Zabbix 5.2 for CentOS8


## MySQL インストール

```
dnf -y module install mysql
systemctl enable mysqld
systemctl start mysqld
mysql_secure_installation
```

```mysql_secure_installation
Securing the MySQL server deployment.

Connecting to MySQL using a blank password.

VALIDATE PASSWORD COMPONENT can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD component?

Press y|Y for Yes, any other key for No: y

There are three levels of password validation policy:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

Please enter 0 = LOW, 1 = MEDIUM and 2 = STRONG: 0
Please set the password for root here.

New password:

Re-enter new password:

Estimated strength of the password: 50
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL 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? (Press y|Y for Yes, any other key for No) : 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? (Press y|Y for Yes, any other key for No) : y
Success.

All done!
```


## Apache PHP インストール

```
dnf -y module install httpd php
systemctl enable httpd
systemctl start httpd
systemctl enable php-fpm
systemctl start php-fpm
```

## Zabbix インストール

```
dnf -y install https://repo.zabbix.com/zabbix/5.2/rhel/8/x86_64/zabbix-release-5.2-1.el8.noarch.rpm
dnf -y install zabbix-server-mysql zabbix-web-japanese zabbix-apache-conf
```

### PHP 設定変更

```
vi /etc/php-fpm.d/zabbix.conf
```

```/etc/php-fpm.d/zabbix.conf
[zabbix]
user = apache
group = apache
listen = /run/php-fpm/zabbix.sock
listen.acl_users = apache,nginx
listen.allowed_clients = 127.0.0.1
pm = dynamic
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35
php_value[session.save_handler] = files
php_value[session.save_path]    = /var/lib/php/session
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[date.timezone] = Asia/Tokyo
```

### Zabbix Server 設定変更

```
vi /etc/zabbix/zabbix_server.conf
```

```/etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBName=zabbix
DBUser=zabbix
DBPassword=パスワード
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
LogSlowQueries=3000
StatsAllowedIP=127.0.0.1
```


### MySQL 設定変更

```
mysql -u root -p パスワード
```


```sql
CREATE DATABASE zabbix character set utf8 collate utf8_bin;
CREATE USER zabbix@localhost IDENTIFIED BY 'パスワード';
GRANT ALL ON zabbix.* TO zabbix@localhost;
```

### Zabbix用のテーブル作成

```
zcat /usr/share/doc/zabbix-server-mysql/create.sql.gz | mysql -u zabbix -p パスワード
```

### Zabbix Server 起動

```
systemctl enable zabbix-server
systemctl start zabbix-server
```



## Zabbix Agent インストール

```
dnf -y install zabbix-agent2
```

### Zabbix Agent 設定変更

```
vi /etc/zabbix/zabbix_agent2.conf
```

```/etc/zabbix/zabbix_agent2.conf
PidFile=/var/run/zabbix/zabbix_agent2.pid
LogFile=/var/log/zabbix/zabbix_agent2.log
LogFileSize=0
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agent2.d/*.conf
ControlSocket=/tmp/agent.sock
```

### Zabbix Agent 起動

```
systemctl enable zabbix-server
systemctl start zabbix-server
systemctl enable zabbix-agent2
systemctl start zabbix-agent2
```