Centos安装zabbix5.0

Zabbix5.0安装

一、关闭防火墙

[root@server ~]# systemctl status firewalld.service
[root@server ~]# systemctl stop firewalld.service
[root@server ~]# systemctl disable firewalld.service

二、关闭selinux

[root@server1 ~]# setenforce 0
[root@server1 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config

查看selinux:
[root@server1 ~]# getenforce  

三、卸载Mariadb

[root@mysql mysql]# rpm -qa |grep mariadb
[root@mysql mysql]# yum remove mariadb-libs-5.5.68-1.el7.x86_64

四、配置YUM源

可以配置官方zabbix源或阿里源,三选一

1.官方zabbix源配置
[root@server ~]# rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm

Retrieving https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.6qpCXd: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]

[root@server ~]# yum search zabbix

[root@server ~]# yum clean all
2.阿里zabbix源配置

如果官方zabbix Yum源无法使用,可以配置阿里YUM源来代替
https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/

(1) 安装阿里YUM源
[root@server yum.repos.d]# cp CentOS-Base.repo CentOS-Base.repo.bak
[root@server yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-7.repo

(2) 安装阿里zabbix源
[root@server yum.repos.d]# rpm -ivh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
Retrieving https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.6tu2BA: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-5.0-1.el7         ################################# [100%]

查看zabbix内容:
[root@server yum.repos.d]# rpm -ql zabbix-release
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
/etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
/etc/yum.repos.d/zabbix.repo
/usr/share/doc/zabbix-release-5.0
/usr/share/doc/zabbix-release-5.0/GPL

卸载使用以下命令:
[root@server yum.repos.d]# rpm -qa |grep zabbix-release
zabbix-release-5.0-1.el7.noarch

[root@server yum.repos.d]# rpm -e zabbix-release-5.0-1.el7.noarch

(2) 修改zabbix.repo
http://repo.zabbix.com/zabbix/5.0/rhel/7/$basearch/
对比
https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/

将repo.zabbix.com 替换为 mirrors.aliyun.com/zabbix、

[root@server yum.repos.d]# vi zabbix.repo
:%s/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g
:%s/gpgcheck=1/gpgcheck=0/g

[zabbix-frontend]
enabled=1

清理缓存:
[root@server yum.repos.d]# yum clean all
3.离线配置zabbix源
(1) 配置系统YUM
[root@server ~]# mkdir /opt/yum
[root@server ~]# cp -r /run/media/admin/CentOS\ 7\ x86_64/*  /opt/yum

[root@server ~]# vi /etc/yum.repos.d/CentOS-Base.repo

[CentOS-Base]
baseurl=file:///opt/yum
gpgcheck=0
enabled=1

(2) 下载zabbix rpm包
[root@server ~]# mkdir -p /opt/yum/Zabbix
[root@server ~]# cd /opt/yum/Zabbix
[root@server zabbix]# wget -nd -r -l1 --no-parent https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/
[root@server Zabbix]# wget -nd -r -l1 --no-parent http://repo.mysql.com/yum/mysql-5.7-community/el/7/x86_64/

(3) 生成仓库
createrepo /opt/yum/Zabbix

(4) 配置repo
[root@server Zabbix]# vi /etc/yum.repos.d/zabbix.repo
[zabbix]
name=Zabbix Official Repository - $basearch
baseurl=file:///opt/yum/Zabbix
enabled=1
gpgcheck=0

(5) 清理缓存
[root@server Zabbix]# yum clean all
[root@server Zabbix]# yum makecache

(6) 查看已安装repo
[root@server Zabbix]# yum repolist

Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * centos-sclo-rh: mirrors.163.com
repo id                                                   repo name                                                                status
base                                                      CentOS-7 - Base                                                          4,070
centos-sclo-rh/x86_64                                     CentOS-7 - SCLo rh                                                       7,559
zabbix                                                    Zabbix Official Repository - x86_64                                        167
repolist: 11,796

五、配置时间同步

1.查看时区
[root@server01 ~]# timedatectl status|grep 'Time zone'
       Time zone: Asia/Shanghai (CST, +0800)
2.设置时区
方法一:
[root@server ~]# timedatectl set-timezone Asia/Shanghai

方法二:
[root@server ~]# rm /etc/localtime
[root@server ~]# ln -s  /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
3.设置时间
方法一:
[root@server ~]# timedatectl  set-time "2017-07-31 15:26:00"

方法二:
[root@server ~]# date -s '2017-07-31 15:26:00'
4.配置自动同步时间
(1) 安装NTP
[root@server ~]# yum install ntp

(2) 配置自动同步
[root@server ~]# crontab -e
*/20 * * * * /usr/sbin/ntpdate ntp1.aliyun.com  > /dev/null 2>&1

时区服务器:
#中国
cn.ntp.org.cn
#中国香港
hk.ntp.org.cn
#美国
us.ntp.org.cn

六、安装Mysql

1.安装

Mysql安装提供两种安装方式,RPM安装和YUM安装,二选一

  • RPM包安装Mysql
(1) 下载
https://downloads.mysql.com/archives/get/p/23/file/mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar

(2) 解压
[root@server soft]# tar xvf mysql-5.7.30-1.el7.x86_64.rpm-bundle.tar
mysql-community-common-5.7.30-1.el7.x86_64.rpm
mysql-community-server-5.7.30-1.el7.x86_64.rpm
mysql-community-test-5.7.30-1.el7.x86_64.rpm
mysql-community-client-5.7.30-1.el7.x86_64.rpm
mysql-community-embedded-5.7.30-1.el7.x86_64.rpm
mysql-community-libs-5.7.30-1.el7.x86_64.rpm
mysql-community-devel-5.7.30-1.el7.x86_64.rpm
mysql-community-embedded-compat-5.7.30-1.el7.x86_64.rpm
mysql-community-embedded-devel-5.7.30-1.el7.x86_64.rpm
mysql-community-libs-compat-5.7.30-1.el7.x86_64.rpm

(3) 安装
[root@server soft]# yum install *.rpm
  • YUM源安装Mysql
(1) 下载repo
[root@server ~]# wget https://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

(2) 安装repo
[root@server ~]# rpm -ivh mysql57-community-release-el7-9.noarch.rpm

(3) 安装mysql
[root@server ~]# yum install -y mysql-server
2.启动Mysql
[root@server ~]# systemctl start mysqld
3.设置自动启动
[root@server ~]# systemctl enable mysqld
4.查看Mysql状态
[root@server ~]# systemctl status mysqld
5.添加数据库字符集
[root@server ~]# vi /etc/my.cnf
[mysqld]
character-set-server = utf8
collation-server = utf8_bin
6.重启DB
[root@server ~]# systemctl restart mysqld
7.修改root密码
[root@server ~]# grep 'log-error' /etc/my.cnf
log-error=/var/log/mysqld.log

[root@server ~]# grep 'temporary password' /var/log/mysqld.log
2021-07-29T17:38:03.708304Z 1 [Note] A temporary password is generated for root@localhost: gh4<1pO.a+re

mysql> alter user current_user() identified by 'aA_123456';

七、创建zabbix数据库及用户

1.创建用户
mysql> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)

