ServersMan@VPS CentOS6 MariaDBのInstall

更に続けてMariaDBのInstall

MySQLは使いたくないのでござる。

まずは、https://downloads.mariadb.org/mariadb/repositories/ から CentOS→CentOS6 64bit→5.5と選んで

repository情報を表示

http://mariadb.org/mariadb/repositories/

[mariadb] name = MariaDB baseurl = http://yum.mariadb.org/5.5/centos6-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1

これを/etc/yum.repos.d/mariadb.repoとして保存する。

編集内容↑のrepository情報 [xxxxx@dti-vps-srvXX ~]$ yum list MariaDB-server MariaDB-client Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile

  • base: ftp.iij.ad.jp
  • extras: ftp.iij.ad.jp
  • updates: ftp.iij.ad.jp Available Packages MariaDB-client.x86_64 5.5.30-1 mariadb MariaDB-server.x86_64 5.5.30-1 mariadb

こんな感じで確認できるので、後はyum install

Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile

  • base: ftp.iij.ad.jp
  • extras: ftp.iij.ad.jp
  • updates: ftp.iij.ad.jp base | 3.7 kB 00:00 extras | 3.5 kB 00:00 mariadb | 1.9 kB 00:00 mariadb/primary_db | 15 kB 00:00 nginx | 2.9 kB 00:00 updates | 3.5 kB 00:00 vz-base | 951 B 00:00 vz-updates | 951 B 00:00 Setting up Install Process Resolving Dependencies –> Running transaction check —> Package MariaDB-client.x86_64 0:5.5.30-1 will be installed –> Processing Dependency: MariaDB-common for package: MariaDB-client-5.5.30-1.x86_64 —> Package MariaDB-server.x86_64 0:5.5.30-1 will be installed –> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: MariaDB-server-5.5.30-1.x86_64 –> Processing Dependency: perl(DBI) for package: MariaDB-server-5.5.30-1.x86_64 –> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: MariaDB-server-5.5.30-1.x86_64 –> Processing Dependency: libaio.so.1()(64bit) for package: MariaDB-server-5.5.30-1.x86_64 –> Running transaction check —> Package MariaDB-common.x86_64 0:5.5.30-1 will be installed –> Processing Dependency: MariaDB-compat for package: MariaDB-common-5.5.30-1.x86_64 —> Package libaio.x86_64 0:0.3.107-10.el6 will be installed —> Package perl-DBI.x86_64 0:1.609-4.el6 will be installed –> Running transaction check —> Package MariaDB-compat.x86_64 0:5.5.30-1 will be installed –> Finished Dependency Resolution

Dependencies Resolved

================================================================================ Package Arch Version Repository Size

Installing: MariaDB-client x86_64 5.5.30-1 mariadb 10 M MariaDB-server x86_64 5.5.30-1 mariadb 33 M Installing for dependencies: MariaDB-common x86_64 5.5.30-1 mariadb 23 k MariaDB-compat x86_64 5.5.30-1 mariadb 2.7 M libaio x86_64 0.3.107-10.el6 base 21 k perl-DBI x86_64 1.609-4.el6 base 705 k

Transaction Summary

Install 6 Package(s)

Total download size: 46 M Installed size: 193 M Is this ok [y/N]: y Downloading Packages: (1/6): MariaDB-5.5.30-centos6-x86_64-client.rpm | 10 MB 00:17 (2/6): MariaDB-5.5.30-centos6-x86_64-common.rpm | 23 kB 00:00 (3/6): MariaDB-5.5.30-centos6-x86_64-compat.rpm | 2.7 MB 00:04 (4/6): MariaDB-5.5.30-centos6-x86_64-server.rpm | 33 MB 00:54 (5/6): libaio-0.3.107-10.el6.x86_64.rpm | 21 kB 00:00 (6/6): perl-DBI-1.609-4.el6.x86_64.rpm | 705 kB 00:00

