关于双机交互热备份实验 配置文件

本文详细介绍了MySQL主从配置的方法及注意事项,包括配置文件my.cnf的具体设置、权限授予、同步参数调整等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

下面为双机交互热备份时候my.ini 配置文件,生产环境中利用双主架构出现问题机会较多,一般只用主从mysql ,现贴上来供参考.

#Master IP: 192.168.0.208
#Slave  IP: 192.168.0.108
#synchronization database: radius
# user: repl     password: repl
[root@localhost lib]# more /etc/my.cnf ##Master mysql database configuration file
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1


# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0


server-id=1
log-bin
binlog-do-db=radius
max_binlog_size=104857600
replicate-same-server-id
#========================
# under setting slave
#========================
master-host=192.168.0.108
master_user=repl
master-password=repl
master-port=3306
master-connect-retry=60
replicate-do-db=radius


binlog-ignore-db=mysql
#log-slave-updates
[mysqld_safe]
log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid






[root@localhost log]# more /etc/my.cnf ##Slave mysql database configuration file
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1


# Disabling symbolic-links is recommended to prevent assorted security risks;
# to do so, uncomment this line:
# symbolic-links=0
server-id=2
log-bin
binlog-do-db=radius
max_binlog_size=104857600
replicate-same-server-id
#========================
# under setting slave
#========================
master-host=192.168.0.208
master_user=repl
master-password=repl
master-port=3306
master-connect-retry=60
# setting synchronization
replicate-do-db=radius
binlog-ignore-db=mysql
#log-slave-updates
[mysqld_safe]
log-error=/var/log/mysqld.log
#pid-file=/var/run/mysqld/mysqld.pid




GRANT REPLICATION SLAVE ON *.* TO 'USER'@'RAH' IDENTIFIED BY 'PASSWORD';
 
CHANGE MASTER TO 
MASTER_HOST='192.168.0.208',MASTER_USER='repl',MASTER_PASSWORD='repl', 
master_log_file="MASER-LOG-FILE",master_log_pos=MASTER_POS;
 
 #=================================================================================
## debug command ,at mysql status
# show master status \G;
# show slave status \G;
# slave start;
# slave stop;


主从配置注意事项:

#Mysql 双机交互热备份注意事项


1>: slave 必须能远程访问 master
GRANT REPLICATION SLAVE ON *.* TO 'USER'@'RAH' IDENTIFIED BY 'PASSWORD';


2>: 如果slave 没有master 的log_file和pos ,必须用下面命令静态指定,
CHANGE MASTER TO 
MASTER_HOST='192.168.0.208',MASTER_USER='repl',MASTER_PASSWORD='repl', 
master_log_file="MASER-LOG-FILE",master_log_pos=MASTER_POS;

3>: "/etc/my.cnf"文件必配置正确,请见my_cnf.sh 脚本


4>: 同步数据库的结构必须一致

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值