Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to install and deploy Zabbix

2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces how to install and deploy Zabbix. It is very detailed and has a certain reference value. Friends who are interested must finish it!

Preface

Zabbix is currently one of the most mainstream open source monitoring solutions, deployment itself is not difficult, the difficulty is in-depth understanding. According to the practice in the production environment, starting with the new version of Zabbix 4.0 LTS, I believe that more and more open source components will be presented to us in containerized form in the future.

Operating system:

[root@mysql ~] # cat / etc/redhat-releaseCentOS Linux release 7.5.1804 (Core)

Mysql: version 5.7.23 192.168.75.251

Zabbix Server: version 3.4.12 192.168.75.250

First, install Mysql

1.1 download mysql

Turn off the firewall

# systemctl stop firewalld# systemctl disable firewalldvi / etc/selinux/configSELINUX=enforcing changed to SELINUX= disabled

Centos7 default database is mariadb. Uninstall it first.

Rpm-qa | grep mariadbmariadb-libs-5.5.56-2.el7.x86_64rpm-e-- nodeps mariadb-libs-5.5.56-2.el7.x86_64

This version requires boost 1.9and also needs to be downloaded.

[root@mysql soft] # lltotal 132444 RW root@mysql soft-1 root root 83709983 Aug 10 10:26 boost_1_59_0.tar.gz-rw-r--r-- 1 root root 51907462 Aug 10 10:26 mysql-5.7.23.tar.gz

Add mysql user

Groupadd mysqluseradd-g mysql-s / sbin/nologin mysql

1.2 install dependency packages

Yum install-y cmake bison bison-devel libaio-devel gcc gcc-c++ git ncurses-devel

1.3 compilation

Extract the mysql and put the compressed version of boost in the decompressed mysql directory

Tar xzvf mysql-5.7.23.tar.gzmv boost_1_59_0.tar.gz mysql-5.7.23

Go to the MySQL source file directory, create a new configure as the compilation directory, and enter it

Cd mysql-5.7.23mkdir configurecd configure

Using cmake to build a compilation environment

Cmake.. -DBUILD_CONFIG=mysql_release\-DINSTALL_LAYOUT=STANDALONE\-DCMAKE_BUILD_TYPE=RelWithDebInfo\-DENABLE_DTRACE=OFF\-DWITH_EMBEDDED_SERVER=OFF\-DWITH_SSL=bundled\-DWITH_ZLIB=system\-DWITH_PAM=ON\-DCMAKE_INSTALL_PREFIX=/var/mysql/\-DINSTALL_PLUGINDIR= "/ var/mysql/lib/plugin"\-DDEFAULT_CHARSET=utf8\-DDEFAULT_COLLATION=utf8_general_ci\-DWITH_EDITLINE=bundled\-DFEATURE_SET=community\-DCOMPILATION_COMMENT= "MySQL Server (GPL)"\-DWITH_DEBUG=OFF\-DWITH_BOOST=..

Installation

Make & & make install

Modify the configuration file

Vim / etc/ my.cnf[mysqld] datadir=/var/lib/mysqlsocket=/var/mysql/mysql.sockport=3306log_error=/var/mysql/log/error.logbasedir=/var/mysql/ [client] socket=/var/mysql/mysql.sockchown mysql.mysql / etc/my.cnf

Create a log file

Mkdir-p / var/mysql/logtouch / var/mysql/log/error.logtouch / var/mysql/mysql.sockchown-R mysql.mysql / var/mysql/

1.4 initialization

# / var/mysql/bin/mysqld-initialize-user=mysql

Check to see if the data file is generated

# ll / var/lib/mysqltotal 110628 ibdata1-rw-r- RW mysql mysql r-1 mysql mysql 56 Aug 10 11:06 auto.cnf-rw-r- 1 mysql mysql 417 Aug 10 11:06 ib_buffer_pool-rw-r- 1 mysql mysql 12582912 Aug 10 11:06 ibdata1-rw-r- 1 mysql mysql 50331648 Aug 10 11:06 ib_logfile0-rw-r- 1 mysql mysql 50331648 Aug 10 11:06 ib_logfile1drwxr-x--- 2 Mysql mysql 4096 Aug 10 11:06 mysqldrwxr-x--- 2 mysql mysql 8192 Aug 10 11:06 performance_schemadrwxr-x--- 2 mysql mysql 8192 Aug 10 11:06 sys

Check whether the log file is generated

# ll / var/mysql/log

Temporary password generation is placed in error.log

# cat / var/mysql/log/error.log2019-11-18T09:06:22.922254Z 0 [Warning] TIMESTAMP with implicit DEFAULT value is deprecated. Please use-- explicit_defaults_for_timestamp server option (see documentation for more details). 2019-11-18T09:06:24.600401Z 0 [Warning] InnoDB: New log files created, LSN=457902019-11-18T09:06:24.853258Z 0 [Warning] InnoDB: Creating foreign key constraint system tables.2019-11-18T09:06:24.915246Z 0 [Warning] No existing UUID has been found, so we assume that this is the first time that this server has been started. Generating a new UUID: 5dbf9eac-9c4a-11e8-8768-000c29a48522.2019-11-18T09:06:24.916709Z 0 [Warning] Gtid table is not ready to be used. Table 'mysql.gtid_executed' cannot be opened.2019-11-18T09:06:24.917772Z 1 [Note] A temporary password is generated for root@localhost: NS0+ > RzwvHWl

