Archive for the ‘Linux’ Category

Backup MySQL databases to remote server using mysql-zrm

Recently I use mysql-zrm to backup a large databases from a client server. I can backup all databases or a set of database or maybe some of tables with one line linux command. Pretty easy to use.

You may imagine that mysql-zrm is a strong management tool of mysql, mysqldump and mysqlhotcopy.  The key benifits for me are : I can backup all databases at once with my databases are automatically created if a new client comes; mysql-zrm is able to save compressed data to different folder, so I can keep saved data up to seven days (you may do it one month or maybe one year); It also has a scheduler to do your task every certain time you want.

Installation:

1. login to your backup server

2. Download rpm from http://www.zmanda.com/download-zrm.php

3. If you don’t have Perl installed, run ” yum install perl ”

4. run ” rpm -ivh MySQL-zrm-2.0-1.noarch.rpm ”

5. “  vi /etc/mysql-zrm/mysql-zrm.conf ” update following parameters in file

backup-mode=logical [ ideally raw for myisam engine and logical for innodb. but I recommend using logical for default. Because when I use raw for default value, and if there is table with innodb engine exist, zrm will prompt me password for mysql@(server_ip) which have no idea about linux mysql user login ]

destination=/home/mybackup_dir  [ specify where backup files will be stored]

Start backup:

mysql-zrm –action backup –host xxx.xxx.xxx.xxx –user aabb –password ccdd  –backup-set abcd

where
–host is remote server IP for MySQL
–user is remote MySQL server  user login
–password is remote MySQL server  user login password
–backup-set is backup folder name

Result:

after running the command, you will get backup file in the path look like this

/home/mybackup_dir/abcd/20081128195236

Restore database to local server:

/usr/bin/mysql-zrm-restore –user=1122 –password=2233 –source-directory=/home/mybackup_dir/abcd/20081128195236
check out your backup server MySQL database. :-)

  • Share/Save/Bookmark

Install VMware tools to Fedora 10 client OS on Windows Vista host OS

Software requirements:

  • Windows Vista Ultimate 64bit
  • VMware workstation 6.5.1
  • Fedora 10 64bit

Install packages that are required to build VMware tools:

1
 yum install gcc make kernel-devel</li>

Step by step guide

  1. Logon to Fedora, and select “Install VMware Tools” from VM menu
  2. After the tool cd was mount, open a terminal window logon as root user and type
    1
    2
    3
    
    cd ~
    mkdir VMware
    cd VMWare
  3. Type:
    1
    
    cp /media/VMware\ Tools/VMwareTools-7.8.4-126130.tar.gz ./
  4. Untar and install by typing:
    1
    2
    3
    
    tar zxpf ./VMwareTools-7.8.4-126130.tar.gz
    cd vmware-tools-distrib/
    ./vmware-install.pl
  5. Config and build VMware tool modules:
    1
    
    vmware-config-tools.pl

    and type y when prompt to build vmware modules

Restart your guest OS and then you should have vmware tool installed. You should be able to see your shared folder from the host OS.

  • Share/Save/Bookmark

Linux Server Security Checklist

  • Firewall (apf/csf and bfd)
  • Secure tmp partition (noexec)
  • rootkit scanning
  • PHP hardening
  • Apache hardening
  • Mod-security
  • Shell login notification
  • Share/Save/Bookmark

Troubleshooting Linux High CPU Utilization

troubleshooting linux high cpu utilization

1. us -> User CPU time: The time the CPU has spent running users’
processes that are not niced.
2. sy -> System CPU time: The time the CPU has spent running the
kernel and its processes.
3. ni -> Nice CPU time: The time the CPU has spent running users’
proccess that have been niced.
4. wa -> iowait: Amount of time the CPU has been waiting for I/O to complete.
5. hi -> Hardware IRQ: The amount of time the CPU has been servicing
hardware interrupts.
6. si -> Software Interrupts.: The amount of time the CPU has been
servicing software interrupts.

ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10

  • Share/Save/Bookmark

Troubleshooting High Memory Usage

First of all, this post is nowhere near a complete reference for linux memory usage and troubleshooting high memory usage. It only has the steps I’d taken to troubleshoot my own server when it gets overloaded by increased traffic. It happens once a while, and usually I can fix it by tuning some Apache, MySQL and other config setting.

1. using top command

After executing top command, press “Shift” + “>” and look at “RES” column. The RES column is the most reliable indicator of the real memory usage of that process.

top result

2. ps axu –sort:rss

show memory usage sorted by lowest memory usages first.

A general Apache which serves static html page should consume less than 10MB per process.
For heavily serving PHP pages, in my case it uses 18MB-39MB each httpd process.

mysqld has a memory usage of 120MB in my case. I can tell that the query cache settings worked as planned.

ps aux –sort -vsz | head -25
Top memory hogs

  • Share/Save/Bookmark

Check Linux Versions – common commands part1

  • Check Linux Kernel version:

uname -a

  • Check Linux version

cat /proc/version

  • Check Redhat based Linux version

cat /etc/redhat-release

  • Check PHP version on Linux server

php -v

  • Check mysql version on linux server

mysql -V

  • Check apache version on linux server

httpd -v

  • Share/Save/Bookmark

Install VMware Tools for Fedora 8 in VMware 6.0.2

  1. Click VM-> install VMware tools
  2. In Fedora 8 terminal window, copy WMwareTools-6.0.2-59284.tar.gz into your home folder
  3. unzip it. gzip -d WMwareTools-6.0.2-59284.tar.gz | tar -xvf WMwareTools-6.0.2-59284.tar
  4. run vmware-install.pl
  • Share/Save/Bookmark

SQL Injection vulnerability on Plesk 8.2.0

I just read this one from SWsoft forum.

There is a SQL injection vulnerable security hole exists on Plesk 8.x.x. Yes, it’s even on 8.2.0, which is the latest stable version.

It’s /usr/local/psa/admin/plib/class.Session.php.

Here’s the fix.

  • Share/Save/Bookmark

Linux common commands

1. Check folder size

$ du -hs /path/to/directory

2. Zip a folder

$ zip -r filename.zip /path/to/folder

3. Mount a portable harddrive / usb drive

$/sbin/fdisk -l

4. Check memory usage

$ free -m

by look into the free column of -/+ buffers/cache line, it’s the free memory that can be used by applications.

5. Check if a package is installed (RedHat Enterprise/Fedora/Suse/CentOS)

$rpm -qa | grep PACKAGE-NAME

6. Check file system size
du -h -x

7. Check file system space
df -h

8. Install rpm package
rpm -ivh PACKAGE-NAME

  • Share/Save/Bookmark