zabbix迁移数据库迁移 5.1-5.6

zabbix迁移数据库迁移 5.1-5.6
系统环境:centos6.5
zabbix环境: yum安装
源mysql: Server version 5.1.73
目的mysql:Server version 5.6.21-log 

基本步骤:

1、新安装一台mysql服务器,mysql版本5.6(原来的库是yum安装的5.1)

安装过程不再介绍

2、停止zabbix_Server进程,导出 zabbix数据库

如果数据量不大,可以采用mysqldump ,

但是我这里数据量比较大100G的数据,且不愿意丢失数据,所以才去拷贝的方式迁移库,所以没有采用mysqldump的方式,而是直接拷贝数据文件目录到新的服务器上。

我这里后期直接使用nfs存放数据库文件,所以挂载了nfs,并直接把数据拷贝到nfs上

在mysql5.1的服务器上执行:

mount  10.12.4.11:/nfs/zabbix  /data
nohup rsync -avph --progress /var/lib/mysql  /data/mysql_1.27/ &

3、复制(挂载)zabbix数据库文件到新的mysql服务器上。

在mysql5.6的服务器上执行:

mount  10.12.4.11:/nfs/zabbix  /data

4、导入zabbix数据库(mysqldump备份的,可以直接把sql文件导入数据库),此处直接修改/etc/my.cnf配置文件,把数据库目录指向nfs上拷贝的mysql5.1的数据库文件。

/etc/init.d/mysqld5.6 stop

vim /etc/my.cnf

[mysqld]
#datadir=/var/lib/mysql
datadir=/data/mysql_1.27/mysql
然后启动mysqld
/etc/init.d/mysqld5.6 start
然后执行
/usr/local/mysql/bin/mysql_upgrade  -uroot -p123456
可能会遇到一些报错,但是没关系。
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_index_usage' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'table_io_waits_summary_by_table' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'table_lock_waits_summary_by_table' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'threads' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_current' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_history' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_history_long' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_thread_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_account_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_user_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_summary_by_host_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_stages_summary_global_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_current' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_history' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_history_long' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_thread_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_account_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_user_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_host_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_summary_global_by_event_name' has the wrong structure
2016-07-04 23:29:20 24086 [ERROR] Native table 'performance_schema'.'events_statements_summary_by_digest' has the wrong structure


看着日志,再次重启下
/etc/init.d/mysqld5.6 restart
然后再执行一下 upgrate,更新下数据库,即可
/usr/local/mysql/bin/mysql_upgrade  -uroot -p123456
再次重启   数据库更新完毕。没有报错了
/etc/init.d/mysqld5.6 restart

5、修改zabbix的数据库连接
修改zabbix_server.conf文件里DB相关的地址,用户名和密码。
vim /etc/zabbix/zabbix_server.conf
DBHost=10.12.1.42
DBUser=zbx_user
DBPassword=123456
6、重启服务,重启完,zabbix server收集到的数据 将会写到新的库里面。
/etc/init.d/zabbix-server  restart
但是次数zabbix页面访问的数据还是老的库,需要手动修改

7、修改zabbix页面访问的mysql数据库地址
#我的zabbix版本是2.4,修改配置文件的时候需要通过web页面修改,而没有  /usr/share/zabbix/conf/zabbix.conf.php 配置文件
修改方式:
浏览器登录zabbix(或者直接浏览器输入http://10.12.1.27/zabbix/setup.php
选择  administrator –> Installation 
然后按照向导修改mysql数据库地址即可

你可能感兴趣的:(LINUX,mysql,centos,zabbix,迁移)