CentOS6.7にPerconaServerをインストールする


## はじめに

CentOS6.7にPerconaServerをインストールする手順を記述します。

## 環境

* CentOS 6.7
* PerconaServer 5.6

## リポジトリの設定

```shell
$ sudo yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm

読み込んだプラグイン:fastestmirror, security
インストール処理の設定をしています
percona-release-0.1-3.noarch.rpm                                                                                                      | 6.4 kB     00:00
/var/tmp/yum-root-Vg3Iw0/percona-release-0.1-3.noarch.rpm を調べています: percona-release-0.1-3.noarch
/var/tmp/yum-root-Vg3Iw0/percona-release-0.1-3.noarch.rpm をインストール済みとして設定しています
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
base                                                                                                                                  | 3.7 kB     00:00
extras                                                                                                                                | 3.4 kB     00:00
updates                                                                                                                               | 3.4 kB     00:00
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package percona-release.noarch 0:0.1-3 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

=============================================================================================================================================================
 パッケージ                            アーキテクチャ               バージョン                     リポジトリー                                         容量
=============================================================================================================================================================
インストールしています:
 percona-release                       noarch                       0.1-3                          /percona-release-0.1-3.noarch                       5.8 k

トランザクションの要約
=============================================================================================================================================================
インストール         1 パッケージ

合計容量: 5.8 k
インストール済み容量: 5.8 k
これでいいですか? [y/N]y
パッケージをダウンロードしています:
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : percona-release-0.1-3.noarch                                                                                                 1/1
  Verifying               : percona-release-0.1-3.noarch                                                                                                 1/1

インストール:
  percona-release.noarch 0:0.1-3

完了しました!
```

## PerconaServerのインストール

