PDA

View Full Version : LVM snapshot failure



walterheck
November 24th, 2008, 11:43 PM
Hey guys,

my logs keep showing an error when I use ZRM. First some configurations:

Root's crontab:

[root@web01 /]# crontab -l
0 1 * * * /usr/bin/zrm-pre-scheduler --action backup --backup-set dailyrun --backup-level 0 --interval daily
0 4 * * * /usr/bin/mysql-zrm --action purge


Config file stripped of

[walterheck@web01 ~]$ cat /etc/mysql-zrm/dailyrun/mysql-zrm.conf | grep -v \#
backup-level=0
backup-mode=raw
snapshot-size=20g
snapshot-plugin="/usr/share/mysql-zrm/plugins/lvm-snapshot.pl"
destination=/backup/mysql
retention-policy=10W
compress=1
compress-plugin=/usr/bin/gzip
encrypt=1
encrypt-plugin="/usr/share/mysql-zrm/plugins/encrypt.pl"
decrypt-option="-d"
databases=Hobo smf wordpress mysql
user="backup-user"
password="yeahright"
host="localhost"
port=3306
socket=/var/lib/mysql/mysql.sock
tmpdir=/tmp
verbose=1
mailto="noway@imnottellingya.nope"

the email i receive from the cron job is (only up to the first error message):

pre-schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/zrm-pre-scheduler.log
schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
backup:INFO: ZRM for MySQL Community Edition - version 2.0
dailyrun:backup:INFO: START OF BACKUP
dailyrun:backup:INFO: PHASE START: Initialization
dailyrun:backup:INFO: Mail address: bladiebla@blah.com is ok
dailyrun:backup:INFO: ZRM Temporary configuration file = /etc/mysql-zrm/dailyrun/tmpm3ZO8.conf
dailyrun:backup:INFO: {
dailyrun:backup:INFO: verbose=1
dailyrun:backup:INFO: encrypt-plugin=/usr/share/mysql-zrm/plugins/encrypt.pl
dailyrun:backup:INFO: retention-policy=10W
dailyrun:backup:INFO: tmpdir=/tmp
dailyrun:backup:INFO: destination=/backup/mysql
dailyrun:backup:INFO: decrypt-option=-d
dailyrun:backup:INFO: password=******
dailyrun:backup:INFO: backup-mode=raw
dailyrun:backup:INFO: snapshot-plugin=/usr/share/mysql-zrm/plugins/lvm-snapshot.pl
dailyrun:backup:INFO: compress-plugin=/usr/bin/gzip
dailyrun:backup:INFO: user=backup-user
dailyrun:backup:INFO: quiet=0
dailyrun:backup:INFO: backup-level=0
dailyrun:backup:INFO: encrypt=/usr/share/mysql-zrm/plugins/encrypt.pl
dailyrun:backup:INFO: mailto=bladiebla@blah.com
dailyrun:backup:INFO: databases=Hobo smf wordpress mysql
dailyrun:backup:INFO: port=3306
dailyrun:backup:INFO: socket=/var/lib/mysql/mysql.sock
dailyrun:backup:INFO: host=localhost
dailyrun:backup:INFO: snapshot-size=20g
dailyrun:backup:INFO: compress=/usr/bin/gzip
dailyrun:backup:INFO: }
dailyrun:backup:INFO: Getting mysql variables
dailyrun:backup:INFO: mysqladmin --user="backup-user" --password="*****" --host="localhost" --port="3306" --socket="/var/lib/mysql/mysql.sock" variables
dailyrun:backup:INFO: datadir is /var/lib/mysql/
dailyrun:backup:INFO: mysql_version is 5.0.45
dailyrun:backup:WARNING: Binary logging is off.
dailyrun:backup:INFO: InnoDB data file are /var/lib/mysql/ibdata1
dailyrun:backup:INFO: InnoDB log dir is /var/lib/mysql/.
dailyrun:backup:INFO: backup set being used is dailyrun
dailyrun:backup:INFO: backup-set=dailyrun
dailyrun:backup:INFO: backup-date=20081124010002
dailyrun:backup:INFO: mysql-server-os=Linux/Unix
dailyrun:backup:INFO: host=localhost
dailyrun:backup:INFO: backup-date-epoch=1227506402
dailyrun:backup:INFO: retention-policy=10W
dailyrun:backup:INFO: mysql-zrm-version=ZRM for MySQL Community Edition - version 2.0
dailyrun:backup:INFO: mysql-version=5.0.45
dailyrun:backup:INFO: backup-directory=/backup/mysql/dailyrun/20081124010002
dailyrun:backup:INFO: backup-level=0
dailyrun:backup:INFO: backup-mode=raw
dailyrun:backup:INFO: PHASE END: Initialization
dailyrun:backup:INFO: PHASE START: Running pre backup plugin
dailyrun:backup:INFO: Executing pre-backup-plugin
dailyrun:backup:INFO: PHASE END: Running pre backup plugin
dailyrun:backup:INFO: PHASE START: Flushing logs
dailyrun:backup:INFO: Flushing the logs
dailyrun:backup:INFO: mysqladmin --user="backup-user" --password="*****" --host="localhost" --port="3306" --socket="/var/lib/mysql/mysql.sock" flush-logs
dailyrun:backup:INFO: Getting master logname using command mysql --user="backup-user" --password="*****" --host="localhost" --port="3306" --socket="/var/lib/mysql/mysql.sock" -e "show master status"
dailyrun:backup:INFO: PHASE END: Flushing logs
dailyrun:backup:INFO: PHASE START: Creating snapshot based backup
dailyrun:backup:INFO: innodb on lvm = 0
dailyrun:backup:INFO: getting device details using command /usr/share/mysql-zrm/plugins/lvm-snapshot.pl --action get-vm-device-details --directory /var/lib/mysql/. --sname zrmsyUVSK733x 2>/tmp/bAYUpOtMUR
dailyrun:backup:ERROR: Command /usr/share/mysql-zrm/plugins/lvm-snapshot.pl --action get-vm-device-details --directory /var/lib/mysql/. --sname zrmsyUVSK733x 2>/tmp/bAYUpOtMUR returned error
dailyrun:backup:WARNING: Error getting device details for /var/lib/mysql/.
dailyrun:backup:WARNING: Output of command: 'Getting Device Details' is {
sudo: sorry, you must have a tty to run sudo
Failed to find database: /var/lib/mysql/.
}
dailyrun:backup:INFO: PHASE END: Creating snapshot based backup

