CentOS 6.3にZabbix 1.8を入れてみた(その2.設定編)

 その1の続きです。設定編になります。
 
 同じく、Zabbixサイトと、寺島広大『Zabbix統合監視「実践」入門 ~障害通知、傾向分析、可視化による省力運用 (Software Design plusシリーズ)』を参照しています。


◇MySQLの設定。いきなりviコマンド使うの嫌なので、lessで開いてv押して編集モードにする。
 
[root@localhost ~]# less /etc/my.cnf
 
◇太字のところを追加。innodbのところはZabbixサイトにはなかったけど『Zabbix統合監視「実践」入門』にはあったので追加。
 
--------------------------------------------------
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
 
default-character-set=utf8
skip-character-set-client-handshake
 
innodb_file_per_table
innodb_buffer_pool_size=64M
innodb_log_file_size=16M
innodb_log_files_in_group=2

[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
--------------------------------------------------
 
◇MySQLサービススタート。メッセージが出ているように、MySQL5.5とかだとdefault-character-setは使わないらしい。まあいまいまはよしとする。
 
[root@localhost ~]# service mysqld start
Initializing MySQL database: Installing MySQL system tables…
120811 14:52:35 [Warning] ‘–default-character-set’ is deprecated and will be removed in a future release. Please use ‘–character-set-server’ instead.
OK
Filling help tables…
120811 14:52:36 [Warning] ‘–default-character-set’ is deprecated and will be removed in a future release. Please use ‘–character-set-server’ instead.
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 ]
 
◇MySQLデータベースにログインしてユーザ設定。『Zabbix統合監視「実践」入門』の手順とした。Zabbixサイトの手順でも問題ないはず。
 
[root@localhost ~]# mysql -uroot
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.61 Source distribution
 
Copyright (c) 2000, 2011, 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> create database zabbix;
Query OK, 1 row affected (0.00 sec)
 
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by ‘ぱすわーど’;
Query OK, 0 rows affected (0.01 sec)
 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
 
mysql> exit
Bye
 
◇OS起動時にMySQLも起動するように設定
 
[root@localhost ~]# chkconfig mysqld on
 
◇データベースへの初期データインポート。『Zabbix統合監視「実践」入門』の手順とした。
 
[root@localhost ~]# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-1.8.14/schema/mysql.sql
Enter password:
[root@localhost ~]# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-1.8.14/data/data.sql
Enter password:
[root@localhost ~]# mysql -uzabbix -p zabbix < /usr/share/doc/zabbix-server-1.8.14/data/images_mysql.sql
Enter password:
 
◇/etc/zabbix/zabbix_server.confの以下のところを以下のように修正
 
### Option: DBName
# Database name.
# For SQLite3 path to database file must be provided. DBUser and DBPasswor
d are ignored.
#
# Mandatory: yes
# Default:
# DBName=
 
DBName=zabbix
 
### Option: DBSchema
# Schema name. Used for IBM DB2.
#
# Mandatory: no
# Default:
# DBSchema=
 
### Option: DBUser
# Database user. Ignored for SQLite.
#
# Mandatory: no
# Default:
# DBUser=
 
DBUser=zabbix
 
### Option: DBPassword
# Database password. Ignored for SQLite.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
 
DBPassword=ぱすわーど(ほんとは半角でパスワード入れる)
 
### Option: DBSocket
# Path to MySQL socket.
#
# Mandatory: no
# Default:
# DBSocket=/tmp/mysql.sock
 
DBSocket=/var/lib/mysql/mysql.sock
 
◇Zabbix起動!
 
[root@localhost ~]# service zabbix-server start
Starting zabbix server: [ OK ]
[root@localhost ~]# service zabbix-server status
zabbix_server (pid 4624 4622 4620 4618 4616 4614 4612 4611 4609 4607 4605 4603 4601 4599 4597 4594 4592 4591 4590 4589 4588 4587 4586 4584 4582 4581 4579) is running…
 
