zabbix4.0.19 deployment - Nanny level tutorial

zabbix4.0 deployment

zabbix server needs LAMP or LNMP environment, so there are many installation methods here. We choose a relatively simple installation method and install it directly with the source provided by the official.

Deployment preparation

[root@zabbix-server ~]# uname -a
Linux zabbix-server 3.10.0-1062.18.1.el7.x86_64 #1 SMP Tue Mar 17 23:49:17 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@zabbix-server ~]# cat /etc/centos-release
CentOS Linux release 7.7.1908 (Core)

When the firewall is off, turn off SELinux

yum -y update

Install PHP

yum install -y php php-fpm

vim /etc/php.ini
shift+g Add the following content to the end:

date.timezone = Asia/Shanghai max_execution_time = 300
post_max_size = 32M
max_input_time = 300
memory_limit = 128M makefile

systemctl start php-fpm

Install mariadb

Detect conflicts

Be sure to uninstall MySQL cleanly, otherwise there will be inexplicable problems

systemctl stop mysqld
rpm -aq mysql*
yum remove -y `rpm -aq mysql*`

[root@server2 ~]# find / -name mysql
[root@server1 ~]# rm -rf /var/lib/mysql /var/lib/mysql/mysql /usr/share/mysql

[root@server2 ~]# ll /etc/my.cnf
-rw-r--r-- 1 root root 570 Sep 21  2016 /etc/my.cnf
[root@server2 ~]# rm -rf /etc/my.cnf
[root@server2 ~]# rpm -aq mysql*

Prepare installation package

yum -y install mariadb mariadb-server
systemctl start mariadb
systemctl enable mariadb

You must start it here before you can generate a log. For some versions, you need to find the password in the log.

Database permission initialization

/usr/bin/mysql_secure_installation mysql -uroot mysql -uroot -p

Initialization process:

01 [root@test ~]# /usr/bin/mysql_secure_installation
05 In order to log into MySQL to secure it, we'll need the current
06 password for the root user.  If you've just installed MySQL, and
07 you haven't set the root password yet, the password will be blank,
08 so you should just press enter here.
10 Enter current password for root (enter for none):<---Enter the current root Password, because we haven't set it yet, just enter
11 OK, successfully used password, moving on...
13 Setting the root password ensures that nobody can log into the MySQL
14 root user without the proper authorisation.
16 Set root password? [Y/n] Y   <---Set or not root Password, of course. Enter it Y enter
17 New password: <---input root Enter the password and press enter. There will be no display during the input process
18 Re-enter new password: <---Enter again root Enter the password and press enter. There will be no display during the input process
19 Password updated successfully!
20 Reloading privilege tables..
21  ... Success!
23 By default, a MySQL installation has an anonymous user, allowing anyone
24 to log into MySQL without having to have a user account created for
25 them.  This is intended only for testing, and to make the installation
26 go a bit smoother.  You should remove them before moving into a
27 production environment.
29 Remove anonymous users? [Y/n] Y <---Delete anonymous user? Enter Y enter
30  ... Success!
32 Normally, root should only be allowed to connect from 'localhost'.  This
33 ensures that someone cannot guess at the root password from the network.
35 Disallow root login remotely? [Y/n] Y <---Delete prohibition root User remote login, of course, prohibited, input Y enter
36  ... Success!
38 By default, MySQL comes with a database named 'test' that anyone can
39 access.  This is also intended only for testing, and should be removed
40 before moving into a production environment.
42 Remove test database and access to it? [Y/n] <---Delete test database test´╝îDelete, enter Y enter
43  - Dropping test database...
44  ... Success!
45  - Removing privileges on test database...
46  ... Success!
48 Reloading the privilege tables will ensure that all changes made so far
49 will take effect immediately.
51 Reload privilege tables now? [Y/n] Y <---Refresh permissions, enter Y enter
52  ... Success!
54 Cleaning up...
56 All done!  If you've completed all of the above steps, your MySQL
57 installation should now be secure.
59 Thanks for using MySQL!

Change character set

vim /etc/my.cnf

stay[mysqld]Add to:
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'

vim /etc/my.cnf.d/client.cnf
 stay[client]Add in

vim /etc/my.cnf.d/mysql-clients.cnf

View confirmation character set

[root@pokes02 ~]# mysql -uroot -p******

