full backup:
xtrabackup --defaults-file=/etc/my.cnf --user=backupuser --password=xxxxx --socket=/var/lib/mysql/mysql.sock --compress-threads=4 --stream=xbstream --compress --backup --no-version-check=1 > /root/backup/backup1.qp
prepare
xbstream -x -p 4 -C /root/data < /root/backup/backup1.qp
xtrabackup --decompress --target-dir=/root/data --parallel=4
xtrabackup --prepare --target-dir=/root/data
then I stop mysql and remove the data file
service mysqld stop
mv /var/lib/mysql /var/lib/mysql2
Restoring:
xtrabackup --defaults-file=/etc/my.cnf --copy-back --target-dir=/root/data
change the File Owner and Group to mysql
chown -R mysql:mysql /var/lib/mysql
check:
-rw-r-----. 1 mysql mysql 157 Nov 10 16:21 binlog.000004
-rw-r-----. 1 mysql mysql 14 Nov 10 16:21 binlog.index
drwxr-x---. 2 mysql mysql 60 Nov 10 16:21 DB1
drwxr-x---. 2 mysql mysql 60 Nov 10 16:21 DB2
-rw-r-----. 1 mysql mysql 3542 Nov 10 16:21 ib_buffer_pool
-rw-r-----. 1 mysql mysql 12582912 Nov 10 16:21 ibdata1
-rw-r-----. 1 mysql mysql 50331648 Nov 10 16:21 ib_logfile0
-rw-r-----. 1 mysql mysql 50331648 Nov 10 16:21 ib_logfile1
-rw-r-----. 1 mysql mysql 12582912 Nov 10 16:21 ibtmp1
drwxr-x---. 2 mysql mysql 143 Nov 10 16:21 mysql
-rw-r-----. 1 mysql mysql 25165824 Nov 10 16:21 mysql.ibd
drwxr-x---. 2 mysql mysql 8192 Nov 10 16:21 performance_schema
drwxr-x---. 2 mysql mysql 28 Nov 10 16:21 sys
-rw-r-----. 1 mysql mysql 16777216 Nov 10 16:21 undo_001
-rw-r-----. 1 mysql mysql 16777216 Nov 10 16:21 undo_002
-rw-r-----. 1 mysql mysql 605 Nov 10 16:21 xtrabackup_info
-rw-r-----. 1 mysql mysql 1 Nov 10 16:21 xtrabackup_master_key_id
then i start mysql. find error.
command: service mysqld start
Error message :
Redirecting to /bin/systemctl start mysqld.service
Job for mysqld.service failed because the control process exited with error code. See "systemctl status mysqld.service" and "journalctl -xe" for details.
see mysql log
mysqld: File './binlog.index' not found (OS errno 13 - Permission denied)
2022-11-10T08:21:43.881556Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.28) starting as process 15585
2022-11-10T08:21:43.882576Z 0 [Warning] [MY-013242] [Server] --character-set-server: 'utf8' is currently an alias for the character set UTF8MB3, but will be an alias for UTF8MB4 in a future release. Please consider using UTF8MB4 in order to be unambiguous.
2022-11-10T08:21:43.885546Z 0 [ERROR] [MY-010119] [Server] Aborting
2022-11-10T08:21:43.885803Z 0 [System] [MY-010910] [Server] /usr/sbin/mysqld: Shutdown complete (mysqld 8.0.28) MySQL Community Server - GPL.
I can’t understand. because in /var/lib/mysql ,All file permissions are OK.
when after delete /var/lib/mysql and move mysql2 to mysql, mysql start sucess.
rm -rf /var/lib/mysql
mv /var/lib/mysql2 /var/lib/mysql
mysql is “mysql-8.0.28-1.el7.x86_64”, and xtrabackup is “percona-xtrabackup-80-8.0.28-21.1.el7.x86_64”
OS is centOS7.6
anyone can help me?