but, when I run the manual backup everythign works like a charm:


[root@web01 walterheck]# mysql-zrm-scheduler --now --backup-set dailyrun
schedule:INFO: ZRM for MySQL Community Edition - version 2.0
Logging to /var/log/mysql-zrm/mysql-zrm-scheduler.log
backup:INFO: ZRM for MySQL Community Edition - version 2.0
dailyrun:backup:INFO: START OF BACKUP
dailyrun:backup:INFO: PHASE START: Initialization
dailyrun:backup:WARNING: Binary logging is off.
dailyrun:backup:INFO: backup-set=dailyrun
dailyrun:backup:INFO: backup-date=20081125033653
dailyrun:backup:INFO: mysql-server-os=Linux/Unix
dailyrun:backup:INFO: host=localhost
dailyrun:backup:INFO: backup-date-epoch=1227602213
dailyrun:backup:INFO: retention-policy=10W
dailyrun:backup:INFO: mysql-zrm-version=ZRM for MySQL Community Edition - version 2.0
dailyrun:backup:INFO: mysql-version=5.0.45
dailyrun:backup:INFO: backup-directory=/backup/mysql/dailyrun/20081125033653
dailyrun:backup:INFO: backup-level=0
dailyrun:backup:INFO: backup-mode=raw
dailyrun:backup:INFO: PHASE END: Initialization
dailyrun:backup:INFO: PHASE START: Running pre backup plugin
dailyrun:backup:INFO: PHASE END: Running pre backup plugin
dailyrun:backup:INFO: PHASE START: Flushing logs
dailyrun:backup:INFO: PHASE END: Flushing logs
dailyrun:backup:INFO: PHASE START: Creating snapshot based backup
dailyrun:backup:INFO: Use of uninitialized value in split at /usr/bin/mysql-zrm-backup line 991.
dailyrun:backup:INFO: innodb-data=/var/lib/mysql/ibdata1;
dailyrun:backup:INFO: innodb-logs=/var/lib/mysql/./ib_logfile*
dailyrun:backup:INFO: raw-databases-snapshot=mysql smf wordpress Hobo
dailyrun:backup:INFO: PHASE END: Creating snapshot based backup
dailyrun:backup:INFO: PHASE START: Find table type
dailyrun:backup:INFO: PHASE END: Find table type
dailyrun:backup:INFO: PHASE START: Calculating backup size & checksums
dailyrun:backup:INFO: last-backup=/backup/mysql/dailyrun/20081119123150
dailyrun:backup:INFO: backup-size=310.63 MB
dailyrun:backup:INFO: PHASE END: Calculating backup size & checksums
dailyrun:backup:INFO: PHASE START: Compression/Encryption
dailyrun:backup:INFO: compress=/usr/bin/gzip
dailyrun:backup:INFO: encrypt=/usr/share/mysql-zrm/plugins/encrypt.pl
dailyrun:backup:INFO: decrypt-option=-d
dailyrun:backup:INFO: backup-size-compressed=85.18 MB
dailyrun:backup:INFO: PHASE END: Compression/Encryption
dailyrun:backup:INFO: read-locks-time=00:00:02
dailyrun:backup:INFO: flush-logs-time=00:00:00
dailyrun:backup:INFO: compress-encrypt-time=00:10:50
dailyrun:backup:INFO: backup-time=00:01:50
dailyrun:backup:INFO: backup-status=Backup succeeded
dailyrun:backup:INFO: Backup succeeded
dailyrun:backup:INFO: PHASE START: Running post backup plugin
dailyrun:backup:INFO: PHASE END: Running post backup plugin
dailyrun:backup:INFO: PHASE START: Mailing backup report
dailyrun:backup:INFO: PHASE END: Mailing backup report
dailyrun:backup:INFO: PHASE START: Cleanup
dailyrun:backup:INFO: PHASE END: Cleanup
dailyrun:backup:INFO: END OF BACKUP
/usr/bin/mysql-zrm started successfully


