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

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)
CHANGEmasterTOmaster_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 SLAVEmakes 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 themaster.infoandrelay-log.infofiles, all the relay log files, and starts a new relay log file. To useRESET SLAVE, the slave replication threads must be stopped (useSTOP SLAVEif 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 aSTOP SLAVEstatement or if the slave is highly loaded.)
In MySQL 5.5 (unlike the case in MySQL 5.1 and earlier),RESET SLAVEdoes not change any replication connection parameters such as master host, master port, master user, or master password, which are retained in memory. This means thatSTART SLAVEcan be issued without requiring aCHANGE MASTER TOstatement followingRESET SLAVE.
In MySQL 5.5.16 and later, you can useRESET SLAVE ALLto reset these connection parameters (Bug #11809016). Connection parameters are also reset if the slavemysqldis shut down.
If the slave SQL thread was in the middle of replicating temporary tables when it was stopped, andRESET SLAVEis issued, these replicated temporary tables are deleted on the slave.


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




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