mysql> show  create database zabbix\G
*************************** 1. row ***************************
       Database: zabbix
Create Database: CREATE DATABASE `zabbix` /*!40100 DEFAULT CHARACTER SET utf8 COLLATE utf8_bin */
1 row in set (0.00 sec)

mysql> create user zabbix@localhost identified by 'aA_123456';
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)
2.修改密码策略

Mysql5.6.6对密码强度进行了加强,引入了validate_password插件,如果密码不符合要求,创建帐号会提示错误:ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

Validate Password Policy Tests Performed
0 or LOW Length
1 or MEDIUM Length; numeric, lowercase/uppercase, and special characters
2 or STRONG Length; numeric, lowercase/uppercase, and special characters; dictionary file
(1) 设置密码策略为低
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.00 sec)

mysql> create user zabbix@'localhost' identified by '1234';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements

mysql> set GLOBAL validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> set GLOBAL validate_password_length=4;
Query OK, 0 rows affected (0.00 sec)

(2) 创建用户
mysql> create user zabbix@'localhost' identified by '1234';
Query OK, 0 rows affected (0.00 sec)

八、安装Zabbix

1.安装zabbix server and agent
[root@server ~]# yum install zabbix-server-mysql zabbix-agent zabbix-get
2.安装zabbix frontend
[root@server ~]# yum-config-manager --enable rhel-server-rhscl-7-rpms

[root@server ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl

--> Finished Dependency Resolution
Error: Package: zabbix-web-deps-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-gd
Error: Package: zabbix-web-mysql-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-mysqlnd
Error: Package: zabbix-web-deps-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-mbstring
Error: Package: zabbix-web-deps-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-fpm
Error: Package: zabbix-web-deps-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-xml
Error: Package: zabbix-web-deps-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72
Error: Package: zabbix-web-deps-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-ldap
Error: Package: zabbix-web-deps-scl-5.0.14-1.el7.noarch (zabbix-frontend)
           Requires: rh-php72-php-bcmath
 You could try using --skip-broken to work around the problem
 You could try running: rpm -Va --nofiles --nodigest

安装rh-php:
(1) 卸载旧的php
[root@server ~]# yum remove php*
(2) 安装rh
[root@server ~]# yum install centos-release-scl-rh
(3) 重新安装前端
[root@server ~]# yum install zabbix-web-mysql-scl zabbix-apache-conf-scl
3.导入初始化数据
[root@server ~]# zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix

如果导数据报以下错误,则zabbix数据库字符集没有设置为utf8:
ERROR 1071 (42000) at line 348: Specified key was too long; max key length is 3072 bytes
解决方法:
mysql> alter database zabbix character set utf8 collate utf8_bin;
4.配置zabbix参数
[root@server ~]# vi /etc/zabbix/zabbix_server.conf
DBPassword=aA_123456
5.配置时区
[root@server ~]# vi /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai

去掉前面的;注释
6.开启zabbix进程
[root@server ~]# systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
[root@server ~]# systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
7.配置zabbix前端
http://192.168.1.135/zabbix/setup.php

zabbix默认用户名及密码:
用户名:Admin
密码:zabbix

image-20210730005620783

image-20210730010346301

image-20210730011205869

image-20210730011245954

image-20210730012427637

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