TOUVE 发表于 2019-1-24 11:02:31

ZABBIX(一) Centos 7 安装Zabbix 3.5

  一、zabbix简介:

  zabbix(音同 zæbix)是一个基于WEB界面的提供分布式系统监视以及网络监视功能的企业级的开源解决方案。
  zabbix能监视各种网络参数,保证服务器系统的安全运营;并提供灵活的通知机制以让系统管理员快速定位/解决存在的各种问题。
  zabbix由2部分构成,zabbix server与可选组件zabbix agent。
  zabbix server可以通过SNMP,zabbix agent,ping,端口监视等方法提供对远程服务器/网络状态的监视,数据收集等功能,它可以运行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平台上。
  zabbix server可以单独监视远程服务器的服务状态;同时也可以与zabbix agent配合,可以轮询zabbix agent主动接收监视数据(agent方式),同时还可被动接收zabbix agent发送的数据(trapping方式)。另外zabbix server还支持SNMP (v1,v2),可以与SNMP软件(例如:net-snmp)等配合使用
  二、安装操作系统CentOS 7
  网易下载系统源:http://mirrors.163.com/centos/
  本次试验实在虚拟机上安装的Centos 7.2版本的操作系统。由于安装操作系统比较交单,在此不做详细介绍:

http://s1.运维网.com/images/20180630/1530349085443881.png
  1、关闭selinux:(注:关闭selinux功能后,需要重启操作系统)
  vim /etc/sysconfig/selinux
http://s1.运维网.com/images/20180630/1530349430152434.png
  2、关闭防火墙:
  systemctl start firewalld.service       #启动防火墙
  systemctl stop firewalld.service       #关闭防火墙
  systemctl disable firewalld.service   #禁止firewall开机启动
  3、安装YUM源:

  cd /etc/yum.repos.d/
  ls

http://s1.运维网.com/images/20180630/1530349962865887.png
  备份原来的.repo文件
http://s1.运维网.com/images/20180702/1530518815463108.png
  下载新的cent7的repo包文件:

http://s1.运维网.com/images/20180702/1530518900294615.png
  更新yum源:

  yum clean all

  yum makecache

http://s1.运维网.com/images/20180702/1530519220804344.png
  yum repolist

http://s1.运维网.com/images/20180702/1530519583205087.png
  三、安装LAMP服务:
  1、安装mysql

  从最新版本的Linux系统开始,默认的数据库是Mariadb,不是mysql

  在此使用系统自带的 Mariadb数据,使用repos安装,比较简单

  (1)使用yum源安装Mariadb数据库:
  yum install -y mariadb mariadb-server
http://s1.运维网.com/images/20180702/1530520280739893.png
  (2)启动mariadb,以前的服务管理命令还可以用,(例如:service mariadb start)

  systemctl start mariadb
http://s1.运维网.com/images/20180702/1530520405595103.png
  (3)设置开机自启动

  systemctl enable mariad
http://s1.运维网.com/images/20180702/1530521179881802.png
  (4)安全初始化,设置root密码等:

  mysql_secure_installation
http://blog.运维网.com/static/js/ueditor1.4.3/themes/default/images/spacer.gifhttp://s1.运维网.com/images/20180702/1530522587815626.png
http://s1.运维网.com/images/20180702/1530523501714677.png
  (5)测试登录数据库:

  mysql -uroot -ppassw0rd

http://s1.运维网.com/images/20180702/1530523729507818.png
  (6)配置MariaDB的字符集

  vim /etc/my.cnf

  在标签下添加:

  init_connect='SET collation_connection = utf8_unicode_ci'
  init_connect='SET NAMES utf8'
  character-set-server=utf8
  collation-server=utf8_unicode_ci
  skip-character-set-client-handshake
http://s1.运维网.com/images/20180702/1530536127759104.png
  vim /etc/my.cnf.d/client.cnf

  在中添加

  default-character-set=utf8
http://s1.运维网.com/images/20180702/1530536298647336.png
  vim /etc/my.cnf.d/mysql-clients.cnf

  在中添加

  default-character-set=utf8
http://s1.运维网.com/images/20180702/1530536456251955.png
  全部配置完成,重启Mariadb

  systemctl restart mariadb

  2、安装Apache软件:

  (1)使用yum源安装Apache软件:

  yum -y install httpd
http://s1.运维网.com/images/20180702/1530523994589986.png
  (2)启动httpd服务
  systemctl start httpd.service
  (3)添加开机自启动服务
http://s1.运维网.com/images/20180702/1530524153256485.png
  (4)查看服务状态:
  systemctl status httpd.service
http://s1.运维网.com/images/20180702/1530524235139232.png
  3、安装PHP服务
  (1)yum源安装PHP服务

  yum -y install php

http://s1.运维网.com/images/20180702/1530532514282707.png
  (2)安装php-mysql:

  php-mysql是一个用于让PHP程序使用MYSQL数据库的模块。需要安装改模块,使用命令:

  yum -y install php-mysql

http://s1.运维网.com/images/20180702/1530532689491148.png
  (3)重启httpd服务

  systemctl restart httpd

  ps aux | grep httpd

http://s1.运维网.com/images/20180702/1530533061427270.png
  (4)测试Apache能够调用PHP

  安装完成后,PHP会生成配置文件/etc/httpd/conf.d/php.conf,因为该配置文件在/etc/httpd/conf.d目录下,所以它会被Apache所读取。PHP还会生成配置文件/etc/httpd/conf.modules.d/10-php.conf,该配置文件也会被Apache所读取,它的设定让Apache可以加载PHP模块。不过,PHP软件本身的配置文件其实是/etc/php.ini。
  可以测试: 为了测试Apache能不能正常调用PHP,在/var/www/html目录下新建一个phpinfo.php文档,内容如下所示:
         //其中的是PHP程序的语法,phpinfo ();则是PHP程序提供的一个函式库
  cd /etc/www/html

  vim phpinfo.php

