PR

CentOS7にPercona Server for MySQL 8.0をインストールする手順

スポンサーリンク
Linux

Percona ServerとはPercona社が開発したMySQLに様々な機能を追加し、パフォーマンスを向上させた無償のオープンソースデータベースです。

MySQLと互換性があり、使い勝手に違いは特にありません。

MySQLのEnterpriseエディション(有償)でしか使えない機能などが使えるため、私はMySQLよりもPercona Serverを利用しています。

今回はPercona Server for MySQL 8.0をCentOS7にインストールしてみたいと思います。

今回使用するOS

今回、CentOS7にインストールしてみます。

[root@cent76 ~]# cat /etc/centos-release
CentOS Linux release 7.6.1810 (Core)

Percona Serverのリポジトリをインストールする

[root@cent76 ~]# yum install -y https://repo.percona.com/yum/percona-release-latest.noarch.rpm
Loaded plugins: fastestmirror, langpacks
percona-release-latest.noarch.rpm                                                                |  17 kB  00:00:00
Examining /var/tmp/yum-root-_Pw6lG/percona-release-latest.noarch.rpm: percona-release-1.0-13.noarch
Marking /var/tmp/yum-root-_Pw6lG/percona-release-latest.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package percona-release.noarch 0:1.0-13 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                      Arch                Version             Repository                                   Size
========================================================================================================================
Installing:
 percona-release              noarch              1.0-13              /percona-release-latest.noarch               20 k

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

Total size: 20 k
Installed size: 20 k
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : percona-release-1.0-13.noarch                                                                        1/1
* Enabling the Percona Original repository
<*> All done!
The percona-release package now contains a percona-release script that can enable additional repositories for our newer products.

For example, to enable the Percona Server 8.0 repository use:

  percona-release setup ps80

Note: To avoid conflicts with older product versions, the percona-release setup command may disable our original repository for some products.

For more information, please visit:
  https://www.percona.com/doc/percona-repo-config/percona-release.html

  Verifying  : percona-release-1.0-13.noarch                                                                        1/1

Installed:
  percona-release.noarch 0:1.0-13

Complete!

Percona Server for MySQL 8.0 リポジトリを有効にする

これを実行しないとPercona Server for MySQL 5.7 までのリポジトリしか見れないので、実行します。

[root@cent76 ~]# percona-release setup ps80
* Disabling all Percona Repositories
* Enabling the Percona Server 8.0 repository
* Enabling the Percona Tools repository
<*> All done!

Percona Server for MySQL 8.0 をインストールする

[root@cent76 ~]# yum install -y percona-server-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: ty1.mirror.newmediaexpress.com
 * extras: ty1.mirror.newmediaexpress.com
 * updates: ty1.mirror.newmediaexpress.com
Resolving Dependencies
--> Running transaction check
---> Package percona-server-server.x86_64 0:8.0.18-9.1.el7 will be installed
--> Processing Dependency: percona-server-shared for package: percona-server-server-8.0.18-9.1.el7.x86_64
--> Processing Dependency: percona-server-client for package: percona-server-server-8.0.18-9.1.el7.x86_64
--> Running transaction check
---> Package percona-server-client.x86_64 0:8.0.18-9.1.el7 will be installed
---> Package percona-server-shared.x86_64 0:8.0.18-9.1.el7 will be installed
--> Processing Dependency: percona-server-shared-compat for package: percona-server-shared-8.0.18-9.1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
---> Package percona-server-shared-compat.x86_64 0:8.0.18-9.1.el7 will be obsoleting
--> Finished Dependency Resolution

Dependencies Resolved

========================================================================================================================
 Package                                Arch             Version                   Repository                      Size
========================================================================================================================
Installing:
 percona-server-server                  x86_64           8.0.18-9.1.el7            ps-80-release-x86_64            53 M
 percona-server-shared-compat           x86_64           8.0.18-9.1.el7            ps-80-release-x86_64           1.2 M
     replacing  mariadb-libs.x86_64 1:5.5.60-1.el7_5
Installing for dependencies:
 percona-server-client                  x86_64           8.0.18-9.1.el7            ps-80-release-x86_64            12 M
 percona-server-shared                  x86_64           8.0.18-9.1.el7            ps-80-release-x86_64           1.3 M

Transaction Summary
========================================================================================================================
Install  2 Packages (+2 Dependent packages)

