Zabbix | Centos 7.2 安装 Zabbix 监控程序(一)

  • 内容
  • 相关

安装步骤:

一、配置YUM

二、安装LAMP架构

三、安装zabbix服务

四、初始化zabbix系统


一、配置YUM

1.为了方便获取安装应用,首先配置YUM服务,Centos 默认YUM已安装,下面我们直接配置YUM本地源和网络源即可。

[root@localhost ~]# mount /dev/cdrom /mnt

mount: /dev/sr0 is write-protected, mounting read-only 

2.配置yum网络源;

[root@localhost yum.repos.d]#vi /etc/yum.repos.d/zabbix.repo

#新建一个zabbix.repo YUM源文件,添加如下:

==============zabbix.repo文件================

[zabbix]
name=Zabbix Official Repository - $basearch
#可引用变量$basearh为系统平台类型(x86_64&i386)
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/$basearch/ 
#网络源地址 (镜像站)
enabled=1
#启用为1 禁用为0
gpgcheck=1
#校验为1 禁止校验为0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591
# 这个根据系统版本自动生成,可省略。
[zabbix-non-supported]
name=Zabbix Official Repository non-supported - $basearch
baseurl=http://repo.zabbix.com/non-supported/rhel/7/$basearch/
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
# 这个根据系统版本自动生成,可省略。
gpgcheck=1
[waiwang]
name=waiwang
baseurl=http://mirrors.163.com/centos/7/os/x86_64/
enabled=1
gpgcheck=0
[extras]
name=extras
baseurl=http://mirrors.163.com/centos/7/extras/x86_64/
enabled=1
gpgcheck=0

===================END====================

4.清除YUM缓存文件

[root@localhost ~]# yum clean al

#清除yum缓存

5.创建YUM缓存文件 

[root@localhost ~]# yum makecache

#生成yum缓存

6.[root@localhost ~]# yum  list

#可以查看YUM获取到的文件列表

