[转帖]mysql slave 转为 master _MySQL, Oracle及数据库讨论区_Weblogic技术|Tuxedo技术|中间件技术|Oracle论坛|JAVA论坛|Linux/Unix技术|hadoop论坛_联动北方技术论坛  
网站首页 | 关于我们 | 服务中心 | 经验交流 | 公司荣誉 | 成功案例 | 合作伙伴 | 联系我们 |
联动北方-国内领先的云技术服务提供商
»  游客             当前位置:  论坛首页 »  自由讨论区 »  MySQL, Oracle及数据库讨论区 »
总帖数
1
每页帖数
101/1页1
返回列表
0
发起投票  发起投票 发新帖子
查看: 2148 | 回复: 0   主题: [转帖]mysql slave 转为 master         下一篇 
tangbao@.@
注册用户
等级:新兵
经验:67
发帖:62
精华:0
注册:2011-7-21
状态:离线
发送短消息息给tangbao@.@ 加好友    发送短消息息给tangbao@.@ 发消息
发表于: IP:您无权察看 2014-12-12 9:08:34 | [全部帖] [楼主帖] 楼主

1  检查日志是否已全部应用:

mysql> show processlist;
+----+-------------+--------------------+------+---------+------+-----------------------------------------------------------------------+------------------+
| Id | User        | Host               | db   | Command | Time | State                                                                 | Info             |
+----+-------------+--------------------+------+---------+------+-----------------------------------------------------------------------+------------------+
|  1 | root        | localhost          | test | Query   |    0 | NULL                                                                  | show processlist |
|  4 | system user |                    | NULL | Connect |  345 | Waiting for master to send event                                      | NULL             |
|  5 | system user |                    | NULL | Connect |  295 | Has read all relay log; waiting for the slave I/O thread to update it | NULL             |
|  7 | testuser    | 192.168.1.100:1506 | NULL | Sleep   |  122 |                                                                       | NULL             |
|  8 | testuser    | 192.168.1.100:1507 | test | Sleep   |   86 |                                                                       | NULL             |
|  9 | testuser    | 192.168.1.100:1508 | test | Sleep   |   29 |                                                                       | NULL             |
+----+-------------+--------------------+------+---------+------+-----------------------------------------------------------------------+------------------+
6 rows in set (0.00 sec)


2  停止slave,去掉readonly,reset slave:

mysql> stop slave;
Query OK, 0 rows affected (0.00 sec)
CHANGE master TO master_host='';
mysql> SET global read_only=0;
Query OK, 0 rows affected (0.00 sec)
mysql> reset slave;
Query OK, 0 rows affected (0.04 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+
| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------+----------+--------------+------------------+
| mysql-bin.000004 |      869 |              |                  |
+------------------+----------+--------------+------------------+
1 row in set (0.00 sec)


3 修改my.cnf 一些参数(可以考虑重启一下)

4 关于 reset slave:

RESET SLAVE [ALL]
RESET SLAVE makes the slave forget its replication position in the master's binary log. This statement is meant to be used for a clean start: It deletes the master.info and relay-log.info files, all the relay log files, and starts a new relay log file. To use RESET SLAVE, the slave replication threads must be stopped (use STOP SLAVE if necessary).
Note
All relay log files are deleted, even if they have not been completely executed by the slave SQL thread. (This is a condition likely to exist on a replication slave if you have issued a STOP SLAVE statement or if the slave is highly loaded.)
In MySQL 5.5 (unlike the case in MySQL 5.1 and earlier), RESET SLAVE does not change any replication connection parameters such as master host, master port, master user, or master password, which are retained in memory. This means that START SLAVE can be issued without requiring a CHANGE MASTER TO statement following RESET SLAVE.
In MySQL 5.5.16 and later, you can use RESET SLAVE ALL to reset these connection parameters (Bug #11809016). Connection parameters are also reset if the slave mysqld is shut down.
If the slave SQL thread was in the middle of replicating temporary tables when it was stopped, and RESET SLAVE is issued, these replicated temporary tables are deleted on the slave.


--转自 北京联动北方科技有限公司




赞(0)    操作        顶端 
总帖数
1
每页帖数
101/1页1
返回列表
发新帖子
请输入验证码: 点击刷新验证码
您需要登录后才可以回帖 登录 | 注册
技术讨论