Nâng cấp MySQL 5.5 lên 5.6/5.7 hoặc MariaDB 5.5 lên 10.0/10.1/10.2 trên Plesk Centos 7v

Tác giả: 26/06/2022

Theo mặc định, CentOS 7 được phân phối với MariaDB 5.5. Phiên bản MariaDB 10.x là phiên bản thay thế cho MySQL 5.5-5.7.

  • Để an toàn, backup lại toàn bộ databases với lệnh sau:
    <span style="font-family: 'times new roman', times, serif; font-size: 14pt;">MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysqldump -u admin --all-databases --routines --triggers > /tmp/all-databases.sql</span>
  • Stop MariaDB:
    <span style="font-family: 'times new roman', times, serif; font-size: 14pt;">service mariadb stop</span>
  • Xóa packages mariadb-bench:
    <span style="font-family: 'times new roman', times, serif; font-size: 14pt;">rpm -e --nodeps mariadb-bench</span>
  • Để đảm bảo an toàn, hãy copy thư mục database qua 1 thư mục khác:
    <span style="font-family: 'times new roman', times, serif; font-size: 14pt;">cp -v -a /var/lib/mysql/ /var/lib/mysql_backup</span>
  • Kiểm tra package mysql-server is đã được cài đặt:
    <span style="font-family: 'times new roman', times, serif; font-size: 14pt;">rpm -q --whatprovides mysql-server</span>
  • Nếu nó đã được cài đặt và lệnh trên đưa ra kết quả, hãy xóa bằng lệnh sau:

<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">rpm -e --nodeps `rpm -q --whatprovides mysql-server`</span>

 

1. Cấu hình MariaDB Repo  /etc/yum.repos.d/MariaDB.repo:

Ví dụ nâng cấp MariaDB 10.2:

1.1. Tạo file MariaDB.repo:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">nano /etc/yum.repos.d/MariaDB.repo</span>

1.2. Thêm nội dung như ben dưới vào file:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">[mariadb]</span>
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">name = MariaDB</span>
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">baseurl = <a class="external-link" href="http://yum.mariadb.org/10.2/centos7-amd64" rel="nofollow">http://yum.mariadb.org/10.2/centos7-amd64</a></span>
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">gpgkey=<a class="external-link" href="https://yum.mariadb.org/RPM-GPG-KEY-MariaDB" rel="nofollow">https://yum.mariadb.org/RPM-GPG-KEY-MariaDB</a></span>
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">gpgcheck=1</span>

1.3. Lưu file lại.

2. Nâng cấp MariaDB:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">yum install MariaDB-client MariaDB-server</span>

Sau khi nâng cấp xong, start MariaDB:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">service mariadb start</span>

Hoặc

<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">service mysql start</span>

Upgrade MySQL databases:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">MYSQL_PWD=`cat /etc/psa/.psa.shadow` mysql_upgrade -uadmin</span>

Restart mysql service:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">service mariadb restart</span>

Hoặc
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">service mysql restart</span>

3. Thực hiện lệnh bên dưới để update package version trong Plesk:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">plesk sbin packagemng -sdf</span>

Note: After an upgrade, there may appear ‘mysql’ init script. It should be removed to avoid conflicts with MariaDB service. The same commands can be used to fix already existing conflict:
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">systemctl stop mysql; killall mysqld</span>
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">rm /etc/init.d/mysql && systemctl daemon-reload</span>
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">systemctl start mariadb</span>
<span style="font-family: 'times new roman', times, serif; font-size: 14pt;">systemctl enable mariadb</span>

Để lại một bình luận