centos7.2用rpm包安装zabbix-3.2.4

centos7.2  安装 zabbix3.2.x

查看系统版本

cat /etc/redhat-release

CentOS Linux release 7.2.1511 (Core)

查看内核版本

uname -r

3.10.0-327.el7.x86_64

关闭selinux

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config

setenforce 0

关闭防火墙

systemctl stop firewalld.service

systemctl disable firewalld.service

如果不关闭防火墙需要添加相应的端口,如添加80端口:

firewall-cmd --permanent --add-port={80/tcp,10051/tcp}  添加80端口和10051端口

firewall-cmd --reload                                   重载防火墙

到zabbix的官网下载相应的rpm包  官网地址如下:

http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/

本次实验所需要的包如下:如果有更高的版本,把对应的rpm包更换即可 官网:https://www.zabbix.com/download

Zabbix Packages这个是rpm包

Zabbix Sources  这个是源码包

zabbix-release-3.2-1.el7.noarch.rpm

zabbix-agent-3.2.4-1.el7.x86_64.rpm

zabbix-get-3.2.4-1.el7.x86_64.rpm

zabbix-sender-3.2.4-1.el7.x86_64.rpm

zabbix-proxy-mysql-3.2.4-1.el7.x86_64.rpm

zabbix-server-mysql-3.2.4-2.el7.x86_64.rpm

zabbix-web-3.2.4-1.el7.noarch.rpm

zabbix-web-mysql-3.2.4-1.el7.noarch.rpm

时间同步

yum -y install ntp && ntpdate 1.cn.pool.ntp.org

centos7自带了mariadb-libs  需要卸载它

rpm -qa | grep maraidb

rpm -e --nodeps mariadb-libs

安装LAMP环境   mariadb   httpd   php:

yum -y install mariadb mariadb-server httpd php  

yum -y localinstall *.rpm   安装所有的rpm包

rpm -qa | grep zabbix       查看已安装了那些包

配置LAMP(这里是为了最后zabbix登录web页面不报错,更改时区,内存大小等):

sed -i "s/max_execution_time = 30/max_execution_time = 300/" /etc/php.ini

sed -i "s/post_max_size = 8M/post_max_size = 32M/" /etc/php.ini

sed -i "s/max_input_time = 60/max_input_time = 300/" /etc/php.ini

修改/etc/httpd/conf.d/zabbix.conf,把时区改为亚洲/上海

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

启动数据库,登录数据库 设置数据库密码为123456  并刷新权限

systemctl start  mariadb.service

mysql

set password = password ('123456');

flush privileges;

\q

在Linux命令行 创建zabbix数据库 并设置权限(这一步也可以在上一步登录mysql的时候操作):

mysql -uroot -p123456 -e "create database zabbix character set utf8 collate utf8_bin;"

mysql -uroot -p123456 -e "grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix';"

mysql -uroot -p123456 -e "flush privileges;"

导入zabbix数据库

cd /usr/share/doc/zabbix-server-mysql-3.2.4/

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

启动httpd和mysql,并设置开机启动

systemctl restart mariadb.service

systemctl restart httpd.service

systemctl enable mariadb.service

systemctl enable httpd.service

配置 zabbix_server:

配置zabix_server.conf  zabbix_server.conf中 DBName=zabbix,DBUser=zabbix都是默认的不用更改 也可以vim /etc/zabbix/zabbix_server.conf进去更改  查看

sed -i 's@# DBPassword=@DBPassword=zabbix@g' /etc/zabbix/zabbix_server.conf

sed -i 's@# DBHost=localhost@DBHost=localhost@g' /etc/zabbix/zabbix_server.conf

grep -n '^'[a-Z] /etc/zabbix/zabbix_server.conf   #查看a-Z开头的配置文件

启动zabbix_server并设置开机启动:

systemctl start zabbix-server  

遇到问题如下:

Job for zabbix-server.service failed because the control process exited with error code. See "systemctl status zabbix-server.service" and "journalctl -xe" for details.

解决方法:

systemctl status zabbix-server.service

看到这么一句话

Process: 19635 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=1/FAILURE)

指定server的配置文件启动(因为我是rpm包安装的,所以启动方法如下):

/usr/sbin/zabbix_server -c /etc/zabbix/zabbix_server.conf

看到问题如下:

zabbix_server [19699]: unknown parameter "DBPassowrd" in config file "/etc/zabbix/zabbix_server.conf", line 115

我们发现配置文件里面DBPassowrd 出错了  进去更改一下

如果不知道zabbix_server.conf配置文件在哪里,可以这样做:

find / -name 'zabbix_server.conf'

重启zabbix_server

systemctl restart zabbix-server.service

systemctl status zabbix-server.service

看到  Active: active (running)    说明启动成功

还可以查看一下端口

ss -antlup | egrep '10050|10051'

==================================================================

安装zabbix_agent(在新的Linux机器上安装zabbix_agent)

如果是zabbix_server端安装zabbix_agent那么就不需要再次关闭selinux  安装zabbix源  如果是另一台Linux上就需要关闭selinux 安装zabbix源  

关闭selinux:

sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config

setenforce 0

关闭防火墙

systemctl stop firewalld.service

systemctl disable firewalld.service

如果不关闭防火墙需要添加zabbix_agent的10050端口允许通过

firewall-cmd --permanent --add-port=10050/tcp

firewall-cmd --reload

安装zabbix软件源

http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

官网其他rpm包地址(有需要可自行下载)

http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/

安装zabbix-agent

yum -y install zabbix-sender  zabbix-agent          #zabbix

查看已安装zabbix-agent版本

rpm -qa | grep zabbix-agent

zabbix-agent-3.2.4-1.el7.x86_64

配置zabbix-agent

修改zabbix-agentd.conf  让他指向zabbix_server端

sed -i "s/Server=127.0.0.1/Server=192.168.1.101/" /etc/zabbix/zabbix_agentd.conf

sed -i "s/ServerActive=127.0.0.1/ServerActive=192.168.1.101/" /etc/zabbix/zabbix_agentd.conf      (主动模式)

sed -i "s/Hostname=Zabbix server/Hostname=192.168.1.105/" /etc/zabbix/zabbix_agentd.conf

也可以vim /etc/zabbix/zabbix_agentd.conf进去修改   ip地址根据自己环境更改一下

启动并设置开机自启

systemctl start zabbix-agent.service

systemctl enable zabbix-agent.service

进入web页面:

http://192.168.1.109/zabbix/setup.php

接下去的每一步都很简单 需要注意的是安装lanmp环境时候数据库的密码,在web界面填写的时候要一致,依次下一步即可。

猜你喜欢

转载自blog.51cto.com/12262646/2108445