CentOS 7安装zabbix 5.0
安装前的操作
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since 三 2021-12-08 14:01:28 CST; 9s ago
#开启开机自关闭
[root@localhost ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
#关闭seliunx
[root@localhost ~]# setenforce 0
[root@localhost ~]# vim /etc/sysconfig/selinux
#重启虚拟机
[root@localhost ~]# reboot
安装zabbix server 5.0
zabbix官网地址:https://www.zabbix.com/cn/download
①下载zabbix 5.0版本
#安装源
[root@localhost ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
获取https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
警告:/var/tmp/rpm-tmp.JA6V5m: 头V4 RSA/SHA512 Signature, 密钥 ID a14fe591: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:zabbix-release-5.0-1.el7 ################################# [100%]
[root@localhost ~]# yum repolist
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.163.com
zabbix | 2.9 kB 00:00:00
zabbix-non-supported | 2.9 kB 00:00:00
(1/2): zabbix-non-supported/x86_64/primary_db | 3.7 kB 00:00:00
(2/2): zabbix/x86_64/primary_db | 128 kB 00:00:01
源标识 源名称 状态
base/7/x86_64 CentOS-7 - Base 10,072
extras/7/x86_64 CentOS-7 - Extras 500
updates/7/x86_64 CentOS-7 - Updates 3,187
zabbix/x86_64 Zabbix Official Repository - x86_64 211
zabbix-non-supported/x86_64 Zabbix Official Repository non-supported - x86_64 5
repolist: 13,975
②安装服务端,客户端和web前端
#安装服务端和客户端
[root@localhost ~]# yum install zabbix-server-mysql zabbix-agent
#一直按 “y”
zabbix 5.0 里面的前端要单独装
#安装前端
[root@localhost ~]# yum install centos-release-scl -y
#修改yum文件
[root@localhost ~]# vim /etc/yum.repos.d/zabbix.repo
将zabbix-frontend 的enable修改为1
#安装前端
[root@localhost ~]# yum install zabbix-web-mysql-scl zabbix-nginx-conf-scl -y
③安装mysql
#mysql的专用源
[root@localhost ~]# rpm -ivh https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
获取https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
警告:/var/tmp/rpm-tmp.b8bfJz: 头V3 DSA/SHA1 Signature, 密钥 ID 5072e1f5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:mysql80-community-release-el7-1 ################################# [100%]
[root@localhost ~]# yum -y install yum-utils
已加载插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* centos-sclo-rh: mirrors.163.com
* centos-sclo-sclo: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.163.com
mysql-connectors-community | 2.6 kB 00:00:00
mysql-tools-community | 2.6 kB 00:00:00
mysql80-community | 2.6 kB 00:00:00
(1/3): mysql-connectors-community/x86_64/primary_db | 87 kB 00:00:01
(2/3): mysql-tools-community/x86_64/primary_db | 92 kB 00:00:01
(3/3): mysql80-community/x86_64/primary_db | 188 kB 00:00:01
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
无须任何处理
#修改为mysql57
[root@localhost ~]# yum-config-manager --disable mysql80-community
已加载插件:fastestmirror, langpacks
================================================================== repo: mysql80-community ===================================================================
[mysql80-community]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = http://repo.mysql.com/yum/mysql-8.0-community/el/7/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7/mysql80-community
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = 0
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/mysql80-community/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/mysql80-community/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
hdrdir = /var/cache/yum/x86_64/7/mysql80-community/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = MySQL 8.0 Community Server
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7/mysql80-community
pkgdir = /var/cache/yum/x86_64/7/mysql80-community/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = mysql80-community/x86_64
ui_repoid_vars = releasever,
basearch
username =
[root@localhost ~]# yum-config-manager --enable mysql57-community
已加载插件:fastestmirror, langpacks
================================================================== repo: mysql57-community ===================================================================
[mysql57-community]
async = True
bandwidth = 0
base_persistdir = /var/lib/yum/repos/x86_64/7
baseurl = http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/
cache = 0
cachedir = /var/cache/yum/x86_64/7/mysql57-community
check_config_file_age = True
compare_providers_priority = 80
cost = 1000
deltarpm_metadata_percentage = 100
deltarpm_percentage =
enabled = 1
enablegroups = True
exclude =
failovermethod = priority
ftp_disable_epsv = False
gpgcadir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgcadir
gpgcakey =
gpgcheck = True
gpgdir = /var/lib/yum/repos/x86_64/7/mysql57-community/gpgdir
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
hdrdir = /var/cache/yum/x86_64/7/mysql57-community/headers
http_caching = all
includepkgs =
ip_resolve =
keepalive = True
keepcache = False
mddownloadpolicy = sqlite
mdpolicy = group:small
mediaid =
metadata_expire = 21600
metadata_expire_filter = read-only:present
metalink =
minrate = 0
mirrorlist =
mirrorlist_expire = 86400
name = MySQL 5.7 Community Server
old_base_cache_dir =
password =
persistdir = /var/lib/yum/repos/x86_64/7/mysql57-community
pkgdir = /var/cache/yum/x86_64/7/mysql57-community/packages
proxy = False
proxy_dict =
proxy_password =
proxy_username =
repo_gpgcheck = False
retries = 10
skip_if_unavailable = False
ssl_check_cert_permissions = True
sslcacert =
sslclientcert =
sslclientkey =
sslverify = True
throttle = 0
timeout = 30.0
ui_id = mysql57-community/x86_64
ui_repoid_vars = releasever,
basearch
username =
#安装mysql 服务
[root@localhost ~]# yum install mysql-community-server -y
#开启数据库
[root@localhost ~]# systemctl start mysqld
#设置为开机自启
[root@localhost ~]# systemctl enable mysqld
[root@localhost ~]#
#查看一下数据库服务有没有起来,有3306
[root@localhost ~]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1446/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1099/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1096/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1423/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 2711/sshd: root@pts
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 751/rpcbind
tcp6 0 0 :::22 :::* LISTEN 1099/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1096/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1423/master
tcp6 0 0 ::1:6010 :::* LISTEN 2711/sshd: root@pts
tcp6 0 0 :::3306 :::* LISTEN 4509/mysqld
tcp6 0 0 :::111 :::* LISTEN 751/rpcbind
udp 0 0 0.0.0.0:920 0.0.0.0:* 751/rpcbind
udp 0 0 0.0.0.0:5353 0.0.0.0:* 746/avahi-daemon: r
udp 0 0 0.0.0.0:42677 0.0.0.0:* 746/avahi-daemon: r
udp 0 0 192.168.122.1:53 0.0.0.0:* 1446/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 1446/dnsmasq
udp 0 0 0.0.0.0:111 0.0.0.0:* 751/rpcbind
udp6 0 0 :::920 :::* 751/rpcbind
udp6 0 0 :::111 :::* 751/rpcbind
[root@localhost ~]#
④修改数据库密码和配置
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2021-12-08T08:00:18.049333Z 1 [Note] A temporary password is generated for root@localhost: S+,*tFike8;1
[root@localhost ~]# mysql -uroot -p'S+,*tFike8;1'
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 2
Server version: 5.7.36
Copyright (c) 2000, 2021, 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> ALTER USER'root'@'localhost' IDENTIFIED BY 'xkd187';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#这里报错说我的密码不符合当前的策略要求
原因是:
mysql> SHOW VARIABLES LIKE 'validate_password%';
+--------------------------------------+--------+
| Variable_name | Value |
+--------------------------------------+--------+
| validate_password_check_user_name | OFF |
| validate_password_dictionary_file | |
| validate_password_length | 8 |
| validate_password_mixed_case_count | 1 |
| validate_password_number_count | 1 |
| validate_password_policy | MEDIUM |
| validate_password_special_char_count | 1 |
+--------------------------------------+--------+
7 rows in set (0.01 sec)
mysql>
validate_password_policy 是等级,可以设置密码强度
mysql> ALTER USER 'root'@'localhost' identified by 'XUkd187*';
Query OK, 0 rows affected (0.00 sec)
#创建名字为zabbix的database
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
| zabbix |
+--------------------+
5 rows in set (0.01 sec)
#创建一个user并设hi密码
mysql> create user zabbix@localhost identified by 'Zabbix@187';
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> quit
Bye
⑤导入zabbix初始数据库
#查看一下zabbix安装的时候都有什么
#将zabbix初始数据库导入
[root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-5.0.18/create.sql.gz|mysql -u zabbix -p'Zabbix@187' zabbix
mysql: [Warning] Using a password on the command line interface can be insecure.
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.36 MySQL Community Server (GPL)
Copyright (c) 2000, 2021, 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 zabbix
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> show tables;
+----------------------------+
| Tables_in_zabbix |
+----------------------------+
| acknowledges |
| actions |
| alerts |
| application_discovery |
| application_prototype |
| application_template |
| applications |
| auditlog |
| auditlog_details |
| autoreg_host |
| conditions |
| config |
| config_autoreg_tls |
| corr_condition |
| corr_condition_group |
| corr_condition_tag |
| corr_condition_tagpair |
| corr_condition_tagvalue |
| corr_operation |
| correlation |
| dashboard |
| dashboard_user |
| dashboard_usrgrp |
| dbversion |
| dchecks |
| dhosts |
| drules |
| dservices |
| escalations |
| event_recovery |
| event_suppress |
| event_tag |
| events |
| expressions |
| functions |
| globalmacro |
| globalvars |
| graph_discovery |
| graph_theme |
| graphs |
| graphs_items |
| group_discovery |
| group_prototype |
| history |
| history_log |
| history_str |
| history_text |
| history_uint |
| host_discovery |
| host_inventory |
| host_tag |
| hostmacro |
| hosts |
| hosts_groups |
| hosts_templates |
| housekeeper |
| hstgrp |
| httpstep |
| httpstep_field |
| httpstepitem |
| httptest |
| httptest_field |
| httptestitem |
| icon_map |
| icon_mapping |
| ids |
| images |
| interface |
| interface_discovery |
| interface_snmp |
| item_application_prototype |
| item_condition |
| item_discovery |
| item_preproc |
| item_rtdata |
| items |
| items_applications |
| lld_macro_path |
| lld_override |
| lld_override_condition |
| lld_override_opdiscover |
| lld_override_operation |
| lld_override_ophistory |
| lld_override_opinventory |
| lld_override_opperiod |
| lld_override_opseverity |
| lld_override_opstatus |
| lld_override_optag |
| lld_override_optemplate |
| lld_override_optrends |
| maintenance_tag |
| maintenances |
| maintenances_groups |
| maintenances_hosts |
| maintenances_windows |
| mappings |
| media |
| media_type |
| media_type_message |
| media_type_param |
| module |
| opcommand |
| opcommand_grp |
| opcommand_hst |
| opconditions |
| operations |
| opgroup |
| opinventory |
| opmessage |
| opmessage_grp |
| opmessage_usr |
| optemplate |
| problem |
| problem_tag |
| profiles |
| proxy_autoreg_host |
| proxy_dhistory |
| proxy_history |
| regexps |
| rights |
| screen_user |
| screen_usrgrp |
| screens |
| screens_items |
| scripts |
| service_alarms |
| services |
| services_links |
| services_times |
| sessions |
| slides |
| slideshow_user |
| slideshow_usrgrp |
| slideshows |
| sysmap_element_trigger |
| sysmap_element_url |
| sysmap_shape |
| sysmap_url |
| sysmap_user |
| sysmap_usrgrp |
| sysmaps |
| sysmaps_elements |
| sysmaps_link_triggers |
| sysmaps_links |
| tag_filter |
| task |
| task_acknowledge |
| task_check_now |
| task_close_problem |
| task_data |
| task_remote_command |
| task_remote_command_result |
| task_result |
| timeperiods |
| trends |
| trends_uint |
| trigger_depends |
| trigger_discovery |
| trigger_tag |
| triggers |
| users |
| users_groups |
| usrgrp |
| valuemaps |
| widget |
| widget_field |
+----------------------------+
166 rows in set (0.00 sec)
mysql> quit
Bye
#配置zabbix server 的配置文件的数据库信息
[root@localhost ~]# vim /etc/zabbix/zabbix_server.conf
⑥配置前端php
[root@localhost ~]# cd /etc/opt/rh/rh-php72/
[root@localhost rh-php72]# ls
opt pear pear.conf php.d php-fpm.conf php-fpm.d php.ini pki pm skel sysconfig X11 xdg xinetd.d
[root@localhost rh-php72]# vim php-fpm.d/zabbix.conf
[root@localhost rh-php72]#
⑦修改nginx中zabbix.conf 文件
[root@localhost rh-php72]# cd ..
[root@localhost rh]# ls
rh-nginx116 rh-php72
[root@localhost rh]# cd rh-nginx116/
[root@localhost rh-nginx116]# ls
nginx opt pki pm skel sysconfig X11 xdg xinetd.d
[root@localhost rh-nginx116]# cd nginx/
[root@localhost nginx]# ls
conf.d fastcgi.conf fastcgi_params koi-utf mime.types nginx.conf scgi_params uwsgi_params win-utf
default.d fastcgi.conf.default fastcgi_params.default koi-win mime.types.default nginx.conf.default scgi_params.default uwsgi_params.default
[root@localhost nginx]# cd conf.d/
[root@localhost conf.d]# ls
zabbix.conf
[root@localhost conf.d]# vim zabbix.conf
⑧修改nginx.conf文件
[root@localhost conf.d]# cd ..
[root@localhost nginx]# vim nginx.conf
[root@localhost nginx]# systemctl start zabbix-server.service rh-php72-php-fpm.service rh-nginx116-nginx.service
[root@localhost nginx]# netstat -lntup
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 10646/nginx: master
tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1446/dnsmasq
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1099/sshd
tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1096/cupsd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1423/master
tcp 0 0 127.0.0.1:6010 0.0.0.0:* LISTEN 2711/sshd: root@pts
tcp 0 0 0.0.0.0:10051 0.0.0.0:* LISTEN 10625/zabbix_server
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 10616/php-fpm: mast
tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 751/rpcbind
tcp6 0 0 :::80 :::* LISTEN 10646/nginx: master
tcp6 0 0 :::22 :::* LISTEN 1099/sshd
tcp6 0 0 ::1:631 :::* LISTEN 1096/cupsd
tcp6 0 0 ::1:25 :::* LISTEN 1423/master
tcp6 0 0 ::1:6010 :::* LISTEN 2711/sshd: root@pts
tcp6 0 0 :::10051 :::* LISTEN 10625/zabbix_server
tcp6 0 0 :::3306 :::* LISTEN 4509/mysqld
tcp6 0 0 :::111 :::* LISTEN 751/rpcbind
udp 0 0 0.0.0.0:920 0.0.0.0:* 751/rpcbind
udp 0 0 0.0.0.0:5353 0.0.0.0:* 746/avahi-daemon: r
udp 0 0 0.0.0.0:42677 0.0.0.0:* 746/avahi-daemon: r
udp 0 0 192.168.122.1:53 0.0.0.0:* 1446/dnsmasq
udp 0 0 0.0.0.0:67 0.0.0.0:* 1446/dnsmasq
udp 0 0 0.0.0.0:111 0.0.0.0:* 751/rpcbind
udp6 0 0 :::920 :::* 751/rpcbind
udp6 0 0 :::111 :::* 751/rpcbind
⑨登录zabbix 检查 安装
如果你开始进入是nginx界面,没事他是说看到这个测试页面,说明是正常的,刷新一下就可以;
看下是否都是ok的
密码就是配置 zabbix server 配置文件修改的数据库信息
到这里前端已经安装成功
最后 zabbix后台
初始账号:Admin
密码:zabbix