一、master主服务器的配置
示例:pandas 是基于NumPy 的一种工具,该工具是为了解决数据分析任务而创建的。
1.1 停止mysql服务
1.2编辑my.cnf
主数据库配置:vim /etc/my.cnf
server_id=146
log-bin=mysql-bin
binlog_do_db=db1
binlog_do_db=db2
1.3 启动MySQL服务
1.4 master数据库配置slave
[root@localhost mysql]
Enter password:
mysql> grant replication slave on *.* to masterbackup@'192.168.17.%' identified by '123456';
mysql> exit;
1.5 重启MySQL服务
[root@localhost mysql]
Enter password:
mysql> show master status;
+-------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+-------------------+----------+--------------+------------------+-------------------+
| master-bin.000001 | 154 | test | | |
+-------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
二、slave从服务器配置
2.1 编辑 my.cnf
server_id=210
log-bin=mysql-bin
binlog_do_db=db1
binlog_do_db=db2
2.2 重启MySQL服务
change master to master_host='master_db_ip',master_user='root',master_password='pwd',master_log_file='mysql-bin.000001',master_log_pos=154;
show VARIABLES like '%server_id%'
2.3 Slave启动数据库同步
mysql> start slave;
mysql> stop slave;
2.4 查看slave信息
show slave status\G;
Slave_IO_Running和Slave_SQL_Running都为yes,则表示同步成功。
|