Zabbix 3.4 在CentOS 7.2 上安装详细步骤
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Zabbix 3.4 在CentOS 7.2 上安装详细步骤相关的知识,希望对你有一定的参考价值。
一、环境准备
操作系统: [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) 修改主机名: [[email protected] ~]# hostnamectl set-hostname zabbix-server [[email protected] ~]# logout 配置hosts: [[email protected] ~]# cat >> /etc/hosts <<EOF 10.10.172.235 zabbix-server EOF 服务器IP: [[email protected] ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000 link/ether 00:0c:29:d6:33:8f brd ff:ff:ff:ff:ff:ff inet 10.10.172.235/24 brd 10.10.172.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::20c:29ff:fed6:338f/64 scope link valid_lft forever preferred_lft forever 关闭防火墙: [[email protected] ~]# systemctl stop firewalld [[email protected] ~]# systemctl disable firewalld Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service. Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service. 关闭selinux: [[email protected] ~]# getenforce Disabled [[email protected] ~]# cat /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=disabled # SELINUXTYPE= can take one of three two values: # targeted - Targeted processes are protected, # minimum - Modification of targeted policy. Only selected processes are protected. # mls - Multi Level Security protection. SELINUXTYPE=targeted 解决yum 旧版本的GPG keys 问题 [[email protected] ~]# rpm --import /etc/pki/rpm-gpg/RPM*
二、安装步骤
1、安装zabbix源
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm [[email protected] ~]# yum clean all [[email protected] ~]# yum makecache
2、安装zabbix server
[[email protected] ~]# yum install -y zabbix-server-mysql zabbix-web-mysql 安装过程省略...... Installed: zabbix-server-mysql.x86_64 0:3.4.11-1.el7 zabbix-web-mysql.noarch 0:3.4.11-1.el7 Dependency Installed: OpenIPMI-libs.x86_64 0:2.0.23-2.el7 OpenIPMI-modalias.x86_64 0:2.0.23-2.el7 dejavu-fonts-common.noarch 0:2.33-6.el7 dejavu-sans-fonts.noarch 0:2.33-6.el7 fping.x86_64 0:3.10-1.el7 httpd.x86_64 0:2.4.6-80.el7.centos httpd-tools.x86_64 0:2.4.6-80.el7.centos iksemel.x86_64 0:1.4-2.el7.centos libXpm.x86_64 0:3.5.12-1.el7 libevent.x86_64 0:2.0.21-4.el7 libtool-ltdl.x86_64 0:2.4.2-22.el7_3 libxslt.x86_64 0:1.1.28-5.el7 libzip.x86_64 0:0.10.1-8.el7 mailcap.noarch 0:2.1.41-2.el7 net-snmp-libs.x86_64 1:5.7.2-33.el7_5.2 php.x86_64 0:5.4.16-45.el7 php-bcmath.x86_64 0:5.4.16-45.el7 php-cli.x86_64 0:5.4.16-45.el7 php-common.x86_64 0:5.4.16-45.el7 php-gd.x86_64 0:5.4.16-45.el7 php-ldap.x86_64 0:5.4.16-45.el7 php-mbstring.x86_64 0:5.4.16-45.el7 php-mysql.x86_64 0:5.4.16-45.el7 php-pdo.x86_64 0:5.4.16-45.el7 php-xml.x86_64 0:5.4.16-45.el7 t1lib.x86_64 0:5.1.2-14.el7 unixODBC.x86_64 0:2.3.1-11.el7 zabbix-web.noarch 0:3.4.11-1.el7 Dependency Updated: openssl.x86_64 1:1.0.2k-12.el7 openssl-libs.x86_64 1:1.0.2k-12.el7 Complete!
3、安装启动 mariadb数据库
基于YUM安装Mariadb:
[[email protected] ~]# yum install -y mariadb-server [[email protected] ~]# systemctl start mariadb.service
基于YUM安装MySQL:
1).安装mysql社区版官方源 wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm rpm -ivh mysql-community-release-el7-5.noarch.rpm 2).查看可以安装的mysql版本 yum repolist enabled|grep mysql mysql-connectors-community/x86_64 MySQL Connectors Community 24 mysql-tools-community/x86_64 MySQL Tools Community 38 mysql56-community/x86_64 MySQL 5.6 Community Server 289 3).安装 yum install -y mysql-community-server 4).启动mysql systemctl enable mysqld systemctl start mysqld 5).尝试进入mysql mysql -uroot -p 密码为空
4、创建数据库并分配权限
[[email protected] ~]# mysql -e 'create database zabbix character set utf8 collate utf8_bin;' [[email protected] ~]# mysql -e 'grant all privileges on zabbix.* to [email protected] identified by "zabbix";'
5、建立zabbix相关库表结构并导入数据
[[email protected] ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.11/create.sql.gz | mysql -uzabbix -pzabbix zabbix
6、配置zabbix server 连接mysql数据库
[[email protected] ~]# sed -i.ori '126a DBPassword=zabbix' /etc/zabbix/zabbix_server.conf [[email protected] ~]# grep -Ev "#|^$" /etc/zabbix/zabbix_server.conf LogFile=/var/log/zabbix/zabbix_server.log LogFileSize=0 PidFile=/var/run/zabbix/zabbix_server.pid SocketDir=/var/run/zabbix DBName=zabbix DBUser=zabbix DBPassword=zabbix SNMPTrapperFile=/var/log/snmptrap/snmptrap.log Timeout=4 AlertScriptsPath=/usr/lib/zabbix/alertscripts ExternalScripts=/usr/lib/zabbix/externalscripts LogSlowQueries=3000
7、修改zabbix的时区
[[email protected] ~]# sed -i.ori '18a php_value date.timezone Asia/Shanghai' /etc/httpd/conf.d/zabbix.conf
8、解决中文乱码
[[email protected] ~]# yum -y install wqy-microhei-fonts [[email protected] ~]# cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf cp: overwrite ‘/usr/share/fonts/dejavu/DejaVuSans.ttf’? y 或者从C:WindowsFonts下拷贝字体到/usr/share/fonts/dejavu/之下,并替换DejaVuSans.ttf
9、设置开机自启动
[[email protected] ~]# systemctl enable mariadb.service [[email protected] ~]# systemctl enable httpd.service [[email protected] ~]# systemctl enable zabbix-server.service
10、启动服务
[[email protected] ~]# systemctl start zabbix-server [[email protected] ~]# systemctl start httpd
11、安装zabbix agent
[[email protected] ~]# yum install -y zabbix-agent
12、在agent上配置上server ip
[[email protected] ~]# sed -i.ori 's#Server=127.0.0.1#Server=10.10.172.235#' /etc/zabbix/zabbix_agentd.conf [[email protected] ~]# grep -Ev "#|^$" /etc/zabbix/zabbix_agentd.conf PidFile=/var/run/zabbix/zabbix_agentd.pid LogFile=/var/log/zabbix/zabbix_agentd.log LogFileSize=0 Server=10.10.172.235 ServerActive=127.0.0.1 Hostname=Zabbix server Include=/etc/zabbix/zabbix_agentd.d/*.conf
13、agent设置开机启动
[[email protected] ~]# systemctl enable zabbix-agent.service
14、开启agent
[[email protected] ~]# systemctl start zabbix-agent.service
三、访问web
http://10.10.172.235/zabbix/setup.php
点击下一步
以上检测项,哪些有问题可根据提示信息进行解决,所有项目都OK 点击下一步
选择mysql数据库,输入密码即可
默认即可,点击下一步
安装清单汇总,点击下一步
点击Finish就进入zabbix登录页面了,默认的用户名为Admin,密码为zabbix.
zabbix GUI主页-->Configuration ---->Hosts,点击Zabbix server,修改可见名称和 agent ip
更新并启用即可。
Monitoring-->Graphs-->主机(10.10.172.235)-->Granph(Memory usage)
到此为止zabbix安装配置成功。
以上是关于Zabbix 3.4 在CentOS 7.2 上安装详细步骤的主要内容,如果未能解决你的问题,请参考以下文章
zabbix 3.0.7 for Centos 7.2 安装