1.5 start

Change the initial password, modify environment variables

Copy the startup file from the template file:

Cp / var/mysql/support-files/mysql.server / etc/init.d/mysqld

Modify the startup file:

Vim / etc/init.d/mysqld

Find the following two lines:

Basedir=

Datadir=

Modified to:

Basedir=/var/mysql/datadir=/var/lib/mysql

Change permissions

# chown-R mysql.mysql / var/mysql / var/lib/mysql

Start

/ etc/init.d/mysqld startln-s / var/mysql/bin/mysql / usr/bin

Configure the MySQL environment variable:

Vim / root/.bash_profile

Find the following line:

PATH=$PATH:$HOME/bin

Modified to:

PATH=$PATH:$HOME/bin:/var/mysql/bin

Log in using the temporary password generated above

# mysql-u root-p NS0+ > RzwvHWl

Welcome to the MySQL monitor. Commands end with; or\ g.

Your MySQL connection id is 6

Server version: 5.7.23

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

Affiliates. Other names may be trademarks of their respective

Owners.

Type 'help;' or'\ h' for help. Type'\ c'to clear the current input statement.

Mysql >

Change the initial password

Mysql > alter user 'root'@'localhost' identified by' 123456'

Second, install Zabbix Server

2.1 install php

Install php7.1 version, zabbix3.0 version requires php5.4 or above.

Check the local php version first

Php-v

Check the current php installation package

Yum list installed | grep php

Uninstall the local php installation package cleanly

Yum remove php*

The default yum source cannot upgrade PHP. We need to add a third-party yum source. We choose the webtatic library.

Rpm-Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpmrpm-Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

Install php7.1

Yum install-y php71w

Install related plug-ins

Yum install-y php71w-fpm php71w-opcache php71w-cli php71w-gd php71w-imap php71w-mysqlnd php71w-mbstring php71w-mcrypt php71w-pdo php71w-pecl-apcu php71w-pecl-mongodb php71w-pecl-redis php71w-pgsql php71w-xml php71w-xmlrpc php71w-devel mod_php71w php71w-ldap php71w-bcmath

Modify the configuration parameters of PHP

Vim / etc/php.inidate.timezone= Asia/Shanghaimax_execution_time = 300post_max_size = 32Mmemory_limit = 128Mmbstring.func_overload = 1max_input_time = 300

Session adjust permissions

Chmod-R 777 / var/lib/php/session/

2.2 install zabbix

Install dependency packages

Yum-y install gcc* make curl curl-devel net-snmp net-snmp-devel perl-DBI httpd mariadb* mysql-devel libxml2-devel curl-devel unixODBC-devel net-snmp-devel OpenIPMI-devel openldap openldap-devel libevent-develjava-devellibssh3-devel

Create zabbix users and groups

Groupadd zabbixuseradd-g zabbix zabbix

Compile, install

Tar zxvf zabbix-3.4.12.tar.gzcd zabbix-3.4.12/./configure-prefix=/usr/local/zabbix-- enable-server-- enable-proxy-- enable-agent-- enable-ipv6-- with-mysql-- with-net-snmp-- with-libcurl-- with-openipmi-- with-unixodbc-- with-ldap-- with-ssh3-- enable-javamake & & make installchown-R zabbix.zabbix / usr/local/zabbix

Modify zabbix configuration file

Vi / usr/local/zabbix/etc/zabbix_server.confLogFile=/tmp/zabbix_server.logDebugLevel=3DBHost=192.168.75.251 # server and DBName=zabbixDBUser=zabbixDBPassword=zabbixDBSocket=/var/mysql/mysql.sockDBPort=3306StartPollers=10Timeout=4AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscriptsLogSlowQueries=3000CacheSize=1024M for database separation

The parameters of the later configuration file are adjusted according to the demand.

Transfer several sql files from the zabbix package to the above mysql server and import the database file

[root@zabbix] # cd / opt/soft/zabbix-3.4.12/database/mysql [root@zabbix mysql] # lltotal 4876 RW Murray. 1 1001 1001 2877497 Jul 30 19:41 data.sql-rw-r--r--. 1 1001 1001 1978341 Jul 30 19:41 images.sql-rw-r--r--. 1 1001 1001 134791 Jul 30 19:41 schema.sql [root@zabbix mysql] # scp * root@192.168.75.251:/opt/

The following is done on the mysql (192.168.75.251) server

# mysql-u root-p

Enter password:

Create a zabbix database with the character set set to utf8

Mysql > create database zabbix character set utf8 collate utf8_bin

Create a zabbix user in the mysql database, give the zabbix user full permissions on the zabbix database, and allow the zabbix server to access mysql remotely

Mysql > GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@192.168.75.250IDENTIFIED BY 'zabbix';mysql > GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY' zabbix';mysql > flush privileges;mysql > show databases +-+ | Database | +-+ | information_schema | | mysql | | performance_schema | | sys | | zabbix | +-+ 5 rows in set (0.00 sec)

Import data files and operate in the console

# mysql-u zabbix-p zabbix

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report