标签:null ges 参数 ica com mysql数据库 oca update 执行
上回提到了用ThinkPHP框架来实现数据库的读写分离,现在就来简单说说MySQL的主从复制。
形式
如图:图来自互联网
条件
原理
步骤
log-bin=mysql-bin // 将mysql二进制日志取名为mysql-bin binlog_format=mixed // 二进制日志的格式,有三种:statement/row/mixed,具体分别不多做解释,这里使用mixed server-id=111 // 为服务器设置一个独一无二的id便于区分,这里使用ip地址的最后一位充当server-id
GRANT replication slave ON *.* TO ‘slave‘@‘%‘ IDENTIFIED BY ‘123456‘;
mysql> GRANT replication slave ON *.* TO ‘slave‘@‘%‘ IDENTIFIED BY ‘123456‘;
Query OK, 0 rows affected (0.00 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 | 315 | | | |
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
master_host=‘192.168.33.110‘ // 设置要连接的主服务器的ip地址
master_user=‘slave‘ // 设置要连接的主服务器的用户名
master_password=‘123456‘ // 设置要连接的主服务器的密码
master_log_file=‘mysql-bin.000001‘ // 设置要连接的主服务器的bin日志的日志名称,即show slave status命令得到的信息File列名称
master_log_pos=315 // 设置要连接的主服务器的bin日志的记录位置,即show slave status命令得到的信息Position列名称,(这里注意,最后一项不需要加引号。否则配置失败)
从数据库配置完成,重启MySQL服务
mysql> start slave;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> show slave status \G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 192.168.33.110
Master_User: slave
Master_Port: 3306
Connect_Retry: 60
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 1036
Relay_Log_File: localhost-relay-bin.000002
Relay_Log_Pos: 1004
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: 1036
Relay_Log_Space: 1181
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: 111
Master_UUID: 39a19e0a-7957-11e6-aa19-0800272020f4
Master_Info_File: /Data/data/mysql/data/master.info
SQL_Delay: 0
SQL_Remaining_Delay: NULL
Slave_SQL_Running_State: Slave has read all relay log; waiting for the slave I/O thread to update it
Master_Retry_Count: 86400
Master_Bind:
Last_IO_Error_Timestamp:
Last_SQL_Error_Timestamp:
Master_SSL_Crl:
Master_SSL_Crlpath:
Retrieved_Gtid_Set:
Executed_Gtid_Set:
Auto_Position: 0
1 row in set (0.00 sec)
最后就可以测试是否可以了~~~
标签:null ges 参数 ica com mysql数据库 oca update 执行
原文地址:http://www.cnblogs.com/timothy-lai/p/6170737.html