Cold backup instructions
We want to back up 200G MySQL data. If you use dump backup, it is very slow. Cold backup is simple and violent.
First prepare two virtual machines
centos7.8
192.168.59.144
192.168.59.143
1. Simulate a piece of data
MariaDB [(none)]> create database dzw charset utf8;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> use dzw;
Database changed
MariaDB [dzw]> create table stu(ID int(5),NAME varchar(10));
Query OK, 0 rows affected (0.01 sec)
MariaDB [dzw]> insert into stu values(1,"暴躁程序员");
Query OK, 1 row affected (0.00 sec)
MariaDB [dzw]> select * from stu;
+------+-----------------+
| ID | NAME |
+------+-----------------+
| 1 | 暴躁程序员 |
+------+-----------------+
1 row in set (0.00 sec)
2. Turn off MySQL copy backup
systemctl stop mariadb
cd /var/lib/
打包mysql目录
zip -r mysql.zip mysql/
传输到恢复服务器
scp mysql.zip root@192.168.59.144:/root
3. Restore the backup under the new server
解包
unzip mysql.zip
移动到刚才修改好的目录下
mv mysql /usr/local/
Error resolution
After moving, I found that MySQL can't get up
tailf /var/log/messages
Check the log
because the owner of the MySQL directory is not assigned to the group
chown -R mysql:mysql /usr/local/mysql/
Start after configuration
systemctl start mariadb
After starting, check whether our data exists
use dzw
select * from stu;
+------+-----------------+
| ID | NAME |
+------+-----------------+
| 1 | 暴躁程序员 |
+------+-----------------+
1 row in set (0.00 sec)
If there is a successful recovery! ! !