Total download size: 68 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/ps-80-release-x86_64/packages/percona-server-client-8.0.18-9.1.el7.x86_64.rpm: Header V4 RSA/SHA256 Signature, key ID 8507efa5: NOKEY
Public key for percona-server-client-8.0.18-9.1.el7.x86_64.rpm is not installed
(1/4): percona-server-client-8.0.18-9.1.el7.x86_64.rpm                                           |  12 MB  00:00:43
(2/4): percona-server-shared-8.0.18-9.1.el7.x86_64.rpm                                           | 1.3 MB  00:00:03
(3/4): percona-server-shared-compat-8.0.18-9.1.el7.x86_64.rpm                                    | 1.2 MB  00:00:04
(4/4): percona-server-server-8.0.18-9.1.el7.x86_64.rpm                                           |  53 MB  00:02:48
------------------------------------------------------------------------------------------------------------------------
Total                                                                                   411 kB/s |  68 MB  00:02:48
Retrieving key from file:///etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY
Importing GPG key 0x8507EFA5:
 Userid     : "Percona MySQL Development Team (Packaging key) <mysql-dev@percona.com>"
 Fingerprint: 4d1b b29d 63d9 8e42 2b21 13b1 9334 a25f 8507 efa5
 Package    : percona-release-1.0-13.noarch (installed)
 From       : /etc/pki/rpm-gpg/PERCONA-PACKAGING-KEY
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : percona-server-shared-compat-8.0.18-9.1.el7.x86_64                                                   1/5
  Installing : percona-server-shared-8.0.18-9.1.el7.x86_64                                                          2/5
  Installing : percona-server-client-8.0.18-9.1.el7.x86_64                                                          3/5
  Installing : percona-server-server-8.0.18-9.1.el7.x86_64                                                          4/5
Percona Server is distributed with several useful UDF (User Defined Function) from Percona Toolkit.
Run the following commands to create these functions:
mysql -e "CREATE FUNCTION fnv1a_64 RETURNS INTEGER SONAME 'libfnv1a_udf.so'"
mysql -e "CREATE FUNCTION fnv_64 RETURNS INTEGER SONAME 'libfnv_udf.so'"
mysql -e "CREATE FUNCTION murmur_hash RETURNS INTEGER SONAME 'libmurmur_udf.so'"
See http://www.percona.com/doc/percona-server/8.0/management/udf_percona_toolkit.html for more details
  Erasing    : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                 5/5
  Verifying  : percona-server-client-8.0.18-9.1.el7.x86_64                                                          1/5
  Verifying  : percona-server-shared-compat-8.0.18-9.1.el7.x86_64                                                   2/5
  Verifying  : percona-server-server-8.0.18-9.1.el7.x86_64                                                          3/5
  Verifying  : percona-server-shared-8.0.18-9.1.el7.x86_64                                                          4/5
  Verifying  : 1:mariadb-libs-5.5.60-1.el7_5.x86_64                                                                 5/5

Installed:
  percona-server-server.x86_64 0:8.0.18-9.1.el7           percona-server-shared-compat.x86_64 0:8.0.18-9.1.el7

Dependency Installed:
  percona-server-client.x86_64 0:8.0.18-9.1.el7              percona-server-shared.x86_64 0:8.0.18-9.1.el7

Replaced:
  mariadb-libs.x86_64 1:5.5.60-1.el7_5

Complete!

※インターネットに繋がらないサーバの場合は、以下Percona Serverの公式ページにrpmがありますので個別にダウンロードし、サーバにアップロードしてインストールしてください。

Percona Server for MySQL
Percona Server for MySQL is a free, fully compatible, open source MySQL Server alternative that offers breakthrough perf...

Percona Serverの起動

[root@cent76 ~]# systemctl start mysqld.service

MySQLのrootユーザの初期パスワードを確認

以下の赤文字のものが初期パスワードです。mysqld.logから探します。

[root@cent76 ~]# grep 'temporary password' /var/log/mysqld.log
2020-01-07T23:53:11.918424Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: 7myE0You7K+h

rootユーザで接続

[root@cent76 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.18-9

Copyright (c) 2009-2019 Percona LLC and/or its affiliates
Copyright (c) 2000, 2019, 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ユーザの初期パスワードを変更

初期パスワードを変更しないとSQLが何も実行できないので、パスワードを変更します。


mysql> ALTER USER 'root'@'localhost' identified BY 'hoge4you#T';
Query OK, 0 rows affected (0.32 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)