线上的有一个c的程序,读了mariadb的数据就core,查了下,我们用了mysql_ping命令,在执行的时候在mariadb的内部core了,用dmesg看了下内核信息,最终定位可能的原因是Mysql的版本问题,所以本次需要将我们用的Mariadb的版本升级到最新,并且测试下是否有问题,页就是一次升级过程。
一 查看OS版本和数据库版本
#mysql
MariaDB [(none)]> select version();
+----------------+
| version() |
+----------------+
| 10.3.7-MariaDB |
操作系统版本:
[root@localhost ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.6.1810 (Core)
Release: 7.6.1810
Codename: Core
二 下载升级
2.1 下载
wget http://ftp.bme.hu/pub/mirrors/mariadb//mariadb-10.4.11/bintar-linux-x86_64/mariadb-10.4.11-linux-x86_64.tar.gz
停止老的mariadb:
service mysqld stop
#查看mysql和mariadb相关的包
rpm -qa|grep mariadb
[root@localhost opt]# rpm -qa | grep mariadb
mariadb-libs-5.5.64-1.el7.x86_64
[root@localhost opt]# rpm -e mariadb-libs-5.5.64-1.el7.x86_64
error: Failed dependencies:
libmysqlclient.so.18()(64bit) is needed by (installed) perl-DBD-MySQL-4.023-5.el7.x86_64
libmysqlclient.so.18()(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) perl-DBD-MySQL-4.023-5.el7.x86_64
libmysqlclient.so.18(libmysqlclient_18)(64bit) is needed by (installed) postfix-2:2.10.1-6.el7.x86_64
发现没有多少个,可能是yum安装,所以用yum查看下安装的mysql和卸载:
[root@localhost opt]# yum list|grep maria
mariadb-libs.x86_64 1:5.5.64-1.el7 @base
holland-mariabackup.noarch 1.1.20-1.el7 epel
mariadb.x86_64 1:5.5.64-1.el7 base
mariadb-bench.x86_64 1:5.5.64-1.el7 base
mariadb-devel.i686 1:5.5.64-1.el7 base
mariadb-devel.x86_64 1:5.5.64-1.el7 base
mariadb-embedded.i686 1:5.5.64-1.el7 base
mariadb-embedded.x86_64 1:5.5.64-1.el7 base
mariadb-embedded-devel.i686 1:5.5.64-1.el7 base
mariadb-embedded-devel.x86_64 1:5.5.64-1.el7 base
mariadb-libs.i686 1:5.5.64-1.el7 base
mariadb-server.x86_64 1:5.5.64-1.el7 base
mariadb-test.x86_64 1:5.5.64-1.el7 base
#卸载
yum remove mariadb-test.x86_64 mariadb-server.x86_64 mariadb-libs.i686 mariadb-embedded-devel.x86_64 mariadb-embedded-devel.i686 mariadb-embedded.x86_64 mariadb-embedded.i686 mariadb-devel.x86_64 mariadb-devel.i686 mariadb-bench.x86_64 mariadb.x86_64 holland-mariabackup.noarch mariadb-libs.x86_64
二 安装
按照官网的步骤,结合我们的安装脚本进行安装,安装参考:https://www.centos.bz/2017/12/mariadb%E4%BA%8C%E8%BF%9B%E5%88%B6%E5%AE%89%E8%A3%85%E5%92%8C%E9%85%8D%E7%BD%AE%E8%AF%B4%E6%98%8E/
结果运行出错:
mariadb Unknown/unsupported storage engine: InnoDB
网上有忽略这个引擎的办法,但是我们的表就用InnoDB引擎,所以智能另外想办法
忽略InnoDB,可以更改my.cnf
[mysqld]
innodb=OFF
ignore-builtin-innodb
skip-innodb
default-storage-engine=myisam
default-tmp-storage-engine=myisam
有人说删除日志,但是我的数据库的数据目录是空的,所以也不存在这个问题。
rm /var/lib/mysql/ib_logfile0
rm /var/lib/mysql/ib_logfile1
看有两个文件没有,则touch下目录和文件:
touch /var/log/mariadb/mariadb.log
chown -R mysql:mysql /var/log/mariadb
mkdir -p /var/run/mariadb
chown -R mysql:mysql /var/run/mariadb
启动下:
systemctl start mariadb
Job for mariadb.service failed because the control process exited with error code. See "systemctl status mariadb.service" and "journalctl -xe" for details
仍然报错:
Process: 15688 ExecStart=/usr/local/mysql/bin/mysqld $MYSQLD_OPTS $_WSREP_NEW_CLUSTER $_WSREP_START_POSITION (code=exited, status=1/FAILURE)
Process: 15661 ExecStartPre=/bin/sh -c [ ! -e /usr/local/mysql/bin/galera_recovery ] && VAR= || VAR=`/usr/local/mysql/bin/galera_recovery`; [ $? -eq 0 ] && systemctl set-environment _WSREP_START_POSITION=$VAR || exit 1 (code=exited, status=0/SUCCESS)
Process: 15659 ExecStartPre=/bin/sh -c systemctl unset-environment _WSREP_START_POSITION (code=exited, status=0/SUCCESS)
Main PID: 15688 (code=exited, status=1/FAILURE)
Status: "MariaDB server is down"
Jan 07 10:42:43 localhost.localdomain mysqld[15688]: 2020-01-07 10:42:43 0 [Note] InnoDB: Starting shutdown...
Jan 07 10:42:43 localhost.localdomain mysqld[15688]: 2020-01-07 10:42:43 0 [ERROR] Plugin 'InnoDB' init function returned error.
Jan 07 10:42:43 localhost.localdomain mysqld[15688]: 2020-01-07 10:42:43 0 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
Jan 07 10:42:43 localhost.localdomain mysqld[15688]: 2020-01-07 10:42:43 0 [Note] Plugin 'FEEDBACK' is disabled.
Jan 07 10:42:43 localhost.localdomain mysqld[15688]: 2020-01-07 10:42:43 0 [ERROR] Unknown/unsupported storage engine: InnoDB
Jan 07 10:42:43 localhost.localdomain mysqld[15688]: 2020-01-07 10:42:43 0 [ERROR] Aborting
Jan 07 10:42:44 localhost.localdomain systemd[1]: mariadb.service: main process exited, code=exited, status=1/FAILURE
Jan 07 10:42:44 localhost.localdomain systemd[1]: Failed to start MariaDB 10.4.11 database server.
Jan 07 10:42:44 localhost.localdomain systemd[1]: Unit mariadb.service entered failed state.
运行:journalctl -xe
查看: /usr/local/mysql/bin/mysqld 报错是没有这个目录,所以看下权限,更改下目录的权限:
chown -R mysql:mysql /usr/local/mysql
启动成功!