Total 615 kB/s | 46 MB 01:17 warning: rpmts_HdrFromFdno: Header V3 DSA/SHA1 Signature, key ID 1bb943db: NOKEY Retrieving key from https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Importing GPG key 0x1BB943DB: Userid: “Daniel Bartholomew (Monty Program signing key) <dbart @askmonty.org>” From : https://yum.mariadb.org/RPM-GPG-KEY-MariaDB Is this ok [y/N]: y Running rpm_check_debug Running Transaction Test Transaction Test Succeeded Running Transaction Installing : MariaDB-compat-5.5.30-1.x86_64 1/6 Installing : MariaDB-common-5.5.30-1.x86_64 2/6 Installing : libaio-0.3.107-10.el6.x86_64 3/6 Installing : perl-DBI-1.609-4.el6.x86_64 4/6 Installing : MariaDB-server-5.5.30-1.x86_64 5/6 chown: cannot access `/var/lib/mysql’: No such file or directory

PLEASE REMEMBER TO SET A PASSWORD FOR THE MariaDB 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 dti-vps-srvXX 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 MariaDB Knowledgebase at http://kb.askmonty.org or the MySQL manual for more instructions.

Please report any problems with the ‘/usr/bin/mysqlbug’ script!

The latest information about MariaDB is available at http://mariadb.org/. You can find additional information about the MySQL part at: http://dev.mysql.com Support MariaDB development by buying support/new features from Monty Program Ab. You can contact us about this at sales@montyprogram.com. Alternatively consider joining our community based development effort: http://kb.askmonty.org/en/contributing-to-the-mariadb-project/

Installing : MariaDB-client-5.5.30-1.x86_64 6/6 Verifying : MariaDB-client-5.5.30-1.x86_64 1/6 Verifying : MariaDB-common-5.5.30-1.x86_64 2/6 Verifying : perl-DBI-1.609-4.el6.x86_64 3/6 Verifying : libaio-0.3.107-10.el6.x86_64 4/6 Verifying : MariaDB-server-5.5.30-1.x86_64 5/6 Verifying : MariaDB-compat-5.5.30-1.x86_64 6/6

Installed: MariaDB-client.x86_64 0:5.5.30-1 MariaDB-server.x86_64 0:5.5.30-1

Dependency Installed: MariaDB-common.x86_64 0:5.5.30-1 MariaDB-compat.x86_64 0:5.5.30-1 libaio.x86_64 0:0.3.107-10.el6 perl-DBI.x86_64 0:1.609-4.el6

Complete! [xxxxx@dti-vps-srvXX ~]$

</dbart>

つづいてhardening、、、。find_mysql_clientがcommand not foundだけど、無視していいので、無視する。

# mysql_secure_installationはsudoしなくて良い気がする。

Starting MySQL.. SUCCESS! [xxxxx@dti-vps-srvXX ~]$ sudo /usr/bin/mysql_secure_installation /usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found

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

In order to log into MariaDB to secure it, we’ll need the current password for the root user. If you’ve just installed MariaDB, 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 MariaDB 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 MariaDB installation has an anonymous user, allowing anyone to log into MariaDB 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, MariaDB 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!

Cleaning up…

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

Thanks for using MariaDB! [xxxxx@dti-vps-srvXX ~]$

chkconfigを確認

mysql 0:off 1:off 2:on 3:on 4:on 5:on 6:off

なお、Memory関連のチューニングパラメータはこんな感じ。

現時点で650MiBくらい消費しているので、後でちょっと調整しようかなと。

key_buffer_size 134217728 net_buffer_length 16384 read_buffer_size 131072 sort_buffer_size 2097152 table_open_cache 400 sort_buffer_size 2097152 read_rnd_buffer_size 262144 aria_pagecache_buffer_size 134217728 aria_sort_buffer_size 134217728

後はPHPとWordPressかな。

あ、忘れてた。文字コードをutf8に変更

編集内容[mysqld]セクションにcharacter_set_server = utf8を追記 [xxxxx@dti-vps-srvXX ~]$ sudo service mysql restart Shutting down MySQL. SUCCESS! Starting MySQL.. SUCCESS! [xxxxx@dti-vps-srvXX ~]$ mysql -u root -p -e ‘SHOW VARIABLES;’