centos7 yum安装配置部署 zabbix4.0

1、添加清华大学软件源:

 将以下内容写入 /etc/yum.repos.d/CentOS-Base.repo

 

 

# CentOS-Base.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[base]
name=CentOS-$releasever - Base
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos/$releasever/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

更新软件包缓存 sudo yum makecache

 

2、下载安装

Install Zabbix repository

rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum clean all

b. Install Zabbix server, frontend, agent

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

 

 

假如上述官网步骤无法安装,(通常是运营商网络环境问题导致,可换一个网络环境),下载清华软件源的rpm包:

wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-server-mysql-4.0.14-1.el7.x86_64.rpm

wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-web-4.0.14-1.el7.noarch.rpm

wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-web-mysql-4.0.14-1.el7.noarch.rpm

wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-agent-4.0.14-1.el7.x86_64.rpm

wget https://mirrors.tuna.tsinghua.edu.cn/zabbix/zabbix/4.0/rhel/7/x86_64/zabbix-get-4.0.14-1.el7.x86_64.rpm

 

yum -y localinstall zabbix-server-mysql-4.0.14-1.el7.x86_64.rpm

yum -y localinstall zabbix-web-4.0.14-1.el7.noarch.rpm

yum -y localinstall zabbix-web-mysql-4.0.14-1.el7.noarch.rpm

yum -y localinstall zabbix-agent-4.0.14-1.el7.x86_64.rpm

yum -y localinstall zabbix-get-4.0.14-1.el7.x86_64.rpm

 

 

3、安装数据库mariadb并配置:

yum install mariadb mariadb-server
systemctl start mariadb   #启动mariadb
systemctl enable mariadb  #设置开机自启动
mysql_secure_installation #设置root密码等相关
mysql -uroot -p           #测试登录

create database zabbix;

create user zabbix@localhost identified by '111111';

grant all on zabbix.* to zabbix@'localhost' identified by '111111';

grant all on zabbix.* to zabbix@'localhost';

在linux shell里面解压缩sql脚本:

gunzip /usr/share/doc/zabbix-server-mysql-4.0.16/create.sql.gz

cp /usr/share/doc/zabbix-server-mysql-4.0.16/create.sql.gz /tmp

chmod 777 /tmp/create.sql

用zabbix用户登入mysql,执行sql脚本:

source /tmp/create.sql

 

vi /etc/zabbix/zabbix_server.conf

修改DBhost为localhost:

### Option: DBHost
# Database host name.
# If set to localhost, socket is used for MySQL.
# If set to empty string, socket is used for PostgreSQL.
#
# Mandatory: no
# Default:
# DBHost=localhost
DBHost=localhost

 

# Option: DBPassword
# Database password.
# Comment this line if no password is used.
#
# Mandatory: no
# Default:
# DBPassword=
DBPassword=111111

 

vi /etc/php.ini

[Date]
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
;date.timezone =
date.timezone = Asia/shanghai

 

4、启动zabbix-server agent和apache :

systemctl start zabbix-server zabbix-agent httpd

关闭selinux和防火墙,否则会无法运行zabbix:

setenforce 0

vi /etc/selinux/config
SELINUX=disabled
systemctl stop firewalld
systemctl disable firewalld

systemctl stop firewalld

 

在浏览器访问 ip/zabbix 即可进入web配置页面

zabbix默认用户名密码  admin / zabbix

一路点击下一步,输入数据库主机、数据库、用户密码点完成即可。

5、添加需要监控的设备(服务器主机、网络设备、ups设备)item监控项、触发器、action、用户媒介。 

posted @ 2020-01-12 20:56  黑剑石清  阅读(466)  评论(0编辑  收藏  举报