关闭原集群mha 由于集群软件在侦测到主服务器失效后会干预相关资源,造成备机身份切换和IP飘移,为了避免这种影响,要关掉集群 [mysql@slave02 bin]$ masterha_check_status [mysql@slave02 bin]$ masterha_check_status --conf=/etc/app1.cnf app1 is stopped(2:NOT_RUNNING). [mysql@slave02 bin]$ ps faux | grep manager mysql 27192 0.0 0.0 103244 864 pts/2 S+ 00:23 Configuration File for keepalived global_defs { router_id LVS_slave01 } vrrp_instance VI_3 { state MASTER interface eth0 virtual_router_id 3 priority 85 advert_int 1 authentication
观察到数据库的连接比如 :3306 在数据库里可以使用 show processlist 来看连接 (必要的时候可以停止原master数据库) [root@origin-master ~]# /etc/init.d/mysql stop Shutting down MySQL........................................[ OK ].
前言 有了keepalived和mysql upgrade的技术作基础,可以结合两者完成无逢升级 下面分享一下我的 Best Practice Of Mysql Migration ---- 概要 -- -- 准备工作 下面步骤最好作为准备工作,提前完成,这样可以更有效进行切换,和减少窗口期 挂载NFS 安装软件包的收集(mysql,xtrabackup,keepalived) 安装keepalived
前言 有了keepalived和mysql upgrade的技术作基础,可以结合两者完成无逢升级 下面分享一下我的 Best Practice Of Mysql Migration ---- 概要 -- -- 准备工作 下面步骤最好作为准备工作,提前完成,这样可以更有效进行切换,和减少窗口期 挂载NFS 安装软件包的收集(mysql,xtrabackup,keepalived) 安装keepalived
参考链接 此处为语雀内容卡片,点击链接查看:MySQL 5.7.27 迁移 DM 8 · 语雀 迁移前准备 以下中的命名,密码都是可修改的,这里给出的就只是一个例子 创建表空间 # 创建表空间名为 dbTest tablespace "dbTest"; 授予权限 -- 授予用户 dbTest 常规权限 grant "PUBLIC","RESOURCE","SOI","SVI","VTI" to "dbTest"; 迁移 1)打开 dm 数据迁移工具 2)点击新建迁移 3)选择迁移方式 4)源数据库连接(mysql) 5)目的数据库连接(dm数据库) 6)选择迁移选项 保持对象名大小写:看情况选择,如果是大小写不敏感可以直接勾选 ,比如 列超出定义 7)勾选需要迁移的数据库 建议 目的模式 改为全大写,还是尽量 用户名,模式名 全大写并且一致 8)勾选要迁移的表 9)迁移 迁移问题 列长度超出定义 问题 解决 1) 第一种:扩大字段的长度,例如:1.5倍 2)第二种(适用于 mysql 中 varchar 字段):将 varchar 的字段类型替换成 nvarchar 步骤 在指定表页面中,选中出问题的表,点击转换
Configuration File for keepalived global_defs { router_id LVS_new_master } vrrp_instance VI_3 { state BACKUP interface em1 virtual_router_id 3 priority 150 advert_int 1 authentication
修改zabbix统计数据过期时间 [root@new-master mysql]# vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh [root@new-master mysql]# grep 120 /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh if ========================== Installing: libev x86_64 4.03-3. -4.013-3.el6.x86_64 has missing requires of libmysqlclient.so.16()(64bit) perl-DBD-MySQL-4.013-3.el6. el6.x86_64 1/1 Verifying : libev-4.03-3.el6.x86_64 1/1 Installed: libev.x86_64 0:4.03-3.el6
要确保mysql 数据库的 datadir是清空的,否则会报错 [root@slave02 data]# cat restore.log nohup: ignoring input Warning: /usr/bin/innobackupex version 2.3.2 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 306a2e0 ) Original data directory /var/lib/mysql is not empty! ) Original data directory /var/lib/mysql is not empty! 开头的文件 如: .bash_history .lesshst .mysql_history .viminfo 要指明删,如 rm -rf .bash_history .lesshst .mysql_history
要确保mysql 数据库的 datadir是清空的,否则会报错 [root@slave02 data]# cat restore.log nohup: ignoring input Warning: /usr/bin/innobackupex version 2.3.2 based on MySQL server 5.6.24 Linux (x86_64) (revision id: 306a2e0 ) Original data directory /var/lib/mysql is not empty! ) Original data directory /var/lib/mysql is not empty! 开头的文件 如: .bash_history .lesshst .mysql_history .viminfo 要指明删,如 rm -rf .bash_history .lesshst .mysql_history
myisam_recover_options [testuser@slave01 etc]$ innodb_additional_mem_pool_size 也已经被弃用了,如果有要注释掉 ---- 将zabbit加入mysql 组以方便监控 [root@new-master mysql]# vim /etc/group [root@new-master mysql]# id zabbix uid=496(zabbix) gid =493(zabbix) groups=493(zabbix),492(mysql) [root@new-master mysql]# /etc/init.d/zabbix-agent restart ]# ---------- [root@zabbix-server ~]# zabbix_get -s new-master -p 10050 -k "mysql.slowlog[100,/var/lib /mysql/new-master-slow.log]" 2.98465 [root@zabbix-server ~]#
Configuration File for keepalived global_defs { router_id LVS_new_master } vrrp_instance VI_3 { state BACKUP interface em1 virtual_router_id 3 priority 150 advert_int 1 authentication
修改zabbix统计数据过期时间 [root@new-master mysql]# vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh [root@new-master mysql]# grep 120 /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh if ========================== Installing: libev x86_64 4.03-3. -4.013-3.el6.x86_64 has missing requires of libmysqlclient.so.16()(64bit) perl-DBD-MySQL-4.013-3.el6. el6.x86_64 1/1 Verifying : libev-4.03-3.el6.x86_64 1/1 Installed: libev.x86_64 0:4.03-3.el6
]# chown -R mysql.mysql /var/lib/mysql/ [root@slave02 mysql]# ll total 5916780 drwx------ 2 mysql mysql ---- 2 mysql mysql 36864 Dec 9 03:57 mysqltestt_db drwx------ 2 mysql mysql 4096 Dec 9 03 drwx------ 2 mysql mysql 4096 Dec 9 02:52 ijavadb drwx------ 2 mysql mysql 12288 Dec 9 4096 Dec 9 02:45 mysql drwx------ 2 mysql mysql 4096 Dec 9 02:49 testdb drwx------ 2 mysql mysql mysql mysql 20480 Dec 9 03:08 /data/mysql/ [root@slave02 mysql]#
full_backup.log xtrabackup: innodb_log_group_home_dir = ./ xtrabackup: innodb_log_files_in_group = 3 [root@slave01 data]# cd /var/lib/mysql/ [root@slave01 mysql]# ls livedb slave01-relay-bin.000308 .000309 ibdata1 wavedb mysql-bin.000155 mysql-bin.000160 functiondb mysqltest_his slave01 ib_logfile2 mysql mysql-bin.000158 keydb [root@slave01 mysql]# rm -rf * [root@slave01 mysql ]# ls [root@slave01 mysql]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda3
myisam_recover_options [testuser@slave01 etc]$ innodb_additional_mem_pool_size 也已经被弃用了,如果有要注释掉 ---- 将zabbit加入mysql 组以方便监控 [root@new-master mysql]# vim /etc/group [root@new-master mysql]# id zabbix uid=496(zabbix) gid =493(zabbix) groups=493(zabbix),492(mysql) [root@new-master mysql]# /etc/init.d/zabbix-agent restart ]# ---------- [root@zabbix-server ~]# zabbix_get -s new-master -p 10050 -k "mysql.slowlog[100,/var/lib /mysql/new-master-slow.log]" 2.98465 [root@zabbix-server ~]#
innobackupex: Backup created in directory '/data/nfs/test_full_backup/2015-12-09_00-53-03' innobackupex: MySQL binlog position: filename 'mysql-bin.000004', position 8299670 151209 02:06:09 innobackupex: Connection
启动mysql并且开启同步 [root@slave02 mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Your MySQL connection id is 1 Server version: 5.6.27-75.0-log Percona Server (GPL), Release 75.0, Revision mysql> show slave status\G Empty set (0.00 sec) mysql> CHANGE MASTER TO MASTER_HOST='192.168.66.100' =8299670; Query OK, 0 rows affected, 2 warnings (0.01 sec) mysql> show slave status\G ************** hostname slave02 mysql>
/tmp/old /tmp/new id zabbix /etc/init.d/zabbix-agent restart zabbix_get -s new-master -p 10050 -k "mysql.slowlog [100,/var/lib/mysql/new-master-slow.log]" vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh grep 120 /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh yum install libev rpm -e xtrabackup test_full_backup/2015-12-09_00-53-03/ >> restore.log 2>&1 & tail -f restore.log watch -n 2 du -sh /data/mysql / cat xtrabackup_binlog_pos_innodb chown -R mysql.mysql /var/lib/mysql/ 原文地址
更新slave mysql版本 [root@slave02 src]# rpm -e Percona-Server-client-51-5.1.73-rel14.11.603.rhel6.x86_64 -4.013-3.el6.x86_64 libmysqlclient.so.16()(64bit) is needed by (installed) php-mysql-5.3.3-40.el6_6. -4.013-3.el6.x86_64 libmysqlclient.so.16(libmysqlclient_16)(64bit) is needed by (installed) php-mysql libmysqlclient_r.so': File exists 2:Percona-Server-client-5########################################### [ 67%] 3: SONAME 'libfnv1a_udf.so'" mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'" mysql
启动mysql并且开启同步 [root@slave02 mysql]# mysql -u root -p Enter password: Welcome to the MySQL monitor. Your MySQL connection id is 1 Server version: 5.6.27-75.0-log Percona Server (GPL), Release 75.0, Revision mysql> show slave status\G Empty set (0.00 sec) mysql> CHANGE MASTER TO MASTER_HOST='192.168.66.100' [100,/var/lib/mysql/new-master-slow.log]" vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh / cat xtrabackup_binlog_pos_innodb chown -R mysql.mysql /var/lib/mysql/ 原文地址