I wanted to touch Zabbix, so I built it with GCP and at the time of building (February 2020) with the latest version of Zabbix 4.4.
First, create an instance for Zabbix server. I created it as follows. Regarding machine specifications, the required specifications will change depending on the number of monitoring targets and the number of monitoring items to be registered. This time it's a test, so it's appropriate.
item | Contents |
---|---|
Instance name | zabbix-server |
region | us-central1 |
zone | us-central1-f |
Machine type | n1-standard-2 (vCPU x 2, memory 7.5 GB) |
Boot disk | CentOS 7 |
IP address | Create a static IP address |
The environment used is as follows.
item | Contents |
---|---|
OS | CentOS 7.7 |
Middleware | Apache MariaDB PHP |
Zabbix server | 4.4 |
Zabbix agent | 4.4 |
** List of sites that I referred to **
-Zabbix Official Documentation --Qiita's Zabbix related articles
Add Zabbix repository. If a new version is released, please check from the official repository below.
Install the repository configuration package.
$ rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
Next, install the necessary packages as a prerequisite.
For php, use group install
to install related packages as well.
#Installation of required packages
$ yum install httpd
$ yum install mariadb mariadb-server
$ yum groupinstall php
Then install the required packages on Zabbix server.
You will be asked yes / no
several times, but please proceed with y
. If it is troublesome, add -y
to the issue command and execute it, all will be executed with y
.
$ yum install zabbix-web-mysql zabbix-web-japanese zabbix-server-mysql
First, set up Zabbix server.
#Edit configuration file-Uncomment the line and set the DB password
$ vi /etc/zabbix/zabbix_server.conf
The following changes
-------------------------------------------------
# DBPassword=
↓
DBPassword=xxxxxxxxxx <---Enter any password here
-------------------------------------------------
Next, set the DB.
#Enable auto-start setting
$ systemctl enable mariadb
#Service startup
$ systemctl start mariadb
#Perform initial DB settings
# yes/You will be asked no several times, but all[y]Please proceed with. Password is zabbix_server.I made it the same as the one set in conf.
$ mysql_secure_installation
#Login to DB
$ mysql -u root -p <password>
#Database zabbix character set utf8 collat e utf8_Create a bin.
MariaDB [(none)]> CREATE DATABASE zabbix character set utf8 collate utf8_bin;
MariaDB [(none)]> CREATE USER zabbix@localhost IDENTIFIED BY '<password>';
MariaDB [(none)]> GRANT ALL ON zabbix.* TO zabbix@localhost;
MariaDB [(none)]> quit
Bye
Load the schema file for Zabbix into the database.
$ zcat /usr/share/doc/zabbix-server-mysql-4.4.*/create.sql.gz | mysql -u zabbix -p zabbix
Enter password:← Enter the password of DB user zabbix
Disable SELinux settings and restart the OS.
$ vi /etc/sysconfig/selinux
#changes
SELINUX=enforcing
↓
SELINUX=disabled
#Reboot
$ reboot
Firewall settings (zabbix server side)
$ firewall-cmd --add-port=10051/tcp --zone=public --permanent
success
$ firewall-cmd --add-service=http --zone=public --permanent
success
$ firewall-cmd --reload
success
Set Apache's automatic start and start the service.
$ systemctl enable httpd
$ systemctl start httpd
Roughly at least the settings on the Zabbix server side are over.
From here, the settings will be made on the monitored side.
Installation of zabbix-agent
#Add Zabbix repository
$ rpm -Uvh https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
$ yum install zabbix-agent
Edit configuration file
$ vi /etc/zabbix/zabbix_agentd.conf
#Enable remote command monitoring,Uncomment and change the value to 1
#The following changes
# EnableRemoteCommands=0
↓
EnableRemoteCommands=1
#Server IP address that allows monitoring
#Change to Zabbix server IP address
Server=127.0.0.1
↓
Server=xxx.xxx.xxx.xxx
#IP address of the server to which the active check monitoring data is sent
#Change to Zabbix server IP address
ServerActive=127.0.0.1
↓
ServerActive=xxx.xxx.xxx.xxx
#Note that it is not the host name on the OS, but the host name on Zabbix monitoring settings.
Hostname=Zabbix server
↓
Hostname=myhost01
Set automatic start of zabbix-agent and start service.
$ systemctl enable zabbix-agent
$ systemctl start zabbix-agent
Firewall settings (monitored server side)
$ firewall-cmd --add-port=10050/tcp --zone=public --permanent
$ firewall-cmd --add-source=<IP address of Zabbix server here> --zone=public --permanent
$ firewall-cmd --reload
Roughly at least the settings on Zabbix-agent side are completed.
Let's take a look at the management screen!
http://ZabbixサーバのIPアドレス/zabbix/
Follow the instructions on the screen to proceed with the initial settings
Confirm that the dashboard is displayed, and the initial setting is completed.
Up to this point, the settings until monitoring can be taken are complete. Thank you for your hard work.
As an aside, I personally recommend a dark theme that is easy on the eyes. It can be set from the following.
The dashboard looks like this
After that, I tried to monitor the previously built Minecraft server and discord-bot server, Zabbix is good, I really like it ^^
I wanted to try various things and study so that I could use Zabbix more. See you again!
Recommended Posts