MariaDB [(none)]> show variables like "%character%";show variables like "%collation%";
| Variable_name            | Value                      |
| character_set_client     | utf8                       |
| character_set_connection | utf8                       |
| character_set_database   | latin1                     |
| character_set_filesystem | binary                     |
| character_set_results    | utf8                       |
| character_set_server     | latin1                     |
| character_set_system     | utf8                       |
| character_sets_dir       | /usr/share/mysql/charsets/ |
8 rows in set (0.00 sec)

| Variable_name        | Value             |
| collation_connection | utf8_general_ci   |
| collation_database   | latin1_swedish_ci |
| collation_server     | latin1_swedish_ci |
3 rows in set (0.00 sec)

Install apache

yum install -y httpd

Installing zabbix

rpm -i
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y

Pay attention to whether there are errors reported.

Common error handling:

Solve Errno 256 error reporting

yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent The following errors are reported:

Error downloading packages: 
zabbix-web-4.0.19-1.el7.noarch: [Errno 256] No more mirrors to try. 
zabbix-agent-4.0.19-1.el7.x86_64: [Errno 256] No more mirrors to try. 
zabbix-server-mysql-4.0.19-1.el7.x86_64: [Errno 256] No more mirrors to try.

reason: zabbix The source itself is a problem because the server is abroad.

[root@localhost ~]# cd /etc/yum.repos.d
[root@localhost yum.repos.d]# ls
CentOS-Base.repo  CentOS-Debuginfo.repo  CentOS-Media.repo    CentOS-Vault.repo
CentOS-CR.repo    CentOS-fasttrack.repo  CentOS-Sources.repo  zabbix.repo
[root@localhost yum.repos.d]# vim zabbix.repo 

Add the following:

name=Zabbix Official Repository - $basearch

name=Zabbix Official Repository non-supported - $basearch

Import zabbix data

Create library and authorize

Before creating a new bbzaix data library, you must manage the bbzaix data library

Create zabbix library, create zabbix user, and authorize.

[root@pokes02 ~]# mysql -uroot -p
password :123456
mysql> create database zabbix character set utf8 collate utf8_bin;      #Create zabbix Library
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '******';     #Create zabbix user with password*****
mysql> grant all on zabbix.* to 'zabbix'@'localhost' identified by '*******' with grant option;  #Authorize zabbix users to have permission to manage zabbix libraries
mysql> flush privileges;    #Refresh permissions
mysql> quit;

The above libraries, users and authorizations have been created. Now let's find the data to import

View the database provided by zabbix

[root@pokes02 ~]# ls /usr/share/doc/zabbix-server-mysql-4.0.38/create.sql.gz 
[root@pokes02 ~]# gzip -d /usr/share/doc/zabbix-server-mysql-4.0.38/create.sql.gz
[root@pokes02 ~]# mysql -uzabbix -p******* zabbix < /usr/share/doc/zabbix-server-mysql-4.0.38/create.sql    # *****It's a password

Note: if an error is reported when importing data here, it is because you did not authorize successfully, or did not build a zabbix library, or the zabbix user password is wrong, etc.

Restart service

systemctl restart zabbix-server.service
systemctl restart zabbix-agent.service 
systemctl restart httpd.service 

Zabbix configuration

Modify the DBPassword password. After the database is imported, you need to configure the database password for Zabbix and modify / etc / Zabbix / Zabbix_ server. In conf

vim /etc/zabbix/zabbix_server.conf    #Tap / search DBPassword
DBPassword=********			#The password here is the password of the database zabbix user, not the root password

The default is to add a # number for annotation, and to cancel the annotation and add a password

Configure PHP time zone

Configure PHP time zone for ZABBIX: modify and edit the file / etc / httpd / conf.d/ Conf, uncomment and set the correct time zone for you.

vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai

Start Zabbix service

Restart service:
systemctl restart zabbix-server
systemctl restart zabbix-agent 
systemctl restart httpd.service

Configure startup:
systemctl enable zabbix-server
systemctl enable zabbix-agent 
systemctl enable httpd

Access graphical interface

After startup, you can run: http://IP/zabbix Enter the configuration interface of ZABBIX.

The default login account and password are Admin and zabbix

Keywords: Linux MySQL CentOS Zabbix

Added by r4ck4 on Thu, 17 Feb 2022 03:38:14 +0200