CentOS7にZabbix4.0を構築する手順メモ
| 登録日 | :2024/03/25 03:48 |
|---|---|
| カテゴリ | :Linux |
CentOS7.9にZabbix4.0を構築する手順をメモする。
環境は
OS : CentOS7.9
DB : mariadb 5.5
Zabbix: : 4.0-1
1 関連ソフトのインストール
wget https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
rpm -ivh zabbix-release-4.0-1.el7.noarch.rpm
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-sender zabbix-get zabbix-web-japanese
yum -y install mariadb mariadb-server mariadb-libs
yum -y install net-snmp
2. DBセットアップ
mariadbのrootパスワード初期セットアップ
[root@localhost log]# 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):
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] Y
New password:
Re-enter new password:
Sorry, you can't use an empty password here.
New password:
Re-enter new password:
Sorry, passwords do not match.
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] Y
... 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] n
... skipping.
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] Y
- 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] Y
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
データベースの構築
[root@localhost install]# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 9
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, 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 'passwor
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit;
Bye
スキーマの投入
[root@localhost zabbix-server-mysql-4.0.50]#cd /usr/share/doc/zabbix-server-mysql*/
[root@localhost zabbix-server-mysql-4.0.50]# ls
AUTHORS COPYING ChangeLog NEWS README create.sql.gz
[root@localhost zabbix-server-mysql-4.0.50]# zcat create.sql.gz | mysql -u zabbix -p zabbix
Enter password:
[root@localhost zabbix-server-mysql-4.0.50]#
3. Zabbixサーバの設定
zabbix._server.confにて、DBのパスワードを登録
[root@localhost zabbix]# vi /etc/zabbix/zabbix_server.conf
(省略)
# DBPassword=
DBPassword=zabbix_password
zabbix.confにてTimezoneの設定
[root@localhost zabbix]# cd /etc/httpd/conf.d/
[root@localhost conf.d]# ls
README autoindex.conf php.conf userdir.conf welcome.conf zabbix.conf
[root@localhost conf.d]# vi zabbix.conf
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
<IfModule mod_php5.c>
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 max_input_vars 10000
php_value always_populate_raw_post_data -1
# php_value date.timezone Europe/Riga
php_value date.timezone Asia/Tokyo
</IfModule>
</Directory>
4. Zabbixサーバスタート
[root@localhost conf.d]# systemctl start zabbix-server
[root@localhost conf.d]# systemctl start zabbix-agent
[root@localhost conf.d]# systemctl restart httpd
[root@localhost conf.d]# systemctl enable httpd
[root@localhost conf.d]# systemctl enable zabbix-server
[root@localhost conf.d]# systemctl enable zabbix-agent
[root@localhost conf.d]# systemctl enable mariadb
firewalldをいったん無効
[root@localhost zabbix]# systemctl stop firewalld.service
5. Webアクセス
http://サーバのIPアドレス/zabbix
にて、Zabbixサーバにアクセス。
初期設定で、DBパスワードやZabbix名などを定義。
Zabbixの初回ログインは
Admin
zabbix
にて、ダッシュボードのトップ画面が表示されればOK