redhat linux5.0下虚拟机搭建mysql5.5.40主从复制配置步骤
来源:互联网 发布:mac os x 10.11.6镜像 编辑:程序博客网 时间:2024/06/14 22:53
1、主库配置 在rpm下安装配置文件默认安装位置/usr/share/mysql/my-medium.cnf ,拷贝到/etc目录下 cp my-medium.cnf 到my.cnf;
同样从库也一样配置。
2、主库修改配置文件vi my.cnf 下server-id=1 log-bin=mysql-bin;
3、在主服务器上建立帐户并授权slave
grant replication slave on *.* to 'root'@'192.168.56.129' identified by '123456'
4、重启主库 /etc/init.d/mysql start
5、主服务器的mysql,查询master的状态
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 262 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
从库配置
1、从库修改配置文件 vi my.cnf下server-id=2 ,log-bin=mysql-bin
2、配置从服务器Slave:
mysql> change master to master_host='192.168.56.128',master_user='root',master_password='123456',
-> master_log_file='mysql-bin.000001',master_log_pos=0;
3、检查从服务器复制功能状态:
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.56.128
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: localhost-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
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: 4
Relay_Log_Space: 107
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: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
1 row in set (0.01 sec)
ERROR:
No query specified
SLAVE_IO_RUNING:NO
SLAVE_SQL_RUNING:NO 判断mysql服务没有启动。
4、启动从服务器
start slave
5、检查从服务器复制功能状态 Slave_IO_Running: Yes
Slave_SQL_Running: Yes 正常
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.128
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 262
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 408
Relay_Master_Log_File: mysql-bin.000001
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: 262
Relay_Log_Space: 568
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:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
ERROR:
No query specified
在主服务器上建立测试数据:
mysql> create database ceshi;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ceshi |
| mysql |
| performance_schema |
| student |
| test |
+--------------------+
6 rows in set (0.01 sec)
mysql> use ceshi;
Database changed
mysql> use ceshi;
Database changed
mysql> create table ceshi(id int(3),name char(10));
Query OK, 0 rows affected (0.27 sec)
mysql> select * from ceshi;
Empty set (0.00 sec)
mysql> insert into ceshi values(001,'bobu');
Query OK, 1 row affected (0.05 sec)
mysql> select * from ceshi;
+------+------+
| id | name |
+------+------+
| 1 | bobu |
+------+------+
1 row in set (0.00 sec)
在从服务器上检查服务是否正确
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ceshi |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> use ceshi;
Database changed
mysql> select * from ceshi;
+------+------+
| id | name |
+------+------+
| 1 | bobu |
+------+------+
1 row in set (0.01 sec)
同样从库也一样配置。
2、主库修改配置文件vi my.cnf 下server-id=1 log-bin=mysql-bin;
3、在主服务器上建立帐户并授权slave
grant replication slave on *.* to 'root'@'192.168.56.129' identified by '123456'
4、重启主库 /etc/init.d/mysql start
5、主服务器的mysql,查询master的状态
mysql> show master status;
+------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000001 | 262 | | |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
从库配置
1、从库修改配置文件 vi my.cnf下server-id=2 ,log-bin=mysql-bin
2、配置从服务器Slave:
mysql> change master to master_host='192.168.56.128',master_user='root',master_password='123456',
-> master_log_file='mysql-bin.000001',master_log_pos=0;
3、检查从服务器复制功能状态:
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: 192.168.56.128
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: localhost-relay-bin.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
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: 4
Relay_Log_Space: 107
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: NULL
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 0
1 row in set (0.01 sec)
ERROR:
No query specified
SLAVE_IO_RUNING:NO
SLAVE_SQL_RUNING:NO 判断mysql服务没有启动。
4、启动从服务器
start slave
5、检查从服务器复制功能状态 Slave_IO_Running: Yes
Slave_SQL_Running: Yes 正常
mysql> show slave status \G;
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.56.128
Master_User: root
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 262
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 408
Relay_Master_Log_File: mysql-bin.000001
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: 262
Relay_Log_Space: 568
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:
Replicate_Ignore_Server_Ids:
Master_Server_Id: 1
1 row in set (0.00 sec)
ERROR:
No query specified
在主服务器上建立测试数据:
mysql> create database ceshi;
Query OK, 1 row affected (0.01 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ceshi |
| mysql |
| performance_schema |
| student |
| test |
+--------------------+
6 rows in set (0.01 sec)
mysql> use ceshi;
Database changed
mysql> use ceshi;
Database changed
mysql> create table ceshi(id int(3),name char(10));
Query OK, 0 rows affected (0.27 sec)
mysql> select * from ceshi;
Empty set (0.00 sec)
mysql> insert into ceshi values(001,'bobu');
Query OK, 1 row affected (0.05 sec)
mysql> select * from ceshi;
+------+------+
| id | name |
+------+------+
| 1 | bobu |
+------+------+
1 row in set (0.00 sec)
在从服务器上检查服务是否正确
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| ceshi |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.00 sec)
mysql> use ceshi;
Database changed
mysql> select * from ceshi;
+------+------+
| id | name |
+------+------+
| 1 | bobu |
+------+------+
1 row in set (0.01 sec)
0 0
- redhat linux5.0下虚拟机搭建mysql5.5.40主从复制配置步骤
- linux虚拟机mysql5.6.4-m7搭建MS主从复制。
- mysql5.6版本-主从复制配置详细步骤
- mysql5.6主从复制搭建
- Mysql5.5主从复制配置
- Mysql5.5配置主从复制
- MySql5.7配置主从复制
- mysql5.7配置主从复制
- mysql5.7主从复制配置
- MySQL5.5配置主从复制_CentOS6.5下进行
- ubuntu下的mysql5.7主从复制配置
- Postgres 主从复制搭建步骤
- linux5下安装mysql5
- MySQL5.5复制配置步骤
- Mysql 主从复制配置步骤
- MYSQL主从复制配置步骤
- MySQL5.1版本的主从复制搭建
- MySQL5.5.42 主从复制架构搭建
- CListCtrl控件失去焦点时仍保持高亮
- Android调试,无需数据线
- 数据库生成脚本,架构+数据
- Flume-conf总结-3-dir_dir_hdfs
- 简明 Vim 练级攻略
- redhat linux5.0下虚拟机搭建mysql5.5.40主从复制配置步骤
- Unity3D之移动平台烘培后电脑和手机显示不一样解决方案
- 菜鸟学C语言一:输入到数组
- Next Permutation
- CString总结
- iOS 7: 使用Base64编解码NSData和NSString对象
- 如何学习C++
- Caffe + Ubuntu 14.04 + CUDA 6.5 新手安装配置指南
- ios成长之路之UITextField