http://s1.运维网.com/images/20180702/1530537150830631.png
  浏览器访问:

http://s1.运维网.com/images/20180702/1530537225537242.png
  四、安装Zabbix
  1、zabbix 安装包下载地址:

  https://www.zabbix.com/download_sources
  2、官方文档说明:

  https://www.zabbix.com/documentation/3.4/manual/installation/install_from_package
  3、导入软件安装源:
  rpm -ivh http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm
http://s1.运维网.com/images/20180703/1530602533651899.png
  4、安装zabbix包:

  yum -y install zabbix-server-mysql zabbix-web-mysql
http://s1.运维网.com/images/20180703/1530604558123782.png
  5、给zabbix服务端安装上客服端服务
  yum -y install zabbix-agent
http://s1.运维网.com/images/20180703/1530605362740440.png
  6、初始化数据库

  create database zabbix character set utf8 collate utf8_bin;      #创建数据库;
http://s1.运维网.com/images/20180703/1530606957143388.png
  grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
http://s1.运维网.com/images/20180703/1530607123699965.png
  quit
http://s1.运维网.com/images/20180703/1530607224598880.png
  7、数据库配置

  进入到这个目录:

  cd /usr/share/doc/zabbix-server-mysql-4.0.0/
  ls

http://s1.运维网.com/images/20180703/1530607330976474.png
  运行命令:

  zcat create.sql.gz | mysql -uroot -p zabbix   (输入数据库的密码)
http://s1.运维网.com/images/20180703/1530607703520603.png
  8、启动zabbix server服务
  vim /etc/zabbix/zabbix_server.conf
  DBHost=localhost
  DBName=zabbix
  DBUser=zabbix
  DBPassword=zabbix
  启动zabbix服务,设置开机自启动

  systemctl start zabbix-server
  systemctl enable zabbix-server
http://s1.运维网.com/images/20180703/1530608592146773.png
  9、编辑zabbix前端的PHP配置

  max_execution_time 300
  memory_limit 128M
  post_max_size 16M
  upload_max_filesize 2M
  max_input_time 300
  always_populate_raw_post_data -1
  date.timezone Asia/Shanghai
  10、设置时钟同步

  安装ntpdate服务:yum -y install ntp

http://s1.运维网.com/images/20180703/1530616112991199.png
  配置ntp配置文件

  vim /etc/ntp.conf

  

  ntpdate cn.pool.ntp.org
  11、启动Apache服务

  systemctl start httpd
  systemctl enable httpd
  五、网页登录zabbix进行配置
  1、使用浏览器,输入IP地址,登录zabbix

  http://192.168.40.134/zabbix/setup.php
http://s1.运维网.com/images/20180703/1530616432693167.png
  2、点击下一步,然后检测配置是否正确:

http://s1.运维网.com/images/20180703/1530621356846931.png
  3、然后点击下一步,配置数据库连接:

  用户名:zabbix   密码:zabbix      

http://s1.运维网.com/images/20180703/1530621486873287.png
  4、然后点击下一步,设置zabbix-server地址和端口:

http://s1.运维网.com/images/20180703/1530621631541586.png
  5、查看已配置的信息:

http://s1.运维网.com/images/20180703/1530621670370323.png
  6、zabbix服务安装成功,点击完成:
http://s1.运维网.com/images/20180703/1530621742714818.png
  7、 显示登录界面(默认用户名:Admin   默认密码:zabbix):
http://s1.运维网.com/images/20180703/1530621792224679.png
  六、zabbix语言设置
  1、将语言改为中文

  vim /usr/share/zabbix/include/locales.inc.php
  找到第56行,将false改为true,zabbix 3.4版本以后的 默认支持中文的

http://s1.运维网.com/images/20180704/1530666713465623.png
  Win+R打开运行窗口,输入fonts,回车进入window系统的字体目录,然后找到 微软雅黑-常规字体,复制出来将其文件名修改为msyh.ttf,然后上传到/usr/share/zabbix/fonts

  cd /usr/share/zabbix/fonts/
  ls

http://s1.运维网.com/images/20180704/1530669664238328.png
  上传成功后,编辑文件

  vim /usr/share/zabbix/include/defines.inc.php

  

  define('ZBX_GRAPH_FONT_NAME',         'graphfont'); 改为:define('ZBX_GRAPH_FONT_NAME',         'msyh');
  define('ZBX_FONT_NAME', 'graphfont');   改为:define('ZBX_FONT_NAME', 'msyh');
  编辑完成后,保存退出,然后刷新网页。
  七、zabbix基本设置
  1、页面设置成中文:
  点击usr按钮,然后设置为中文界面:

http://s1.运维网.com/images/20180704/1530671770729043.png
http://s1.运维网.com/images/20180704/1530671808391004.png      更改背景为黑色;
http://s1.运维网.com/images/20180704/1530671897497894.png
  设置完成后,zabbix3.4版本后,显示能够显示整个屏幕
http://s1.运维网.com/images/20180704/1530672011279411.png      

  2、新版本的zabbix,能够对仪表盘进行编辑,对各个模块进行编辑:
http://s1.运维网.com/images/20180704/1530672203122813.png
  

  以上演示了 zabbix server的搭建方法,后继会提供zabbix的一系列配置教程。

  希望能够帮助有需要的朋友,在此欢迎大家 关注评论。




页: [1]
查看完整版本: ZABBIX(一) Centos 7 安装Zabbix 3.5