```shell
$ sudo yum install Percona-Server-server-56.x86_64
読み込んだプラグイン:fastestmirror, security
インストール処理の設定をしています
Loading mirror speeds from cached hostfile
 * base: www.ftp.ne.jp
 * extras: www.ftp.ne.jp
 * updates: www.ftp.ne.jp
percona-release-noarch                                                                                                                |  951 B     00:00
percona-release-noarch/primary                                                                                                        | 4.9 kB     00:00
percona-release-noarch                                                                                                                                 32/32
percona-release-x86_64                                                                                                                |  951 B     00:00
percona-release-x86_64/primary                                                                                                        | 175 kB     00:01
percona-release-x86_64                                                                                                                               594/594
依存性の解決をしています
--> トランザクションの確認を実行しています。
---> Package Percona-Server-server-56.x86_64 0:5.6.26-rel74.0.el6 will be インストール
--> 依存性の処理をしています: Percona-Server-client-56 のパッケージ: Percona-Server-server-56-5.6.26-rel74.0.el6.x86_64
--> 依存性の処理をしています: Percona-Server-shared-56 のパッケージ: Percona-Server-server-56-5.6.26-rel74.0.el6.x86_64
--> トランザクションの確認を実行しています。
---> Package Percona-Server-client-56.x86_64 0:5.6.26-rel74.0.el6 will be インストール
---> Package Percona-Server-shared-56.x86_64 0:5.6.26-rel74.0.el6 will be インストール
--> 依存性解決を終了しました。

依存性を解決しました

=============================================================================================================================================================
 パッケージ                                  アーキテクチャ            バージョン                            リポジトリー                               容量
=============================================================================================================================================================
インストールしています:
 Percona-Server-server-56                    x86_64                    5.6.26-rel74.0.el6                    percona-release-x86_64                     20 M
依存性関連でのインストールをします。:
 Percona-Server-client-56                    x86_64                    5.6.26-rel74.0.el6                    percona-release-x86_64                    6.4 M
 Percona-Server-shared-56                    x86_64                    5.6.26-rel74.0.el6                    percona-release-x86_64                    725 k

トランザクションの要約
=============================================================================================================================================================
インストール         3 パッケージ

総ダウンロード容量: 27 M
インストール済み容量: 123 M
これでいいですか? [y/N]y
パッケージをダウンロードしています:
(1/3): Percona-Server-client-56-5.6.26-rel74.0.el6.x86_64.rpm                                                                         | 6.4 MB     00:15
(2/3): Percona-Server-server-56-5.6.26-rel74.0.el6.x86_64.rpm                                                                         |  20 MB     00:38
(3/3): Percona-Server-shared-56-5.6.26-rel74.0.el6.x86_64.rpm                                                                         | 725 kB     00:01
-------------------------------------------------------------------------------------------------------------------------------------------------------------
合計                                                                                                                         488 kB/s |  27 MB     00:55
警告: rpmts_HdrFromFdno: ヘッダ V4 DSA/SHA1 Signature, key ID cd2efd2a: NOKEY
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-Percona
Importing GPG key 0xCD2EFD2A:
 Userid : Percona MySQL Development Team <mysql-dev@percona.com>
 Package: percona-release-0.1-3.noarch (@/percona-release-0.1-3.noarch)
 From   : /etc/pki/rpm-gpg/RPM-GPG-KEY-Percona
これでいいですか? [y/N]y
rpm_check_debug を実行しています
トランザクションのテストを実行しています
トランザクションのテストを成功しました
トランザクションを実行しています
  インストールしています  : Percona-Server-shared-56-5.6.26-rel74.0.el6.x86_64                                                                           1/3
  インストールしています  : Percona-Server-client-56-5.6.26-rel74.0.el6.x86_64                                                                           2/3
  インストールしています  : Percona-Server-server-56-5.6.26-rel74.0.el6.x86_64                                                                           3/3
2015-09-15 23:29:50 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-09-15 23:29:50 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26-74.0) starting as process 3024 ...
2015-09-15 23:29:50 3024 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-09-15 23:29:50 3024 [Note] InnoDB: The InnoDB memory heap is disabled
2015-09-15 23:29:50 3024 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-09-15 23:29:50 3024 [Note] InnoDB: Memory barrier is not used
2015-09-15 23:29:50 3024 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-09-15 23:29:50 3024 [Note] InnoDB: Using Linux native AIO
2015-09-15 23:29:50 3024 [Note] InnoDB: Not using CPU crc32 instructions
2015-09-15 23:29:50 3024 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-09-15 23:29:50 3024 [Note] InnoDB: Completed initialization of buffer pool
2015-09-15 23:29:50 3024 [Note] InnoDB: The first specified data file ./ibdata1 did not exist: a new database to be created!
2015-09-15 23:29:50 3024 [Note] InnoDB: Setting file ./ibdata1 size to 12 MB
2015-09-15 23:29:50 3024 [Note] InnoDB: Database physically writes the file full: wait...
2015-09-15 23:29:50 3024 [Note] InnoDB: Setting log file ./ib_logfile101 size to 48 MB
2015-09-15 23:29:51 3024 [Note] InnoDB: Setting log file ./ib_logfile1 size to 48 MB
2015-09-15 23:29:51 3024 [Note] InnoDB: Renaming log file ./ib_logfile101 to ./ib_logfile0
2015-09-15 23:29:51 3024 [Warning] InnoDB: New log files created, LSN=45781
2015-09-15 23:29:51 3024 [Note] InnoDB: Doublewrite buffer not found: creating new
2015-09-15 23:29:51 3024 [Note] InnoDB: Doublewrite buffer created
2015-09-15 23:29:51 3024 [Note] InnoDB: 128 rollback segment(s) are active.
2015-09-15 23:29:51 3024 [Warning] InnoDB: Creating foreign key constraint system tables.
2015-09-15 23:29:51 3024 [Note] InnoDB: Foreign key constraint system tables created
2015-09-15 23:29:51 3024 [Note] InnoDB: Creating tablespace and datafile system tables.
2015-09-15 23:29:51 3024 [Note] InnoDB: Tablespace and datafile system tables created.
2015-09-15 23:29:51 3024 [Note] InnoDB: Waiting for purge to start
2015-09-15 23:29:51 3024 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.26-74.0 started; log sequence number 0
2015-09-15 23:29:51 3024 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2015-09-15 23:29:51 3024 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2015-09-15 23:29:51 3024 [Note] Binlog end
2015-09-15 23:29:51 3024 [Note] InnoDB: FTS optimize thread exiting.
2015-09-15 23:29:51 3024 [Note] InnoDB: Starting shutdown...
2015-09-15 23:29:53 3024 [Note] InnoDB: Shutdown completed; log sequence number 1625977


2015-09-15 23:29:53 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use --explicit_defaults_for_timestamp server option (see documentation for more details).
2015-09-15 23:29:53 0 [Note] /usr/sbin/mysqld (mysqld 5.6.26-74.0) starting as process 3048 ...
2015-09-15 23:29:53 3048 [Note] InnoDB: Using atomics to ref count buffer pool pages
2015-09-15 23:29:53 3048 [Note] InnoDB: The InnoDB memory heap is disabled
2015-09-15 23:29:53 3048 [Note] InnoDB: Mutexes and rw_locks use GCC atomic builtins
2015-09-15 23:29:53 3048 [Note] InnoDB: Memory barrier is not used
2015-09-15 23:29:53 3048 [Note] InnoDB: Compressed tables use zlib 1.2.3
2015-09-15 23:29:53 3048 [Note] InnoDB: Using Linux native AIO
2015-09-15 23:29:53 3048 [Note] InnoDB: Not using CPU crc32 instructions
2015-09-15 23:29:53 3048 [Note] InnoDB: Initializing buffer pool, size = 128.0M
2015-09-15 23:29:53 3048 [Note] InnoDB: Completed initialization of buffer pool
2015-09-15 23:29:53 3048 [Note] InnoDB: Highest supported file format is Barracuda.
2015-09-15 23:29:53 3048 [Note] InnoDB: 128 rollback segment(s) are active.
2015-09-15 23:29:53 3048 [Note] InnoDB: Waiting for purge to start
2015-09-15 23:29:53 3048 [Note] InnoDB:  Percona XtraDB (http://www.percona.com) 5.6.26-74.0 started; log sequence number 1625977
2015-09-15 23:29:53 3048 [Note] RSA private key file not found: /var/lib/mysql//private_key.pem. Some authentication plugins will not work.
2015-09-15 23:29:53 3048 [Note] RSA public key file not found: /var/lib/mysql//public_key.pem. Some authentication plugins will not work.
2015-09-15 23:29:53 3048 [Note] Binlog end
2015-09-15 23:29:53 3048 [Note] InnoDB: FTS optimize thread exiting.
2015-09-15 23:29:53 3048 [Note] InnoDB: Starting shutdown...
2015-09-15 23:29:55 3048 [Note] InnoDB: Shutdown completed; log sequence number 1625987




PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

  /usr/bin/mysqladmin -u root password 'new-password'
  /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password'

Alternatively you can run:

  /usr/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

Please report any problems at
 https://bugs.launchpad.net/percona-server/+filebug

The latest information about Percona Server is available on the web at
  http://www.percona.com/software/percona-server

Support Percona by buying support at
 http://www.percona.com/products/mysql-support

WARNING: Default config file /etc/my.cnf exists on the system
This file will be read by default by the MySQL server
If you do not want to use this, either remove it, or use the
--defaults-file argument to mysqld_safe when starting the server

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/5.6/management/udf_percona_toolkit.html for more details
  Verifying               : Percona-Server-shared-56-5.6.26-rel74.0.el6.x86_64                                                                           1/3
  Verifying               : Percona-Server-server-56-5.6.26-rel74.0.el6.x86_64                                                                           2/3
  Verifying               : Percona-Server-client-56-5.6.26-rel74.0.el6.x86_64                                                                           3/3

インストール:
  Percona-Server-server-56.x86_64 0:5.6.26-rel74.0.el6

依存性関連をインストールしました:
  Percona-Server-client-56.x86_64 0:5.6.26-rel74.0.el6                          Percona-Server-shared-56.x86_64 0:5.6.26-rel74.0.el6

完了しました!

$ yum list installed | grep Percona
Percona-Server-client-56.x86_64
Percona-Server-server-56.x86_64
Percona-Server-shared-56.x86_64

```

