xiguaqq20 发表于 2017-12-31 18:36:18

Centos7X部署Zabbix监控

  一:yum安装LAMP环境
  # yum install httpd httpd-devel httpd-tools mariadb-server mariadb-devel php-mysql php-gd libjpeg* php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
  yum -y install php* --skip-broken
  yum -y install curl curl-devel net-snmp net-snmp-devel perl-DBI gcc   安装zabbix环境需求插件
  二:编译zabbix-server
  #useradd -M -s /sbin/nologin zabbix
#tar zxvf zabbix-3.2.7.tar.gz -C /usr/src/
  root@localhost ~]#cd /usr/src/zabbix-3.2.7
#./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-proxy --with-mysql --enable-net-snmp --with-libcurl
  --prefix----> 指定zabbix安装目录
  --enable-server----> 支持zabbix服务器
  --enable-agent----> 支持zabbix代理
  --enable-proxy----> 支持zabbix代理服务器
  --with-libcurl----> 使用curl包
  --with-net-snmp----> 使用net-snmp软件包,选择性地指定路径NET-SNMP配置
  --with-mysql=/usr/bin/mysql_con
#make
# make install
  注:如出现configure: error: MySQL library not found错误,是因为缺少mariadb-devel该软件包,yum install mariadb-devel进行安装
# ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/
# cd /usr/local/zabbix/etc/
# cp zabbix_server.conf zabbix_server.conf.back
# vim zabbix_server.conf
  DBHost=localhost
  DBName=zabbixdb
  DBUser=xiaoyu
  DBPassword=123456
  DBPort=3306
# systemctl start mariadb
  MariaDB [(none)]> create database zabbixdb
  Query OK, 1 row affected (0.00 sec)
  MariaDB [(none)]>grant all on zabbixdb.* to xiaoyu@'localhost'>
  Query OK, 0 rows affected (0.00 sec)
  MariaDB [(none)]> flush privileges;
  Query OK, 0 rows affected (0.00 sec)
#cd /usr/src/zabbix-3.2.7/database/mysql/
# ls
  data.sql【初始脚本】images.sql【图片库】schema.sql【表结构】
# mysql -uxiaoyu -p123456 zabbixdb < schema.sql
# mysql -uxiaoyu -p123456 zabbixdb < images.sql
# mysql -uxiaoyu -p123456 zabbixdb < data.sql
# cp -a /usr/src/zabbix-3.2.7/frontends/php/*/var/www/html/    #将zabbix的php安装文件导入到http的发布目录
# cp /etc/php.ini    /etc/php.ini.back
# sed -i '/max_execution_time/s/30/600/g;/max_input_time/s/60/600/g;/memory_limit/s/128M/256M/g;/post_max_size/s/8M/32M/g;/upload_max_filesize/s/2M/16M/g;s/\;date.timezone.*/date.timezone \=\Asia\/Shanghai/g' /etc/php.ini
  PHP配置参数
  

max_execution_time = 600    #限制执行时间  
max_input_time = 600   #设置接受数据的最多时间
  
memory_limit = 256M   #设置每个脚本所占用的内存
  
post_max_size = 32M    #允许POST的数据最大字节长度,默认为8M
  
upload_max_filesize = 16M   #上传文件的大小限制
  
date.timezone = Asia/Shanghai   #时区设置
  

  创建&授权zabbix启动配置文件
# cd /usr/src/zabbix-3.2.7/misc/init.d/tru64/
# cp zabbix_* /etc/init.d/
# chmod o+x -R /etc/init.d/
# /etc/init.d/zabbix_server start
  Zabbix server started.
# netstat -anput | grep zabbix
  tcp      0      0 0.0.0.0:10051         0.0.0.0:*               LISTEN      19278/zabbix_server
# systemctl start httpd




需修创建zabbix.conf.php文件,执行如下命令,或者单击“Download the configuration file”下载zabbix.conf.php文件,并将该文件上传至/var/www/html/conf/,并设置可写权限,刷新WEB页面,zabbix.conf.php内容代码如下,最后单击Finish即可:




  部署agent被控端(本身已安装agent,直接配置即可)
# cd /usr/local/zabbix/etc/
# ls
  zabbix_agentd.conf    zabbix_proxy.conf    zabbix_server.conf       zabbix_server.conf.d
  zabbix_agentd.conf.dzabbix_proxy.conf.dzabbix_server.conf.back
# vim zabbix_agentd.conf
  LogFile=/tmp/zabbix_agentd.log
  Server=192.168.2.129
  ServerActive=192.168.2.129
  Hostname =192.168.2.129
# /etc/init.d/zabbix_agentd start
  Zabbix agent started.
# netstat -anput | grep zabbix_agent
  tcp      0      0 0.0.0.0:10050         0.0.0.0:*               LISTEN      23939/zabbix_agentd



(1)         创建发现Action
  Zabbix发现规则创建完毕,客户端Agent安装完后,被发现的IP主机不会自动添加至Zabbix监控列表,需要添加发现动作,添加方法如下:
  Configurationà Actions à Event source(选择Discovery) à Create action
  添加规则时,系统默认存在一条发现规则,可以新建规则,也可以编辑默认规则,如图



  上传简体字,防止出现乱码

# cd /var/www/html/fonts
# mv STXIHEI.TTF DejaVuSans.ttf
页: [1]
查看完整版本: Centos7X部署Zabbix监控