mysqldump

1. dump all database into backup file

mysqldump –opt  –all-databases > /tmp/databkup

(–opt includes lock table option)

2. dump several databases

mysqldump –opt –databases db1 db2 db3 > /tmp/databkup

3. dump single table

mysqldump –opt db1 table1 > /tmp/databkup

Touble shooting
Error: Access denied for user x@y to database z when using lock tables
mysqldump -u username -p database –single-transaction >dump.sql

User tar to back up db

mysql> FLUSH TABLES WITH READ LOCK;

(This will lock the db so it won’t be updated by other threads. Write threads by other process will wait till the lock is released)

#tar cvzf /var/tmp/datadump.tgz /var/lib/mysql/*

mysql> UNLOCK TABLES;

Restore data
lock tables bbb write;
mysql bbb < /data_backup/databkup
unlock tables;

requiretty

Some cron didn’t work well after move to CentOS5

New to disable requiretty

May 19 10:40:01 xxx sudo:     root : sorry, you must have a tty to run sudo ; TTY=unknown ; PWD=/www/xxx/bin ; USER=xxx ; COMMAND=/bin/sh moviepagechmod.sh
vi /etc/sudoers
#Defaults    requiretty

Logrotate

Some logrotate  are not working properly

added “/var/log/xxx/*/errors” into /etc/logrotate.d/xxx
and change to weekly

/usr/local/zeus/web/log/errors /var/log/xxx/*/errors {
weekly
rotate 8
missingok
create 0644 nobody nobody
compress
}