• 追加された行はこの色です。
  • 削除された行はこの色です。
[[監視システム(NMS)]]
目次~
#contents
*CentOS7にZabbix3系をPHP7系と一緒に入れる [#f267ed1c]
**CentOS7 [#wcd6617f]

最小インストールで構築

**MariaDBをインストール [#q2bc17a4]

-/etc/yum.repos.d/MariaDB.repo
 # MariaDB 10.1 CentOS repository list
 # http://mariadb.org/mariadb/repositories/
 [mariadb]
 name = MariaDB
 baseurl = http://yum.mariadb.org/10.1/centos7-amd64
 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
 gpgcheck=1

-YUMで MariaDB 10.1をインストール
 yum install mariadb-server mariadb mariadb-devel mariadb-libs

-MariaDBを起動し、自動起動を有効にする
 systemctl start mariadb
 systemctl enable mariadb

-初期設定スクリプトを使い、rootユーザのパスワードを設定
 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
 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] ←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
  ... 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
  - 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!

**Apache,PHPをインストール [#r8646a20]

-YUMでApacheをインストール
 yum install httpd

-Apacheを起動し、自動起動を有効にする
 systemctl start httpd
 systemctl enable httpd
-PHP 7系をインストールするために必要なYUMのリポジトリ(EPEL,Remi)を追加
 yum install epel-release
 rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

-Remiリポジトリを指定し、PHP 7と必要なパッケージをインストール
 yum install --enablerepo=remi-php70 php php-mysqlnd php-ldap php-gd php-xml php-bcmath php-mbstring php-pecl-mysql

-php.iniにタイムゾーンを設定
 sed -i 's/\;date\.timezone\ \=/date\.timezone\ \=\ Asia\/Tokyo/g' /etc/php.ini
-php.ini にZabbix Serverの推奨値を設定
 sed -i "s/^post_max_size.*$/post\_max\_size\ \=\ 16M/g" /etc/php.ini
 sed -i "s/^max_execution_time.*$/max\_execution\_time\ \=\ 300/g" /etc/php.ini
 sed -i "s/^max_input_time.*$/max\_input\_time\ \=\ 300/g" /etc/php.ini

-Apacheを再起動
 systemctl restart httpd
**Zabbix serverをインストール [#sc51668a]
-Zabbix Serverのインストールに必要なYUMのリポジトリを追加
 rpm -Uvh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
-Zabbix Serverと必要なパッケージをインストール
 yum install --enablerepo=remi-php70 zabbix-server zabbix-server-mysql zabbix-web-mysql zabbix-web-japanese
-MariaDBにZabbix Server用のデータベースとユーザを作成。ユーザ名とパスワードは、ともに「zabbix」とする。
 mysql -p

 # mysql -p
 
 Enter password:
 Welcome to the MariaDB monitor.  Commands end with ; or \g.
 Your MariaDB connection id is 10
 Server version: 10.1.11-MariaDB MariaDB Server
 
 Copyright (c) 2000, 2015, Oracle, MariaDB Corporation Ab and others.
 
 Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
 
 MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
 Query OK, 1 row affected (0.00 sec)
 
 MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 
 'zabbix';
 Query OK, 0 rows affected (0.00 sec)
 
 MariaDB [(none)]> \q
 Bye

-Zabbix Server用のデータをMariaDBにインポート
 cd /usr/share/doc/zabbix-server-mysql-3.2.6/
 gzip -d create.sql.gz
 mysql -u zabbix -pzabbix zabbix < create.sql
 cd

-Zabbix Serverの設定ファイルをバックアップ
 mv -v /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak

-/etc/zabbix/zabbix_server.conf
 LogFile=/var/log/zabbix/zabbix_server.log
 LogFileSize=0
 PidFile=/var/run/zabbix/zabbix_server.pid
 DBSocket=/var/lib/mysql/mysql.sock
 SNMPTrapperFile=/var/log/snmptt/snmptt.log
 AlertScriptsPath=/etc/zabbix/alertscripts
 ExternalScripts=/etc/zabbix/externalscripts
 
 DBHost=localhost
 DBName=zabbix
 DBUser=zabbix
 DBPassword=zabbix

-PHP7対応で書き換える
 sed -i "s/PHP\_VERSION\,\ '5\.6'/PHP\_VERSION\,\ '7\.1'/g" /usr/share/zabbix/include/classes/setup/CFrontendSetup.php
-apache再起動

-Zabbix起動 apache再起動
 systemctl enable zabbix-server
 systemctl start zabbix-server
 systemctl restart httpd

-web画面の確認
 WebUIにアクセスするには「http://サーバIPアドレス/zabbix」とブラウザに入力
 表示されない場合はfirewallを止めてみる

-表示されない場合
--firewallにhttpの許可を追加
  firewall-cmd --permanent --add-service=http
-zabbixサーバが起動しない場合
--SELinuxに許可を追加
  setsebool -P httpd_can_connect_zabbix on
  setsebool -P zabbix_can_network on
  yum install policycoreutils-python
  grep zabbix_server /var/log/audit/audit.log | audit2allow -M zabbix-limit
  semodule -i zabbix-limit.pp


トップ   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS