Saturday, September 29, 2012

Linux Commands to Monitor Memory usage

1) vmstat: Monitor virtual memory
    Commands
    ----------------------
      vmstat
      vmstat -s -S M

2) top command

3)pmap Display/examine memory map and libraries (so). Usage: pmap pid

4)sar -B Show statistics on page swapping.

5) time -v date Show system page size, page faults, etc of a process during execution. Note you must fully qualify the command as "/usr/bin/time" to avoid using the bash shell command "time".

6)free Display amount of free and used memory in the system.

7)ps aux

To see only the memory resources occupied by each category of processes, such as Apache httpd, MySQL mysqld or Java, use the following command:

ps aux | awk '{print $4"\t"$11}' | sort | uniq -c | awk '{print $2" "$1" "$3}' | sort -nr




Friday, August 31, 2012

Mysql:Give Root User Logon Permission From Any Host
------------------------

 Note that this is Not very secure, and should only be used for a local development box .

To configure this feature, you’ll need to update the mysql user table to allow access from any remote host, using the % wildcard.

Open the command-line mysql client on the server using the root account. There is a chance getting Access denied error.
-------------------

[root@vps mysql]# mysql -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO
 -------------------

 Then you need to reset mysql password. For doing the same you need to stop the current mysql instance and then start mysql in safe mode.

--------------------

 #service mysqld stop or
#killall mysqld


 /usr/bin/mysqld_safe  --skip-grant-tables&


Now Connect to MySQL
#/usr/bin/mysql
Use the mysql database:
mysql>use mysql;
Change the MySQL admin(root) Password using following command


update user set password=password('wgstlfdse') where user='root' and host='localhost';

lush the privileges so everything will take (It removes any privileges set by the server)
mysql>flush privileges;
Then Quit : mysql>quit
Stop MySQL Service
/etc/init.d/mysqld stop
Start MySQL Service
/etc/init.d/mysqld start


Then connect mysql again 

 
 [root@vps ~]# mysql -u root -p
Enter password:


Use the mysql database:
mysql>use mysql;

Now I’ll update the server host to use the wildcard, and then issue the command to reload the privilege tables.

 update user set host='%' where user='root' and host='localhost';

FLUSH PRIVILEGES;


Also change  bind-address value in my.cnf like below.

--------------------
bind-address= *
---------------------


That’s all there is to it.