linux回炉第二十四天

时间:2023-01-14 11:55:14
mysqldump --help
mysqldump -uroot hellodb | gzip > /data/backup_mysql.sql.gz
mysqldump -uroot -B hellodb > /data/mysql_backup1.sql
mysqldump -uroot -A > /data/mysql_backup_all.sql

mysql -uroot < /data/mysql_backup1.sql

for i in `mysql -e 'show databases;' | egrep -v '^(database|information_schema|performance_schema|sys)$'` ; do mysqldump -B $i > /data/mysql_bak_$i_`data +%F`.sql
xtrabackup --help
主从
2-2-3
2个以上实例
2个二进制日志
3个线程


1、 server id
2、 授权用户名密码
3、 开启二进制日志
4、 二进制日志位置
~]# vim /etc/my.cnf.d/mysql-server.cnf
[mysqld]
server-id=48
~]# systemctl restart mysqld
~]# mysql
> show master logs;
binlog.000002 | 156 | No

> create user repluser@'11.0.1.%' identified by '123456';
> grant replication slave on *.* to repluser@'11.0.1.%';

> show master logs;
| binlog.000002 | 681 | No |


~]# vim /etc/my.cnf.d/mysql-server.cnf
[mysqld]
server-id=68
~]# systemctl restart mysqld
~]# mysql
> help change master to

> CHANGE MASTER TO
MASTER_HOST='11.0.1.48',
MASTER_USER='repluser',
MASTER_PASSWORD='123456',
MASTER_PORT=3306,
MASTER_LOG_FILE='binlog.000002',
MASTER_LOG_POS=681,
MASTER_CONNECT_RETRY=10;

> start slave;
> show slave status\G