My original installation of Zabbix (v4.0) has been installed on centos7 and it's time to migrate it to a new el8 (v5.0) installation. I will use almalinux8 here but these steps should be identical for rockylinux or any other rhel8 clone.
I'll use postgresql and nginx for my setup, so the steps might vary when using mysql or httpd.
First, enable the postgresql module stream. Version 10 is enabled by default but I'll go for the latest available which is version 13 as of writing this.
[root@zabbix-new ~]# yum -d 2 -y module enable postgresql:13
Now that the module stream is enabled, install the required packages:
[root@zabbix-new ~]# yum -d 2 -y install postgresql postgresql-server postgresql-contrib
Initialize the database and start it:
[root@zabbix-new ~]# su - postgres -c 'initdb'
[root@zabbix-new ~]# systemctl enable --now postgresql.service
Create the zabbix user and database in postgresql (creating the user will prompt for a password):
[root@zabbix-new ~]# su - postgres -c 'createuser -P zabbix'
[root@zabbix-new ~]# su - postgres -c 'createdb -O zabbix zabbix'
Create a database backup on the old server and transfer it to the new installation:
[root@zabbix-new]# nc -lvnp 8080 | bzip2 -cdv9 | psql -h 127.0.0.1 -p 5432 -d zabbix -U zabbix -W
[root@zabbix-old]# pg_dump -h 127.0.0.1 -p 5432 -d zabbix -U postgres -w | bzip2 -cv9 | nc -v zabbix-new.archyslife.lan 8080
Depending on the amount of data, this can take a minute.
Once the database transfer is done, we'll continue with the nginx setup on the new server. I'll use nginx v1.20 and php v7.4 which requires enabling a few modules again:
[root@zabbix-new ~]# yum -d 2 -y module enable nginx:1.20 php:7.4
Now that all requirements are met, add the zabbix repo and install the packages:
[root@zabbix-new ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/8/x86_64/zabbix-release-5.0-1.el8.noarch.rpm
[root@zabbix-new ~]# yum -d 2 -y install zabbix-server-pgsql zabbix-web-pgsql zabbix-nginx-conf zabbix-agent
These packages will generate the required configs for php-fpm and nginx. Before finally restarting the services, we'll need to adjust the 'listen' and 'server_name' directive in '/etc/nginx/conf.d/zabbix.conf' config and the timezone in '/etc/php-fpm.d/zabbix.conf'
[root@zabbix-new ~]# sed -i 's/^#\ \ \ \ \ \ \ \ listen\ \ \ \ \ \ \ \ \ \ 80;/ listen 80;/g' /etc/nginx/conf.d/zabbix.conf
[root@zabbix-new ~]# sed -i "s/^#\ \ \ \ \ \ \ \ server_name\ \ \ \ \ example.com;/ server_name $(hostname -f);/g" /etc/nginx/conf.d/zabbix.conf
[root@zabbix-new ~]# sed -i 's/^; php_value\[date\.timezone\] = Europe\/Riga/php_value[date.timezone] = Europe\/Prague/g' /etc/php-fpm.d/zabbix.conf
With all configs set, restart the zabbix-server php-fpm and nginx to make them use the adjusted configs:
[root@zabbix-new ~]# systemctl restart zabbix-server.service php-fpm.service nginx.service
Also make sure they're enabled so that they start automatically after a reboot:
[root@zabbix-new ~]# systemctl enable --now zabbix-server.service php-fpm.service nginx.service
If you are using SELinux (which I highly encourage), you'll have to set a few booleans to allow zabbix to operate as expected:
[root@zabbix-new ~]# setsebool -P httpd_builtin_scripting on
[root@zabbix-new ~]# setsebool -P httpd_can_connect_zabbix on
[root@zabbix-new ~]# setsebool -P httpd_can_network_connect_db on
[root@zabbix-new ~]# setsebool -P httpd_can_sendmail on
[root@zabbix-new ~]# setsebool -P httpd_enable_cgi on
[root@zabbix-new ~]# setsebool -P zabbix_can_network on
In order to finish the installation, connect to the WebUI on your server (http://your_server_ip_or_fqdn/)
Feel free to comment and / or suggest a topic.
Comments
Post a Comment