Centos7.2下yum安装zabbix

环境准备:

[root@xudongmingzuishuai ~]# cat /etc/redhat-release
CentOS Linux release 7.2.1511 (Core)
[root@xudongmingzuishuai ~]# systemctl status firewalld.service   #关闭防火墙
● firewalld.service – firewalld – dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
Active: inactive (dead)
[root@xudongmingzuishuai ~]# getenforce  #检查是否关闭selinux
Disabled
[root@xudongmingzuishuai ~]# hostname -I
10.0.0.202 172.16.1.202

第1章 安装zabbix源

[root@xudongmingzuishuai ~]# rpm -ivh http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
Retrieving http://mirrors.aliyun.com/zabbix/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
warning: /var/tmp/rpm-tmp.de2mvt: Header V4 DSA/SHA1 Signature, key ID 79ea5ed4: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:zabbix-release-3.0-1.el7         ################################# [100%]
[root@xudongmingzuishuai ~]# cd /etc/yum.repos.d/
[root@xudongmingzuishuai yum.repos.d]# ls
CentOS-Base-Aliyun.repo  epel-Aliyun.repo  zabbix.repo

替换zabbix源的下载地址

[root@xudongmingzuishuai yum.repos.d]# sed -i.bak 's#repo.zabbix.com#mirrors.aliyun.com/zabbix#g' zabbix.repo 
 [root@xudongmingzuishuai yum.repos.d]# ls
 CentOS-Base-Aliyun.repo  epel-Aliyun.repo  zabbix.repo  zabbix.repo.bak 

第2章 安装zabbix相关服务

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

安装数据库

yum install -y mariadb-server

启动数据库服务

systemctl start mariadb.service

登录数据库并创建数据库授权用户

mysql
create database zabbix character set utf8;
grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';
flush privileges;

启动web服务

systemctl start httpd.service 

更改zabbix服务配置文件时区

sed -i 's@# php_value date.timezone Europe/Riga@ php_value date.timezone Asia/Shanghai@g' /etc/httpd/conf.d/zabbix.conf
systemctl restart httpd.service 

更改httpd配置文件

echo "ServerName 127.0.0.1:80">>/etc/httpd/conf/httpd.conf
systemctl restart httpd.service 

查看zabbix数据库文件所在的位置

rpm -ql zabbix-server-mysql 
cd /usr/share/doc/zabbix-server-mysql-3.0.10/

导入数据库文件

zcat create.sql.gz|mysql -uzabbix -pzabbix zabbix

编辑zabbix服务配置文件添加登录数据库密码

vi /etc/zabbix/zabbix_server.conf 
DBPassword=zabbix

重启zabbix服务

systemctl start zabbix-server.service
标签:CentosZabbixYum 发布于:2019-11-07 09:19:51