2014年3月11日火曜日

CnetOS 6.5 にMariaDB 10.0.8 をyum で導入 して HandlerSocket を有効にする

MariaDBをインストールして、MySQLデータベースへのアクセスを高速化するためのプラグイン「HandlerSocket」を導入します。 GPGキーを導入
[user@localhost ~]$ rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
mariaDBリポジトリを設定
[user@localhost ~]$ vi /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.0.1/centos6-x86
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
enabled=1
yumでインストール
[user@localhost ~]$ yum install MariaDB-devel MariaDB-client MariaDB-server
MariaDBの起動
[user@localhost ~]$ service mysql start
Starting MySQL. SUCCESS!
自動起動設定
[user@localhost ~]$ chkconfig mysql on
[user@localhost ~]$ chkconfig --list mysql
mysql           0:off   1:off   2:on    3:on    4:on    5:on    6:off
初期設定
[user@localhost ~]$ mysql_secure_installation




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):  #← 空ENTER
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]  #← 空ENTER(rootパスワード設定)
New password:  #← rootパスワード応答
Re-enter new password:  #← rootパスワード応答(確認)
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]  #← 空ENTER(匿名ユーザー削除)
 ... 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]  #← 空ENTER(リモートからのrootログイン禁止。必要なら n を選択)
 ... 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]  #← 空ENTER(testデータベース削除)
 - 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]  #← 空ENTER
 ... 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!
HandlerSocketとは?
簡単に言うと、MySQLデータベースへのアクセスを高速化するためのプラグインです。MySQLのSQLパーザをすっ飛ばし、ネットワーク通信とマルチスレッド処理周辺を置き換えることによって、InnoDB等のデータベースエンジンの性能を限界まで引き出します。 このHandlerSocketですが、すでにモバゲータウンにて実際に運用しています。 従来MySQLとmemcachedの構成で運用していた箇所を、HanderSocketを組み込んだMySQLだけの構成に置き換えました。 その結果、MySQLサーバの負荷軽減、memcachedの負荷軽減、ネットワークトラフィック減少の効果がありました。 また、単純にHandlerSocketに置き換えたことだけによる効果というわけではないのですが、アプリケーションのCPU負荷も大幅に減少しています。
 via http://engineer.dena.jp/2010/08/handlersocket-plugin-for-mysql.html

MariaDBは、デフォルトでHandlerSocketプラグインが梱包されています。 コマンドでINSTALL PLUGIN 構文を打つか、設定ファイル.cnfに記述するだけでHandlerSocketを有効にすることができます。
MariaDB [(none)]> install plugin handlersocket SONAME 'handlersocket.so';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> 
confに読み込むように記載します。
[user@localhost ~]$ vi /etc/my.cnf.d/server.cnf
~
[mysqld]
plugin-load=handlersocket.so

0 件のコメント:

コメントを投稿