AmazonLinuxにZabbix2.4をPostgreSQLを使ってインストール


最近は業務でAWSをよく使っており、AmazonLinuxを操作することが増えてきました。
Zabbixは業務で使う可能性が出てきたので、模索しながらインストール手順をまとめました。必要最低限レベルですが、なんとか自分で構築したZabbixにログインして管理画面を拝むことができました。
使ったAMIは amzn-ami-hvm-2015.03.0.x86_64-gp2 (ami-cbf90ecb) です。
AmazonLinuxを使う時は、RHELもしくはCentOSの6だと思って色々適用してみるとよさそうですね、ベースとしてCentOSを使っているということですし。

参考にさせていただいたページ


Zabbix以外の必要プログラムのインストール

システム系プログラムのアップデート

sudo yum update -y

Apacheのインストール

sudo yum install -y httpd24

PostgreSQLのインストール

sudo yum install -y postgresql93 postgresql93-server postgresql93-devel postgresql-93-libs

Zabbixのインストール

sudo rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm
sudo yum install -y zabbix-server-pgsql zabbix-web-pgsql zabbix-agent

Zabbix用データベースとしてのPostgreSQLの設定

sudo /etc/init.d/postgresql93 initdb
sudo /etc/init.d/postgresql93 start

postgresユーザでログインしてzabbixユーザを作り、パスワードを設定

sudo su postgres
psql
create user zabbix;
alter user zabbix with password 'yourPassword';
alter user postgres with password 'yourPassword';
\q

ec2-userに戻る

exit

PostgreSQLへのログイン方法の変更

sudo vim /var/lib/pgsql93/data/pg_hba.conf
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5

設定反映のために再起動

sudo /etc/init.d/postgresql93 restart

zabbix用データベースの作成

psql -U postgres
create database zabbix owner zabbix;
\q

Zabbix用データベースの中身の構築

sudo psql -U zabbix zabbix < /usr/share/doc/zabbix-server-pgsql-2.4.6/create/schema.sql
sudo psql -U zabbix zabbix < /usr/share/doc/zabbix-server-pgsql-2.4.6/create/images.sql
sudo psql -U zabbix zabbix < /usr/share/doc/zabbix-server-pgsql-2.4.6/create/data.sql

Zabbix自体の設定

Zabbixサーバの設定

sudo vim /etc/zabbix/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=yourPassword

管理画面ディレクトリの設定

sudo chmod -R 755 /usr/share/zabbix
sudo vim /etc/httpd/conf.d/zabbix.conf
#
# Zabbix monitoring system php web frontend
#

Alias /zabbix /usr/share/zabbix


    Options FollowSymLinks
    AllowOverride None
#    Order allow,deny
#    Allow from all
    Require all granted

    php_value max_execution_time 300
    php_value memory_limit 128M
    php_value post_max_size 16M
    php_value upload_max_filesize 2M
    php_value max_input_time 300
    # php_value date.timezone Europe/Riga



#    Order deny,allow
#    Deny from all
    Require all granted
    
        Order deny,allow
        Deny from all
    



#    Order deny,allow
#    Deny from all
    Require all granted
    
        Order deny,allow
        Deny from all
    



#    Order deny,allow
#    Deny from all
    Require all granted
    
        Order deny,allow
        Deny from all
    



#    Order deny,allow
#    Deny from all
    Require all granted
    
        Order deny,allow
        Deny from all
    

phpのタイムゾーンの設定(行わないとWeb画面でのインストール作業が進められない)

sudo vim /etc/php.ini
### 追記
date.timezone = Asia/Tokyo

### 有効化
always_populate_raw_post_data = -1

Zabbixの起動

sudo /etc/init.d/zabbix-server start
sudo /etc/init.d/zabbix-agent start
sudo /etc/init.d/httpd start

自動起動の有効化

sudo chkconfig zabbix-server on
sudo chkconfig zabbix-agent on
sudo chkconfig httpd on
sudo chkconfig postgresql93 on

自動起動の確認

[ec2-user@ip-10-0-3-197 ~]$ sudo chkconfig --list zabbix-server
zabbix-server   0:off   1:off   2:on    3:on    4:on    5:on    6:off
[ec2-user@ip-10-0-3-197 ~]$ sudo chkconfig --list zabbix-agent
zabbix-agent    0:off   1:off   2:on    3:on    4:on    5:on    6:off
[ec2-user@ip-10-0-3-197 ~]$ sudo chkconfig --list httpd
httpd           0:off   1:off   2:on    3:on    4:on    5:on    6:off
[ec2-user@ip-10-0-3-197 ~]$ sudo chkconfig --list postgresql
サービス postgresql に関する情報の読み込み中にエラーが発生しました: そのようなファイルやディレクトリはありません
[ec2-user@ip-10-0-3-197 ~]$ sudo chkconfig --list postgresql93
postgresql93    0:off   1:off   2:on    3:on    4:on    5:on    6:off

Zabbixサーバの起動確認

http://インストールしたサーバのIPアドレス/zabbix/ へアクセス
「2. Check of pre-requisites」の画面で確認項目が全てOKであればOK。


世の中に出ている情報はMySQLをデータベースとして利用しているものが多くて、欲しい情報になかなかたどり着けずに苦戦しました。
参考にさせていただいた記事は本当に助かりました。ありがとうございました。



コメント

このブログの人気の投稿

オライリーのDocker本を読んだり色々な記事を読んだりしたので自分なりにまとめる(Dockerfileについて)

一部のユーザだけ NET::ERR_CERT_REVOKED でサイトにアクセスできない

[#CentOS][#Apache] CentOS6 でApacheが起動できない