Unfortunately, runnign the command that fails is not possible:
[root@web01 walterheck]# perl /usr/share/mysql-zrm/plugins/lvm-snapshot.pl --action get-vm-device-details --directory /var/lib/mysql/. --sname zrmsyUVSK733x 2
Use of uninitialized value in string at /usr/lib/mysql-zrm/ZRM/SnapshotCommon.pm line 136.
Unable to open config file. This should only meant to be in
voked from mysql-zrm



Anyone have any ideas?

kulkarni_mangesh
November 25th, 2008, 01:23 AM
Error “sudo: sorry, you must have a tty to run sudo Failed to find database: /var/lib/mysql/.” is due to improper configuration of “sudoers”.
On the MySQL server of which you are performing a backup, comment “Defaults requiretty” entry from “/etc/sudoers”.
We are assuming that you have added “mysql” user in “/etc/sudoers” as “mysql ALL=(ALL) NOPASSWD: ALL”.

kulkarni_mangesh
November 25th, 2008, 01:27 AM
We cannot execute “/usr/share/mysql-zrm/plugins/lvm-snapshot.pl” alone, it gets called by “mysql-zrm” command internally, after checking and setting up of required parameters.

walterheck
November 25th, 2008, 05:48 AM
On the MySQL server of which you are performing a backup, comment “Defaults requiretty” entry from “/etc/sudoers”.
We are assuming that you have added “mysql” user in “/etc/sudoers” as “mysql ALL=(ALL) NOPASSWD: ALL”.

wow, i find this quite the security flaw! Is there a more specific list of commands i need to allow mysql user to execute? Can this be done more secure?

Thanks for the comments by the way, the fast and good help is highly appreciated!

kind regards,

Walter

kulkarni_mangesh
November 25th, 2008, 06:19 PM
If we don’t want to give right to execute “all” commands then we can specify following commands in sudoers.
LVM2 related commands ( such as vgdisplay, lvcreate, lvremove, lvscan, lvdisplay ), mount, umount.

kulkarni_mangesh
November 25th, 2008, 08:26 PM
Following is an exact line which needs to be added in /etc/sudoers for LVM snapshot based backups, may need to change path for the commands as per the Operating system.:

mysql <FQDN of zrm server> = NOPASSWD:/bin/mount, NOPASSWD:/bin/umount, NOPASSWD:/bin/df, NOPASSWD:/sbin/lvdisplay, NOPASSWD:/sbin/lvcreate, NOPASSWD:/sbin/lvremove
E.g.
mysql localhost.localdomain = NOPASSWD:/bin/mount, NOPASSWD:/bin/umount, NOPASSWD:/bin/df, NOPASSWD:/sbin/lvdisplay, NOPASSWD:/sbin/lvcreate, NOPASSWD:/sbin/lvremove

Regards,
~Mangesh