This is an introduction memo for CentOS 8 of a condition monitoring solution called Zabbix. The configuration uses PostgreSQL for the backend DB and Nginx for the frontend.
Prepare a minimum installed CentOS8. https://qiita.com/SkyLaptor/items/9d597c3b5ae3db5dfc48
This time, I chose PostgreSQL v12 as the database. On Zabbix compatibility list, it seems OK if PostgreSQL v9.2.24 or higher.
python
# wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-8.noarch.rpm
# rpm -Uvh epel-release-latest-8.noarch.rpm
# wget https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# rpm -Uvh pgdg-redhat-repo-latest.noarch.rpm
# dnf install epel-release
# dnf module disable postgresql
# dnf config-manager --disable pgdg10 pgdg11 pgdg95 pgdg96
# dnf clean all
# dnf install postgresql12-server-12.4-1PGDG.rhel8.x86_64 postgresql12-odbc
python
# su - postgres
postgres$ vim .bash_profile
.bash_profile
export PGDATA
#Add the following
export PATH=$PATH:/usr/pgsql-12/bin
python
postgres$ source .bash_profile
postgres$ initdb --encoding=utf8 --locale=C -D /var/lib/pgsql/12/data
postgres$ exit
# systemctl start postgresql-12
# systemctl enable postgresql-12
If you set the front end to Nginx with Zabbix, it seems that it will be installed at the same time when Zabbix is set up.
python
# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
# dnf clean all
# dnf install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-agent zabbix-get vlgothic-fonts vlgothic-p-fonts
# sudo -u postgres createuser --pwprompt zabbix
could not change directory to "/root":No permission * Ignore it and OK
Enter password for new role:Any DB password
Enter it again:Any DB password again
# sudo -u postgres createdb -O zabbix zabbix
could not change directory to "/root":No permission * Ignore it and OK
# zcat /usr/share/doc/zabbix-server-pgsql*/create.sql.gz | sudo -u zabbix psql zabbix
...
INSERT 0 1
COMMIT
# cp -p /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.default
# vim /etc/zabbix/zabbix_server.conf
/etc/zabbix/zabbix_server.conf
# DBPassword=
DBPassword=DB password
python
# cp -p /etc/nginx/conf.d/zabbix.conf /etc/nginx/conf.d/zabbix.conf.default
# vim /etc/nginx/conf.d/zabbix.conf
shell:/etc/nginx/conf.d/zabbix.conf
listen 80;
server_name own server name;
python
# cp -p /etc/php-fpm.d/zabbix.conf /etc/php-fpm.d/zabbix.conf.default
# echo "php_value[date.timezone] = Asia/Tokyo" >> /etc/php-fpm.d/zabbix.conf
# rm /etc/alternatives/zabbix-web-font
# ln -s /usr/share/fonts/vlgothic/VL-PGothic-Regular.ttf /etc/alternatives/zabbix-web-font
# systemctl restart zabbix-server zabbix-agent nginx php-fpm
# systemctl enable zabbix-server zabbix-agent nginx php-fpm
Below in a web browser Access the URL of and start the initial setup.
http: // {server IP or FQDN} /
The system requirements check confirms that there is no NG.
Enter the DB password in the Password
part. You don't have to touch the others.
The initial ID is Admin
and the password is zabbix
.
Set the display to Japanese. Click User settings
at the bottom left of the screen.
Change Language
toJapanese (ja_JP)
.
It is now displayed in Japanese.
It will work as it is, but make various tunings so that it works comfortably.
PostgreSQL
python
# mkdir /etc/systemd/system/postgresql-12.service.d
# vim /etc/systemd/system/postgresql-12.service.d/override.conf
shell:/etc/systemd/system/postgresql-12.service.d/override.conf
[Service]
LimitNOFILE=65536
LimitNPROC=65536
python
# systemctl daemon-reload
# systemctl restart postgresql-12
Nginx
python
# vim /etc/systemd/system/nginx.service.d/override.conf
shell:/etc/systemd/system/postgresql-12.service.d/override.conf
[Service]
LimitNOFILE=65536
LimitNPROC=65536
python
# systemctl daemon-reload
# systemctl restart nginx
PHP
python
# vim /etc/php-fpm.d/zabbix.conf
shell:/etc/php-fpm.d/zabbix.conf
php_value[memory_limit] =1024MB * Adjustment required according to the environment
python
# systemctl restart zabbix-server zabbix-agent nginx php-fpm
If the OS can install Zabbix Agent, it will be possible to acquire a wide variety of information. Let's put it in. Here, the minimum installation of CentOS 8 is targeted.
python
# wget https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
# rpm -Uvh zabbix-release-5.0-1.el8.noarch.rpm
# dnf clean all
# dnf install zabbix-agent zabbix-get
# cp -p /etc/zabbix/zabbix_agentd.conf /etc/zabbix/zabbix_agentd.conf.default
# vim /etc/zabbix/zabbix_agentd.conf
/etc/zabbix/zabbix_agentd.conf
Server=127.0.0.1,IP address of Zabbix Server
#Hostname=Zabbix server * Comment out
python
# systemctl start zabbix-agent
# systemctl enable zabbix-agent
Simply putting the Agent in the monitoring target will not register it in Zabbix Server. Follow the steps below to register.
Log in to the Zabbix Web Console and select Settings
→ Host
from the left menu.
Click Create Host
at the top right of the host screen.
Enter an arbitrary host name in host name
, Linux Servers
in group
, and the target IP address in IP address
of interface
.
Apply Template OS Linux by Zabbix agent
at Link new template
and click `Add``.
After a few minutes of addition, check the agent status
of the added host in the host list and the ZBX
will turn green. It is now monitored.
Recommended Posts