Zabbixをインストールしてみる・続き

やり直し編
参考:http://changineer.info/server/monitoring/monitoring_zabbix.html#Zabbix_WEB
# yum install mysql-server
これでMySQL5.1をインストール。
この作業を知った時に、CentOSではMySQL5.1が標準だということを初めて知る。
っていうかZabbix3.0の動作に必要なMySQLのバージョンは5.0.3ってなってるから、別にバージョンアップしなくても良くない?
…やめよう。
もし5.6をインストールするのであれば
# rpm -ihv http://ftp.jaist.ac.jp/pub/mysql/Downloads/MySQL-5.6/MySQL-shared-5.6.36-1.el6.x86_64.rpm
# yum remove mysql-libs

そしてmysqldを起動しにかかる。

service mysqld start
Initializing MySQL database: Installing MySQL system tables...
OK
Filling help tables...
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

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.

You can start the MySQL daemon with:
cd /usr ; /usr/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/mysql-test ; perl mysql-test-run.pl

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

[ OK ]
Starting mysqld: [ OK ]

mysqldが起動したら、まずMySQL文字コードの設定を行う。これをやらないと後々変なエラーが出る。というか出た(内容忘れたけど)
まずは現状の文字コードがどんな設定になっているか、MySQLにログインして確認する。この時MySQLにパスワードは設定されてないみたいなので、パスワード入力なしでログインできるはず。

mysql> show variables like "%char%";

                                                                                                                • +
Variable_name Value
                                                                                                                • +
character_set_client latin1
character_set_connection latin1
character_set_database latin1
character_set_filesystem binary
character_set_results latin1
character_set_server latin1
character_set_system utf8
character_sets_dir /usr/share/mysql/charsets/
                                                                                                                • +

8 rows in set (0.00 sec)

上記の「latin1」となっているものを、UTF-8に変える必要がある。
どうやるのかというと、以下の内容を/etc/my.cnfに追記する。

[mysqld]
character_set_server=utf8
init_connect="SET NAMES utf8"

…これだけでは足りなかった。

[mysql]
character_set_server=utf8

これも追記すると、全ての文字コードUTF-8になる。
※今回のMySQLのバージョンは5.1なので、character_set_serverではMySQLが受け付けてくれなかった。default_character_setにしたらうまくいった。
これができたら、以下の流れでZabbix用のデータベースとユーザを作成する。

mysql> create database zabbix;
Query OK, 1 row affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost ;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

ここまでできれば、MySQL側の準備はOKだと思いたい。
次はZabbixのインストールです。