2015/9/9 11:12:45
主机名 | ip地址 | 操作系统 | 应用角色 | 操作 |
---|---|---|---|---|
Linux | 192.168.1.107 | Centos 6.6 | zabbix-server & zabbix-agent | 升级mysql版本 |
软件名 | 升级前软件版本 | 升级后版本 |
---|---|---|
Mysql | 5.1.73 | 5.6.26 |
[root@Linux mysql]# pwd
/var/lib/mysql
[root@Linux mysql]# tar zcf ../mysql.tar.gz mysql
[root@Linux]# cp /etc/my.cnf /etc/my.cnf.bak
[root@Linux]# service mysqld stop
[root@Linux]# wget http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
[root@Linux ~]# yum localinstall mysql-community-release-el6-5.noarch.rpm
#可以通过下面的命令来确认这个仓库被成功添加:
[root@Linux yum.repos.d]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community MySQL Connectors Community 14
mysql-tools-community MySQL Tools Community 27
mysql56-community MySQL 5.6 Community Server 180
查看/etc/yum.repos.d/mysql-community.repo配置文件,里面列出了 mysql-5.5 mysql-5.7,但是默认打开了 mysql-5.6,其余两个关闭,重点看enabled=xxx这一项,=0为关闭,=1为打开,如下图
注意:一次只能打开一个版本,否则yum不会选择这个文件的,又自动升级 5.1版本去了。
[root@Linux yum.repos.d]# yum makecache
#查看mysql repo相关软件包
[root@Linux]# yum list | grep mysql-community
mysql-community-release.noarch el6-5 @/mysql-community-release-el6-5.noarch
mysql-community-bench.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-client.i686 5.6.26-2.el6 mysql56-community
mysql-community-client.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-common.i686 5.6.26-2.el6 mysql56-community
mysql-community-common.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-devel.i686 5.6.26-2.el6 mysql56-community
mysql-community-devel.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-embedded.i686 5.6.26-2.el6 mysql56-community
mysql-community-embedded.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-embedded-devel.i686 5.6.26-2.el6 mysql56-community
mysql-community-embedded-devel.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-libs.i686 5.6.26-2.el6 mysql56-community
mysql-community-libs.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-libs-compat.i686 5.6.26-2.el6 mysql56-community
mysql-community-libs-compat.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-server.x86_64 5.6.26-2.el6 mysql56-community
mysql-community-test.x86_64 5.6.26-2.el6 mysql56-community
#安装高版本mysql
[root@Linux yum.repos.d]# yum install mysql-community-server.x86_64 -y
[root@Linux ~]# mysql --version
mysql Ver 14.14 Distrib 5.1.73, for redhat-linux-gnu (x86_64) using readline 5.1
[root@Linux ~]# mysql --version
mysql Ver 14.14 Distrib 5.6.26, for Linux (x86_64) using EditLine wrapper
[root@Linux yum.repos.d]# mysql --version
mysql Ver 14.14 Distrib 5.6.26, for Linux (x86_64) using EditLine wrapper
[root@Linux yum.repos.d]# service mysqld restart
停止 mysqld: [确定]
正在启动 mysqld: [确定]
[root@Linux yum.repos.d]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.6.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
[root@Linux yum.repos.d]# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 3327 mysql 10u IPv6 30158 0t0 TCP *:mysql (LISTEN)
#zabbix原先有监控mysql数据模板,并测试可以正常使用,可以去参考我直接发表的zabbix 2.4监控mysql所示,但是升级完后一直监控不到,查看mysql日志,发现如下:
#上述所说的是缺表现象,解决办法:
#由于是将低版本的MySQL datadir目录直接拷贝到5.6.21-enterprise-commercial-advanced-log的,低版本的mysql这个schema中并没有innodb_table_stats,innodb_index_stats这些表。所以登录到mysql这个schema中手工创建这些表后,重启mysql即可。
[root@Linux log]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 43
Server version: 5.6.26 MySQL Community Server (GPL)
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| test |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)
mysql> use mysql
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> CREATE TABLE `innodb_table_stats` (
-> `database_name` varchar(64) COLLATE utf8_bin NOT NULL,
-> `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
-> `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-> `n_rows` bigint(20) unsigned NOT NULL,
-> `clustered_index_size` bigint(20) unsigned NOT NULL,
-> `sum_of_other_index_sizes` bigint(20) unsigned NOT NULL,
-> PRIMARY KEY (`database_name`,`table_name`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
Query OK, 0 rows affected (0.17 sec)
mysql> CREATE TABLE `innodb_index_stats` (
-> `database_name` varchar(64) COLLATE utf8_bin NOT NULL,
-> `table_name` varchar(64) COLLATE utf8_bin NOT NULL,
-> `index_name` varchar(64) COLLATE utf8_bin NOT NULL,
-> `last_update` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
-> `stat_name` varchar(64) COLLATE utf8_bin NOT NULL,
-> `stat_value` bigint(20) unsigned NOT NULL,
-> `sample_size` bigint(20) unsigned DEFAULT NULL,
-> `stat_description` varchar(1024) COLLATE utf8_bin NOT NULL,
-> PRIMARY KEY (`database_name`,`table_name`,`index_name`,`stat_name`)
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin STATS_PERSISTENT=0;
Query OK, 0 rows affected (0.02 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
#再查看zabbix监控mysql图像,看是否有数据
(●’◡’●)
http://blog.chinaunix.net/uid-28216282-id-4848404.html
http://www.linuxidc.com/Linux/2014-11/109144.htm
http://blog.csdn.net/lwei_998/article/details/41278457