设为首页 收藏本站
查看: 1305|回复: 0

[经验分享] CentOS 6.3 配置 zabbix

[复制链接]

尚未签到

发表于 2019-1-22 10:11:58 | 显示全部楼层 |阅读模式
  一 服务端配置
1.配置前先关闭iptables和SELINUX,避免安装过程中报错
  [root@localhost tw]# service iptables stop
iptables: Flushing firewall rules: [  OK  ]
iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Unloading modules: [  OK  ]
[root@localhost tw]# chkconfig iptables off
[root@localhost tw]# getenforce
Disabled
  
  2.安装LAMP环境

  [root@localhost tw]# yum install -y httpd mysql mysql-server mysql-devel php php-mysql php-common php-mbstring php-gd php-odbc php-xml php-pear
  

  3.下载zabbix-2.0.6.tar.gz
  [root@localhost tw]# wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gz/download
  

  4.安装zabbix所需的组件(server,agent)
  [root@localhost tw]# yum install -y curl curl-devel net-snmp net-snmp-devel perl-DBI
  

  5.创建用户账号(server,agent)

  [root@localhost tw]#useradd zabbix
  [root@localhost tw]#usermod -s /sbin/nologin zabbix
  

  6.创建zabbix数据库并导入zabbix数据库(server)
  [root@localhost tw]#tar zxf zabbix-2.0.6.tar.gz
  [root@localhost tw]#mysqladmin -u root password 123456
  [root@localhost tw] mysql -p123456
mysql> create database zabbix;
mysql> grant all on zabbix.* to zabbix@localhost identified by '123456';
mysql> use zabbix;
mysql> source /tw/zabbix-2.0.6/database/mysql/schema.sql
mysql> source /tw/zabbix-2.0.6/database/mysql/images.sql
mysql> source /tw/zabbix-2.0.6/database/mysql/data.sql
mysql> exit
  

  7.编译安装,如果是客户端安装选择--enable-agent就行了。
  [root@localhost tw]#cd zabbix-2.0.6
  [root@localhost zabbix-2.0.6]# ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
  

  8.编辑配置文件
  [root@localhost zabbix-2.0.6]#cd /usr/local/etc
  [root@localhost zabbix-2.0.6]#[size=1em] cp zabbix_server.conf zabbix_server.conf.bak
  [root@localhost etc]# cp zabbix_agentd.conf  zabbix_agentd.conf.bak
  [root@localhost etc]# more zabbix_server.conf #服务端的配置