7.关闭firewallselinux:(vi  /etc/selinux/

[root@localhost ~]#systemctl stop firewalld.service

#停止firewall

[root@localhost ~]#systemctl disable firewalld.service

#禁止firewall开机启动

[root@localhost ~]# vi /etc/selinux/config

#selinux=enforcing  改为 selinux=disabled 即可。

[root@localhost ~]# sestatus

#查看selinux状态

==============截止YUM环境已经准备完毕===========

二、开始安装LAMP架构

1.安装Apache

[root@localhost ~]#yum –y install httpd

[root@localhost ~]#systemctl start httpd.service

#启动apache

[root@localhost ~]#systemctl stop httpd.service

#停止apache

[root@localhost ~]#systemctl restart httpd.service

#重启apache

[root@localhost ~]#systemctl enable httpd.service

#设置apache开机启动

2.安装MariaDB

RHEL 7.0中,已经使用MariaDB替代了MySQL数据库

2.1安装MariaDB

[root@localhost ~]#yum –y install mariadb mariadb-server

[root@localhost ~]#systemctl start mariadb.service

#启动MariaDB

[root@localhost ~]#systemctl stop mariadb.service

#停止MariaDB

[root@localhost ~]#systemctl restart mariadb.service

#重启MariaDB

[root@localhost ~]#systemctl enable mariadb.service

#设置开机启动

3.安装PHP

[root@localhost ~]#yum -y install php

4.安装PHP组件,使PHP支持 MariaDB

[root@localhost ~]#yum –y install php-mysql php-gd libjpeg*  php-ldap php-odbc php-pear php-xml php-xmlrpc php-mhash

[root@localhost ~]#systemctl restart mariadb.service

#重启MariaDB

[root@localhost ~]#systemctl restart httpd.service

#重启apache 

5.重新启动服务

[root@localhost ~]#systemctl restart mariadb.service

#重启MariaDB

[root@localhost ~]#systemctl restart httpd.service

#重启apache

6.登录http://localhost或者自己设置的IP地址  测试httpd服务是否正常。

==============LAMP架构已经搭建完毕=============

三、zabbix服务的安装和配置

1安装存储库配置文件

[root@localhost ~]#rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm

2.安装zabbix程序

[root@localhost ~]#yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent

2.1在安装zabbix的时候报错(红色是执行的语句),如下:

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

--> Finished Dependency Resolution

Error: Package: zabbix-web-3.4.7-1.el7.noarch (zabbix)

           Requires: php-bcmath

Error: Package: zabbix-web-3.4.7-1.el7.noarch (zabbix)

           Requires: php-mbstring

2.2这两个模块的yum源比较少,在网上发现163yum源包含它们

[root@localhost yum.repos.d]#vi /etc/yum.repos.d/Centos7-Base-163.repo

#新建一个Centos7-Base-163.repo YUM源文件,添加如下:

============ Centos7-Base-163.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 - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
#baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
baseurl=http://mirrors.163.com/centos/7/os/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
 
#released updates
[updates]
name=CentOS-$releasever - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
#baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
baseurl=http://mirrors.163.com/centos/7/updates/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
#baseurl=http://mirrors.163.com/centos/$releasever/extras/$basearch/
baseurl=http://mirrors.163.com/centos/7/extras/x86_64/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
 
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - 163.com
#baseurl=http://mirrors.163.com/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

===================END====================

2.3再次尝试安装即可。

[root@localhost ~]#rpm -ql zabbix-server-mysql

#验证安装文件

/etc/logrotate.d/zabbix-server

/etc/zabbix/zabbix_server.conf

/usr/lib/systemd/system/zabbix-server.service

/usr/lib/tmpfiles.d/zabbix-server.conf

………………………..

3.初始化mariadb数据库,创建zabbix数据库及其用户

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

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

mysql -uroot -e "flush privileges;"

4.导入zabbix初始模式和数据

[root@localhost ~]#zcat /usr/share/doc/zabbix-server-mysql-3.2.1/create.sql.gz | mysql -uroot zabbix 

[root@localhost ~]#mysql -u root

#验证数据是否导入成功

MariaDB [zabbix]>use zabbix;

MariaDB [zabbix]> show tables;

…………….

| acknowledges |

| actions |

| alerts |

………………….

5.配置zabbix配置文件,修改数据库密码为zabbix

[root@localhost ~]#vi /etc/zabbix/zabbix_server.conf

DBPassword=zabbix

6.配置Http配置文件,修改时区为亚洲上海

[root@localhost ~]# vi /etc/httpd/conf.d/zabbix.conf

php_value date.timezone Asia/Shanghai

7.启动zabbix-server,并设置开机自启

[root@localhost ~]#systemctl start zabbix-server

[root@localhost ~]#systemctl enable zabbix-server

注意:

①如果zabbixserver无法启动,则需要安装trousers支持包。
[root@localhost ~]#yum –y install trousers
②如果报pid错误
需要做软连接/var/run > /run

[root@localhost ~]#ln -s /var/run /run

8.启动http,并设置开机自启

[root@localhost ~]#systemctl start httpd

[root@localhost ~]#systemctl enable httpd 

9.启动zabbix-agent,并设置开机自启

[root@localhost ~]#systemctl start zabbix-agent

[root@localhost ~]#systemctl enable zabbix-agent 

四、初始化zabbix系统

1.使用IE登陆zabbix图形界面进行设置

地址:http://IP地址/zabbix/

2.在安装的过程中输入数据库名,账户名和密码都为zabbix

3.安装完成后,网页登录的信息为账户:admin   密码:zabbix

 您阅读这篇文章共花了:

上一篇:Linux | linux 7下永久添加静态路由的方法

下一篇:Zabbix | 修改界面语言为中文(二)

本文标签:    

版权声明:本文依据CC-BY-NC-SA 3.0协议发布,若无特殊注明,本文皆为《fishyoung》原创,转载请保留文章出处。

本文链接:Zabbix | Centos 7.2 安装 Zabbix 监控程序(一) - http://www.fishyoung.com/post-220.html