Mariadb版本升级

Mairadb 版本升级

闲来无事,把CentOS更新了一下,发现原来安装Mariadb的源请求不到了。

看了一下Mariadb官方的源,本来安装的时候,Mariadb的版本是10.9,官方源从10.6直接到10.11了。这样一下子更新就报错了。

1
2
3
4
5
6
7
8
9
10
11
12
yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
https://mirrors.aliyun.com/mariadb/yum/10.9/rhel/7/x86_64/repodata/repomd.xml: [Errno 14] HTTPS Error 404 - Not Found
Trying other mirror.
To address this issue please refer to the below wiki article

https://wiki.centos.org/yum-errors

If above article doesn't help to resolve this issue please use https://bugs.centos.org/.

No packages marked for update

一下子找不到源了,心想,是不是可以直接升级到10.11算了。

重新配置Mariadb的源

直接在[Mariadb][1]的官方网站,通过选择Mariadb的版本,选择CentOS版本,选择对应的源,在中国我们选择阿里的源。生成的配置文件如下:

1
2
3
4
5
6
7
8
9
10
11
# MariaDB 10.11 CentOS repository list - created 2024-05-18 06:30 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# rpm.mariadb.org is a dynamic mirror if your preferred mirror goes offline. See https://mariadb.org/mirrorbits/ for details.
# baseurl = https://rpm.mariadb.org/10.11/centos/$releasever/$basearch
baseurl = https://mirrors.aliyun.com/mariadb/yum/10.11/centos/$releasever/$basearch
module_hotfixes = 1
# gpgkey = https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey = https://mirrors.aliyun.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck = 1

原来的源配置文件,可以直接不要了。在/etc/yum.reop.d/创建新的Mariadb源文件。

接下来,就是更新一下Mariadb。

更新Maraidb

操作如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
yum makecache
yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-server.x86_64 0:10.9.8-1.el7.centos will be updated
---> Package MariaDB-server.x86_64 0:10.11.8-1.el7.centos will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===================================================================================================================================================================================================================
Package Arch Version Repository Size
===================================================================================================================================================================================================================
Updating:
MariaDB-server x86_64 10.11.8-1.el7.centos mariadb 27 M

Transaction Summary
===================================================================================================================================================================================================================
Upgrade 1 Package

Total download size: 27 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for mariadb
MariaDB-server-10.11.8-1.el7.centos.x86_64.rpm | 27 MB 00:00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction

******************************************************************
A MySQL or MariaDB server package (MariaDB-server-10.9.8-1.el7.centos.x86_64) is installed.

Upgrading directly from MySQL 10.9 to MariaDB 10.11 may not
be safe in all cases. A manual dump and restore using mysqldump is
recommended. It is important to review the MariaDB manual's Upgrading
section for version-specific incompatibilities.

A manual upgrade is required.

- Ensure that you have a complete, working backup of your data and my.cnf
files
- Shut down the MySQL server cleanly
- Remove the existing MySQL packages. Usually this command will
list the packages you should remove:
rpm -qa | grep -i '^mysql-'

You may choose to use 'rpm --nodeps -ev <package-name>' to remove
the package which contains the mysqlclient shared library. The
library will be reinstalled by the MariaDB-shared package.
- Install the new MariaDB packages supplied by MariaDB Foundation
- Ensure that the MariaDB server is started
- Run the 'mysql_upgrade' program

This is a brief description of the upgrade process. Important details
can be found in the MariaDB manual, in the Upgrading section.
******************************************************************
error: %pre(MariaDB-server-10.11.8-1.el7.centos.x86_64) scriptlet failed, exit status 1
Error in PREIN scriptlet in rpm package MariaDB-server-10.11.8-1.el7.centos.x86_64
Verifying : MariaDB-server-10.11.8-1.el7.centos.x86_64 1/2
MariaDB-server-10.9.8-1.el7.centos.x86_64 was supposed to be removed but is not!
Verifying : MariaDB-server-10.9.8-1.el7.centos.x86_64 2/2

Failed:
MariaDB-server.x86_64 0:10.9.8-1.el7.centos MariaDB-server.x86_64 0:10.11.8-1.el7.centos

Complete!

结果,原来的安装的11.9已经安装,不能直接升级。看提示还要先停用原来的Mariadb服务,删除原来的10.9的程序包,重新安装。所以,按提示来,先停服务,卸载原来安装的程序包,重新安装10.11版本。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
rpm -qa | grep -i "^mariadb"
MariaDB-common-10.9.8-1.el7.centos.x86_64
MariaDB-client-10.9.8-1.el7.centos.x86_64
MariaDB-server-10.9.8-1.el7.centos.x86_64
MariaDB-compat-10.9.8-1.el7.centos.x86_64
rpm --nodeps -ev MariaDB-server-10.9.8-1.el7.centos.x86_64
Preparing packages...
MariaDB-server-10.9.8-1.el7.centos.x86_64
warning: /etc/my.cnf.d/server.cnf saved as /etc/my.cnf.d/server.cnf.rpmsave

# 重新安装Mariadb server

yum install mariadb-common galera rsync -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
No package mariadb-common available.
* Maybe you meant: MariaDB-common
Package galera-25.3.12-2.el7.x86_64 is obsoleted by galera-4-26.4.18-1.el7.centos.x86_64 which is already installed
Package rsync-3.1.2-12.el7_9.x86_64 already installed and latest version
Nothing to do

yum install mariadb-server -y
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
Package mariadb-server is obsoleted by MariaDB-server, trying to install MariaDB-server-10.11.8-1.el7.centos.x86_64 instead
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-server.x86_64 0:10.11.8-1.el7.centos will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
MariaDB-server x86_64 10.11.8-1.el7.centos mariadb 27 M

Transaction Summary
================================================================================
Install 1 Package

Total download size: 27 M
Installed size: 141 M
Downloading packages:
MariaDB-server-10.11.8-1.el7.centos.x86_64.rpm | 27 MB 00:03
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : MariaDB-server-10.11.8-1.el7.centos.x86_64 1/1
Verifying : MariaDB-server-10.11.8-1.el7.centos.x86_64 1/1

Installed:
MariaDB-server.x86_64 0:10.11.8-1.el7.centos

Complete!

重新安装完成。在更新之前,因为三台数据库组了galera集群,重新安装过后,生成了新的my.cnf文件。所以还需要重新配置Mariadb的galera集群。galera配置见Mariadb集群配置。配置结束,启动Mariadb服务即可。

1
2
systemctl start mariadb 
systemctl status mariadb

查看更新结果

更新完成,查看包更新情况,查看galera集群状态。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
rpm -qa | grep -i "^mariadb"
MariaDB-compat-10.11.8-1.el7.centos.x86_64
MariaDB-common-10.11.8-1.el7.centos.x86_64
MariaDB-client-10.11.8-1.el7.centos.x86_64
MariaDB-server-10.11.8-1.el7.centos.x86_64

# 查看mariadb 集群状态

MariaDB [(none)]> show status like "wsrep_cluster_size";
+--------------------+-------+
| Variable_name | Value |
+--------------------+-------+
| wsrep_cluster_size | 3 |
+--------------------+-------+
1 row in set (0.002 sec)

好了,更新完成,集群同步正常。结束。


Mariadb版本升级
https://ywmy.xyz/2024/05/18/Mariadb版本升级/
作者
ian
发布于
2024年5月18日
许可协议