标签:socket commit com bst 解锁 默认 table /etc serve
vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
lower_case_table_names=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#设置数据库标识
server-id=2
#任何一个事务提交之后就立即写入到磁盘中的二进制文件
sync_binlog=1
#保持数据一致性,建议配置
innodb_flush_log_at_trx_commit=1
#开启服务器二进制日志
log-bin=mysql-bin
# 为每个session 分配的内存,在事务过程中用来存储二进制日志的缓存
binlog_cache_size=1M
# 主从复制的格式(mixed,statement,row,默认格式是statement)
binlog_format=mixed
# 二进制日志自动删除/过期的天数。默认值为0,表示不自动删除。
expire_logs_days=7
# 如果只有一个数据库,可配置,否则不要建议配置,bin-log Position值不变化,影响同步
#binlog-do-db=db1,db2
binlog-ignore-db=mysql
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
vim /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
symbolic-links=0
lower_case_table_names=1
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
#设置数据库标识
server-id=1
replicate-do-db=db1
replicate-ignore-db=mysql
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
Master DB Server IP:192.168.1.216
Slave DB Server IP:192.168.1.217
# 主服务器创建账号,确保Slave服务器能访问Master服务器数据库
Mysql > grant replication slave on *.* to backup@192.168.1.217 identified by 'MYSQL@2018';
Mysql > flush privileges;
Mysql > show variables like 'server_id';
Mysql > show variables like '%bin';
# 主数据库锁表只读
Mysql > flush tables with read lock;
Mysql > show master status;
# 从库导入数据库
Mysql > change master to MASTER_HOST='192.168.1.216',MASTER_PORT=3306,MASTER_USER='backup',MASTER_PASSWORD='MYSQL@2018',MASTER_LOG_FILE='mysql-bin.00001',MASTER_LOG_POS=1000,master_connect_retry=30;
# 查看状态,启动从库线程
Mysql > show slave status\G
Mysql > start slave;
# 查看同步状态
Mysql > show slave status\G
# 出现
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
# 即配置成功
# 主库解锁数据库
Mysql > unlock tables;
标签:socket commit com bst 解锁 默认 table /etc serve
原文地址:https://www.cnblogs.com/Mrhuangrui/p/8797294.html