LogFile=/var/log/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=123456
[root@localhost etc]# more zabbix_agentd.conf #客户端配置
LogFile=/tmp/zabbix_agentd.log
Server=127.0.0.1
UnsafeUserParameters=1
[root@localhost etc]# touch /var/log/zabbix_server.log
[root@localhost etc]# touch /var/log/zabbix_agentd.log
[root@localhost etc]# chmod 777 /var/log/zabbix_*
  

  9.启动服务(server,agent)
  [root@localhost etc]cd /tw/zabbix-2.0.6
  [root@localhost zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_server /etc/init.d/
[root@localhost zabbix-2.0.6]# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
[root@localhost zabbix-2.0.6]# chmod +x /etc/init.d/zabbix_*
添加服务
[root@localhost zabbix-2.0.6]# chkconfig --add zabbix_server
[root@localhost zabbix-2.0.6]# chkconfig --add zabbix_agentd
设置服务器开机自动启动
  注:执行chkconfig时如出现zabbix_server 服务不支持 chkconfig,编辑zabbix_server和zabbix_agentd中开头添加以下内容即可(#chkconfig:345 61 61)
  [size=1em][root@localhost zabbix-2.0.6]# chkconfig zabbix_server on
[size=1em][root@localhost zabbix-2.0.6]# chkconfig zabbix_agentd on
[size=1em][root@localhost zabbix-2.0.6]# /etc/init.d/zabbix_server start
[size=1em]Zabbix server started.
[size=1em][root@localhost zabbix-2.0.6]# /etc/init.d/zabbix_agentd start
[root@localhost zabbix-2.0.6][size=1em]#[size=1em] ps -ef |grep zabbix
[size=1em]zabbix    1803     1  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
[size=1em]zabbix    1805  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
[size=1em]zabbix    1806  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
[size=1em]zabbix    1807  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
[size=1em]zabbix    1808  1803  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_agentd
[size=1em]zabbix    1814     1  0 08:21 ?        00:00:00 /usr/local/sbin/zabbix_server
[size=1em]root      2043  2006  0 08:23 pts/0    00:00:00 grep zabbix
[size=1em][root@localhost zabbix-2.0.6]# netstat -lantp |grep 10050
[size=1em]tcp        0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      1803/zabbix_agentd
[size=1em][root@localhost zabbix-2.0.6]#netstat -lantp |grep 10051
[size=1em]tcp        0      0 0.0.0.0:10051               0.0.0.0:*                   LISTEN      2308/zabbix_server
  

  

  10.安装zabbix web界面(httpd)
  复制php文件,zabbix的终端程序是用php写的,因此需要一个支持php脚本解析的web服务器。然后将frontends/php下面的php文件拷贝到web服务器html文件目录下面。
  [root@localhost zabbix-2.0.6]#cp -r frontends/php /var/www/html/zabbix
  [root@localhost zabbix-2.0.6]#/etc/init.d/httpd restart #启动apache服务
  

  

  

  

  

  11.安装zabbix web界面(nginx)
  1.安装php
  yum install -y php php-mysql php-gd libjpeg* php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-mcrypt php-bcmath php-mhash libmcrypt libmcrypt-devel php-fpm php-pecl*

  2.安装nginx

  [root@localhost]#wget http://nginx.org/download/nginx-1.9.9.tar.gz
  [root@localhost]#tar zxf nginx-1.9.9.tar.gz
  [root@localhost]#cd nginx-1.9.9
  [root@localhost nginx-1.9.9]#./configure --user=www --group=www --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --error-log-path=/data/logs/nginx/error.log --http-log-path=/data/logs/nginx/access.log
  [root@localhost nginx-1.9.9]#make && make install
  3.配置nginx参数(修改成下列内容支持PHP)
  [root@localhost zabbix-2.0.6]#cp -r frontends/php /usr/local/nginx/html/zabbix
  [root@localhost zabbix-2.0.6]#vi /usr/local/nginx/conf/nginx.conf
  server {
  listen       88;
  server_name  127.0.0.1;
  

  #charset koi8-r;
  

  #access_log  logs/host.access.log  main;
  

  location / {
  root   html/zabbix;
  index  index.php index.htm index.html;
  }
  

  #error_page  404              /404.html;
  

  # redirect server error pages to the static page /50x.html
  #
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
  root   html;
  }
  

  # proxy the PHP scripts to Apache listening on 127.0.0.1:80
  #
  #location ~ \.php$ {
  #    proxy_pass   http://127.0.0.1;
  #}
  

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  #
  location ~ \.php$ {
  root           html/zabbix;
  fastcgi_pass   127.0.0.1:9000;
  fastcgi_index  index.php;
  fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
  include        fastcgi_params;
  }
  4.启动
  [root@localhost zabbix-2.0.6]#chown -R /usr/local/nginx
  [root@localhost zabbix-2.0.6]#/usr/local/nginx/sbin/nginx           //启动nginx
  [root@localhost zabbix-2.0.6]#/etc/init.d/php-fpm start          //启动php
  

  11.修改PHP参数
  [root@localhost zabbix-2.0.6]# vi /etc/php.ini
  [Date]
  ; Defines the default timezone used by the date functions
; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone
date.timezone = Asia/Shanghai    #修改一下时区
[root@localhost zabbix-2.0.6]# /etc/init.d/httpd restart
  在浏览器里输入localhost/zabbix出现zabbix安装界面点击next,下一步出现PHP bacmath  no   Fail错误
  [root@localhost zabbix-2.0.6]#yum install -y php-bcmath     #安装php-bcmath即可
  其他报错,根据提示修改/etc/php.ini文件里的参数即可,然后next,配置如下
  Database type:MySQL
  Database host:localhost
  Database port:3306
  Database name:zabbix
  user         :zabbix
  Password     :123456
  点击Test connection出现OK继续next,配置如下
  HOST          :localhost
  Port          :10051
  Name          :zabbix
  配置完成继续next,出现登录界面输入用户名/密码为默认:admin/zabbix
  

  11.配置中文界面
  登录后点击右上角的Profile在里面Language选项选择Chinese(zh_CN)然后save即可





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-666256-1-1.html 上篇帖子: Zabbix实战笔记 下篇帖子: centos7 yum 安装zabbix设置钉钉机器人报警
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表