mysql主从复制
来源:网络 责任编辑:栏目编辑 发表时间:2013-07-02 00:37 点击:次
一、环境描述
主数据库服务器ip:192.168.0.2
从数据库服务器ip:192.168.0.3
主从服务器上的mysql已全新安装,但并为投入生产,所以无数据产生。
二、主从复制配置
1.主数据库服务器master配置
(1)为从服务器slave授权
mysql> grant replication slave on *.* to slave@192.168.0.3 identified by "123";
(2)查看master状态
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 400 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
记下file和position,一会配置slave会用到。(file为mysql日志的文件,position为日志的线索号,从服务器将从这么位置开始复制)
2.从数据库服务器slave配置
(1)修改slave的server id,避免和其他mysql数据库的重复
vi /etc/my.cnf
server-id = 2
(2)执行sql语句的同步
mysql> change master to master_host=192.168.0.2, master_user=slave, master_password=123, master_log_file=mysql-bin.000003, master_log_pos=400;
(3)启动slave的同步功能
mysql> start slave;
(4)查看slave状态
mysql> show slave status G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.2
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 548
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 399
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
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: 548
&nb
主数据库服务器ip:192.168.0.2
从数据库服务器ip:192.168.0.3
主从服务器上的mysql已全新安装,但并为投入生产,所以无数据产生。
二、主从复制配置
1.主数据库服务器master配置
(1)为从服务器slave授权
mysql> grant replication slave on *.* to slave@192.168.0.3 identified by "123";
(2)查看master状态
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000003 | 400 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
记下file和position,一会配置slave会用到。(file为mysql日志的文件,position为日志的线索号,从服务器将从这么位置开始复制)
2.从数据库服务器slave配置
(1)修改slave的server id,避免和其他mysql数据库的重复
vi /etc/my.cnf
server-id = 2
(2)执行sql语句的同步
mysql> change master to master_host=192.168.0.2, master_user=slave, master_password=123, master_log_file=mysql-bin.000003, master_log_pos=400;
(3)启动slave的同步功能
mysql> start slave;
(4)查看slave状态
mysql> show slave status G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.0.2
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000003
Read_Master_Log_Pos: 548
Relay_Log_File: mysql-relay-bin.000002
Relay_Log_Pos: 399
Relay_Master_Log_File: mysql-bin.000003
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB:
Replicate_Ignore_DB:
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: 548
&nb
相关新闻>>
最新推荐更多>>>
- 发表评论
-
- 最新评论 更多>>