◇Apache起動。
 
[root@localhost ~]# service httpd start
Starting httpd: [ OK ]
 
◇zabbix.conf.phpの削除。『Zabbix統合監視「実践」入門』にある手順。
 
[root@localhost ~]# cd /etc/zabbix/
[root@localhost zabbix]# ls
alertscripts maintenance.inc.php zabbix_agentd.conf zabbix.conf.php
externalscripts zabbix_agent.conf zabbix_agentd.d zabbix_server.conf
[root@localhost zabbix]# rm zabbix.conf.php
rm: remove regular empty file `zabbix.conf.php’?
 
◇Firefoxでhttp://localhost/zabbixにアクセスして設定する。
 

 
◇PHPの確認。パフォーマンス的に問題ありそうだが、検証環境なのでまあよしとする。
 

 
◇コネクション確認。
 

 
◇設定ファイルの書き込みのところはFailになる。
 

 
◇Firefoxで設定ファイルをダウンロードして(ボタン押すとダウンロードできる)、ファイルの権限を変えたりしてcpで置き換える。『Zabbix統合監視「実践」入門』に書いてある。
 
[root@localhost zabbix]# ls -alF
total 56
drwxr-xr-x. 5 root root 4096 Aug 11 15:19 ./
drwxr-xr-x. 128 root root 12288 Aug 11 14:49 ../
drwxr-xr-x. 2 root root 4096 Jul 19 01:36 alertscripts/
drwxr-xr-x. 2 root root 4096 Jul 19 01:36 externalscripts/
-rw-r–r–. 1 root root 1025 Jun 28 06:01 maintenance.inc.php
-rw-r–r–. 1 root root 2151 Jun 28 06:00 zabbix_agent.conf
-rw-r–r–. 1 root root 6221 Jun 22 03:54 zabbix_agentd.conf
drwxr-xr-x. 2 root root 4096 Aug 11 14:33 zabbix_agentd.d/
-rw-----–. 1 apache apache 0 Jul 19 01:36 zabbix.conf.php
-rw-----–. 1 zabbix zabbix 9198 Aug 11 15:19 zabbix_server.conf
 
[root@localhost zabbix]# chown root.root zabbix.conf.php
[root@localhost zabbix]# cp /home/ユーザ名/Downloads/zabbix.conf.php ./zabbix.conf.php
cp: overwrite `./zabbix.conf.php’? yes
[root@localhost zabbix]# chmod 644 zabbix.conf.php
[root@localhost zabbix]# ls -alF
total 60
drwxr-xr-x. 5 root root 4096 Aug 11 15:19 ./
drwxr-xr-x. 128 root root 12288 Aug 11 14:49 ../
drwxr-xr-x. 2 root root 4096 Jul 19 01:36 alertscripts/
drwxr-xr-x. 2 root root 4096 Jul 19 01:36 externalscripts/
-rw-r–r–. 1 root root 1025 Jun 28 06:01 maintenance.inc.php
-rw-r–r–. 1 root root 2151 Jun 28 06:00 zabbix_agent.conf
-rw-r–r–. 1 root root 6221 Jun 22 03:54 zabbix_agentd.conf
drwxr-xr-x. 2 root root 4096 Aug 11 14:33 zabbix_agentd.d/
-rw-r–r–. 1 root root 426 Aug 11 15:37 zabbix.conf.php
-rw-----–. 1 zabbix zabbix 9198 Aug 11 15:19 zabbix_server.conf
 
◇再確認する。ボタン押してリトライ。OKになったら完了!
 

 
◇自動起動設定しておく。
 
[root@localhost zabbix]# chkconfig httpd on
[root@localhost zabbix]# chkconfig zabbix-server on
 
◇これでhttp://localhost/zabbixに行って、デフォルトユーザとパスワード(Admin/zabbix)で入ればOK!
 
いえい。

Leave a Reply

Your email address will not be published. Required fields are marked *