主机
172.16.0.21
172.16.0.22
centos6.2
分别使用yum安装mysql
给21上的mysql新建库
CREATE DATABASE `replytest1` /*!40100 DEFAULT CHARACTER SET utf8 */;
建表
CREATE TABLE `replytest1`.`test1` (
`id` INT UNSIGNED NOT NULL AUTO_INCREMENT,
`test1col` VARCHAR(45) NULL,
PRIMARY KEY (`id`));
插入数据
INSERT INTO `replytest1`.`test1` (`test1col`) VALUES (’1′);
INSERT INTO `replytest1`.`test1` (`test1col`) VALUES (’2′);
————————————————————————————————————-
修改主库配置文件
server-id = 1 //数据库ID号, 为1时表示为Master,其中master_id必须为1到232–1之间的一个正整数值;
log-bin=mysql-bin //启用二进制日志;
binlog-do-db=data //需要同步的二进制数据库名;可以写多行
binlog-ignore-db=mysql //不同步的二进制数据库名;这个同步后听说很麻烦
log-slave-updates //把更新的记录写到二进制文件中;
slave-skip-errors
创建负责复制的用户
###GRANT ALL PRIVILEGES ON *.* TO [email protected] IDENTIFIED BY ‘reply’ WITH GRANT OPTION;
grant replication slave on *.* to [email protected] identified by ‘********’
flush privileges;
锁定主库
FLUSH TABLES WITH READ LOCK;
导出主表数据
解锁 并 检查当前的master状态及复制到哪里
UNLOCK TABLES;Show master status;
从库设置
修改配置文件
#从库设置
server-id=2
master-host=172.16.0.1
master-user=reply
master-password=reply
master-connect-retry=600 #如果发现主服务器断线,重新连接的时间差;
replicate-ignore-db=mysql
replicate-ignore-db=test
log-slave-update
slave-skip-errors
#从库设置结束
重启mysql
在从服务器上执行stop slave,reset master命令,重置成主数据库
mysql> stop slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> reset master;
change master to master_host=’172.16.0.21′,master_user=’reply’, master_password=’reply’, master_log_file=’mysql-bin.000001′, master_log_pos=106;
Slave start;
mysql> show slave statusG
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 172.16.0.21
Master_User: reply
Master_Port: 3306
Connect_Retry: 600
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 106
Relay_Log_File: mysqld-relay-bin.000002
Relay_Log_Pos: 251
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB: mysql,test
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 106
Relay_Log_Space: 407
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 0
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
1 row in set (0.00 sec)
茶杯头甜蜜终章dlc 官方手机版v1.0.0.3
下载火柴人传说暗影格斗内置菜单 最新版v3.0.1
下载荒野乱斗测试服 安卓版v61.10.3
下载荒野乱斗彩虹服 安卓版v61.10.3
下载寒霜启示录 安卓版v1.25.10
寒霜启示录是一款生存模拟游戏,不少玩家可能对于末日都有着自己
末日城堡免广告版 安卓最新版v0.7.1
末日城堡免广告版是一款非常好玩的模拟经营类游戏,内部可以不看
甜蜜人生模拟器 最新版v1.4.5
甜蜜人生模拟器是一款非常好玩的模拟恋爱手游,玩家在这里能够对
武器锻造师内置功能菜单 v10.4
武器锻造师内置菜单版是游戏的破解版本,在该版本中为玩家提供了
开放空间overfield 安卓版v1.0.5
开放空间Overfield是一款箱庭养成经营手游,让你在广阔