Zabbix(2)-Zabbix安装

2022-10-31 14:55:10 浏览数 (1)

部署规划

服务器系统: CentOS Linux release 7.8.2003 (Core)

主机类型

IP地址

zabbix-server

192.168.100.26

zabbix-agent

192.168.100.26

zabbix-mysql

192.168.100.26

zabbix 安装

https://www.zabbix.com/documentation/5.0/zh/manual #产品手册

Zabbix-server 安装配置

下载安装:https://www.zabbix.com/download?zabbix=5.0&os_distribution=centos&os_version=7&db=mysql&ws=nginx

zabbix-serber 安装
  • Install Zabbix repository
代码语言:shell复制
yum install -y wget
wget https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm --no-check-certificate
rpm -Uvh zabbix-release-5.0-1.el7.noarch.rpm
yum clean all
  • Install Zabbix server and agent
代码语言:text复制
yum install zabbix-server-mysql zabbix-agent
  • Install Zabbix frontend
代码语言:text复制
yum install centos-release-scl -y
  • Install Zabbix frontend packages
代码语言:text复制
sed -i 's@enabled=1@enabled=1@g' /etc/yum.repo.d/zabbix.repo
yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
  • Install mysql
代码语言:shell复制
wget http://repo.mysql.com/mysql57-community-release-el7-9.noarch.rpm
rpm -ivh mysql57-community-release-el7-9.noarch.rpm
yum install mysql-server mysql -y
systemctl start mysqld
# 修改密码,配置远程访问
password=`grep 'temporary password' /var/log/mysqld.log|awk '{print $NF}'`;mysql -uroot -p${password}
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or g.
Your MySQL connection id is 5
Server version: 5.7.38

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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> use mysql;

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'lok@dWcv%anCCp57kMJv';
Query OK, 0 rows affected (0.00 sec)

mysql> update mysql.user set Host='%' where User='root';
Query OK, 1 row affected (0.00 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
  • Create initial database
代码语言:shell复制
# 创建数据库
mysql -uroot -p
password
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> create user zabbix@localhost identified by 'SPj2a@#@1^@yEd9EN3S5';
Query OK, 0 rows affected (0.00 sec)

mysql> grant all privileges on zabbix.* to zabbix@localhost;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> quit
Bye
# 导入数据
gzip -dv /usr/share/doc/zabbix-server-mysql*/create.sql.gz
mysql -uzabbix -p zabbix;
source /usr/share/doc/zabbix-server-mysql*/create.sql
# Edit file /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
DBHost=172.20.32.104
DBName=zabbix
DBUser=zabbix
DBPassword=123456
DBPort=3306
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
FpingLocation=/usr/bin/fping
Fping6Location=/usr/bin/fping6
LogSlowQueries=3000

Configure PHP for Zabbix frontend

Edit file /etc/opt/rh/rh-nginx116/nginx/conf.d/zabbix.conf, uncomment and set ‘listen’ and ‘server_name’ directives.

代码语言:text复制
# listen 7000;
# server_name zabbix.ctq6.cn;

Edit file /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf, add nginx to listen.acl_users directive.

代码语言:text复制
listen.acl_users = apache,nginx

Then uncomment and set the right timezone for you.

代码语言:text复制
php_value[date.timezone] = Asia/ShangHai

Start Zabbix server and agent processes

代码语言:shell复制
systemctl restart zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
systemctl enable zabbix-server zabbix-agent rh-nginx116-nginx rh-php72-php-fpm
web界面安装

访问:http://192.168.100.209:7000/setup.php

1、默认安装界面

2、配置mysql账号密码

3、zabbix 服务器信息

4、概要信息,确认

5、完成安装界面

6、登陆界面,默认账号密码Admin/zabbix

7、安装完成后,显示server runnning

0 人点赞