## 起動及び初期設定

```shell
$ sudo service mysql start
Starting MySQL (Percona Server). SUCCESS!

$ mysql_secure_installation



NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MySQL to secure it, we'll need the current
password for the root user.  If you've just installed MySQL, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

Set root password? [Y/n] Y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] Y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] Y
 ... Success!

By default, MySQL comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] Y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] Y
 ... Success!




All done!  If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!


Cleaning up...
```

## データベース及びテーブル一覧

```shell
$ myql -u root -p

nter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 13
Server version: 5.6.26-74.0 Percona Server (GPL), Release 74.0, Revision 32f8dfd

Copyright (c) 2009-2015 Percona LLC and/or its affiliates
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              |
| performance_schema |
+--------------------+
3 rows in set (0.00 sec)

mysql> use information_schema;
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> show tables;
+---------------------------------------+
| Tables_in_information_schema          |
+---------------------------------------+
| CHARACTER_SETS                        |
| CLIENT_STATISTICS                     |
| COLLATIONS                            |
| COLLATION_CHARACTER_SET_APPLICABILITY |
| COLUMNS                               |
| COLUMN_PRIVILEGES                     |
| INDEX_STATISTICS                      |
| ENGINES                               |
| EVENTS                                |
| FILES                                 |
| GLOBAL_STATUS                         |
| GLOBAL_TEMPORARY_TABLES               |
| GLOBAL_VARIABLES                      |
| KEY_COLUMN_USAGE                      |
| OPTIMIZER_TRACE                       |
| PARAMETERS                            |
| PARTITIONS                            |
| PLUGINS                               |
| PROCESSLIST                           |
| PROFILING                             |
| REFERENTIAL_CONSTRAINTS               |
| ROUTINES                              |
| SCHEMATA                              |
| SCHEMA_PRIVILEGES                     |
| SESSION_STATUS                        |
| SESSION_VARIABLES                     |
| STATISTICS                            |
| TABLES                                |
| TABLESPACES                           |
| TABLE_CONSTRAINTS                     |
| TABLE_PRIVILEGES                      |
| TABLE_STATISTICS                      |
| TEMPORARY_TABLES                      |
| THREAD_STATISTICS                     |
| TRIGGERS                              |
| USER_PRIVILEGES                       |
| USER_STATISTICS                       |
| VIEWS                                 |
| INNODB_CMP                            |
| XTRADB_INTERNAL_HASH_TABLES           |
| INNODB_SYS_DATAFILES                  |
| XTRADB_RSEG                           |
| INNODB_SYS_TABLESTATS                 |
| INNODB_TRX                            |
| INNODB_FT_BEING_DELETED               |
| INNODB_CMP_RESET                      |
| INNODB_CMP_PER_INDEX                  |
| INNODB_LOCKS                          |
| INNODB_FT_DELETED                     |
| XTRADB_READ_VIEW                      |
| INNODB_LOCK_WAITS                     |
| INNODB_CMPMEM_RESET                   |
| INNODB_SYS_INDEXES                    |
| INNODB_SYS_TABLES                     |
| INNODB_SYS_FIELDS                     |
| INNODB_BUFFER_PAGE_LRU                |
| INNODB_CHANGED_PAGES                  |
| INNODB_FT_CONFIG                      |
| INNODB_FT_INDEX_TABLE                 |
| INNODB_CMP_PER_INDEX_RESET            |
| INNODB_SYS_TABLESPACES                |
| INNODB_FT_INDEX_CACHE                 |
| INNODB_SYS_FOREIGN_COLS               |
| INNODB_METRICS                        |
| INNODB_BUFFER_POOL_STATS              |
| INNODB_CMPMEM                         |
| INNODB_SYS_FOREIGN                    |
| INNODB_SYS_COLUMNS                    |
| INNODB_FT_DEFAULT_STOPWORD            |
| INNODB_BUFFER_PAGE                    |
+---------------------------------------+
70 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> show tables;
+---------------------------+
| Tables_in_mysql           |
+---------------------------+
| columns_priv              |
| db                        |
| event                     |
| func                      |
| general_log               |
| help_category             |
| help_keyword              |
| help_relation             |
| help_topic                |
| innodb_index_stats        |
| innodb_table_stats        |
| ndb_binlog_index          |
| plugin                    |
| proc                      |
| procs_priv                |
| proxies_priv              |
| servers                   |
| slave_master_info         |
| slave_relay_log_info      |
| slave_worker_info         |
| slow_log                  |
| tables_priv               |
| time_zone                 |
| time_zone_leap_second     |
| time_zone_name            |
| time_zone_transition      |
| time_zone_transition_type |
| user                      |
+---------------------------+
28 rows in set (0.00 sec)

mysql> use performance_schema;
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> show tables;
+----------------------------------------------------+
| Tables_in_performance_schema                       |
+----------------------------------------------------+
| accounts                                           |
| cond_instances                                     |
| events_stages_current                              |
| events_stages_history                              |
| events_stages_history_long                         |
| events_stages_summary_by_account_by_event_name     |
| events_stages_summary_by_host_by_event_name        |
| events_stages_summary_by_thread_by_event_name      |
| events_stages_summary_by_user_by_event_name        |
| events_stages_summary_global_by_event_name         |
| events_statements_current                          |
| events_statements_history                          |
| events_statements_history_long                     |
| events_statements_summary_by_account_by_event_name |
| events_statements_summary_by_digest                |
| events_statements_summary_by_host_by_event_name    |
| events_statements_summary_by_thread_by_event_name  |
| events_statements_summary_by_user_by_event_name    |
| events_statements_summary_global_by_event_name     |
| events_waits_current                               |
| events_waits_history                               |
| events_waits_history_long                          |
| events_waits_summary_by_account_by_event_name      |
| events_waits_summary_by_host_by_event_name         |
| events_waits_summary_by_instance                   |
| events_waits_summary_by_thread_by_event_name       |
| events_waits_summary_by_user_by_event_name         |
| events_waits_summary_global_by_event_name          |
| file_instances                                     |
| file_summary_by_event_name                         |
| file_summary_by_instance                           |
| host_cache                                         |
| hosts                                              |
| mutex_instances                                    |
| objects_summary_global_by_type                     |
| performance_timers                                 |
| rwlock_instances                                   |
| session_account_connect_attrs                      |
| session_connect_attrs                              |
| setup_actors                                       |
| setup_consumers                                    |
| setup_instruments                                  |
| setup_objects                                      |
| setup_timers                                       |
| socket_instances                                   |
| socket_summary_by_event_name                       |
| socket_summary_by_instance                         |
| table_io_waits_summary_by_index_usage              |
| table_io_waits_summary_by_table                    |
| table_lock_waits_summary_by_table                  |
| threads                                            |
| users                                              |
+----------------------------------------------------+
52 rows in set (0.00 sec)
```

## 参考

* [Installing Percona Server on Red Hat Enterprise Linux and CentOS] (https://www.percona.com/doc/percona-server/5.6/installation/yum_repo.html)