tangbinde 发表于 2019-1-22 10:11:58

CentOS 6.3 配置 zabbix

  一 服务端配置
1.配置前先关闭iptables和SELINUX,避免安装过程中报错。
  # service iptables stop
iptables: Flushing firewall rules:
iptables: Setting chains to policy ACCEPT: filter
iptables: Unloading modules:
# chkconfig iptables off
# getenforce
Disabled
  
  2.安装LAMP环境

  # 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
  # wget http://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/2.0.6/zabbix-2.0.6.tar.gz/download
  

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

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

  #useradd zabbix
  #usermod -s /sbin/nologin zabbix
  

  6.创建zabbix数据库并导入zabbix数据库(server)
  #tar zxf zabbix-2.0.6.tar.gz
  #mysqladmin -u root password 123456
   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就行了。
  #cd zabbix-2.0.6
  # ./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl
  

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

  9.启动服务(server,agent)
  cd /tw/zabbix-2.0.6
  # cp misc/init.d/tru64/zabbix_server /etc/init.d/
# cp misc/init.d/tru64/zabbix_agentd /etc/init.d/
# chmod +x /etc/init.d/zabbix_*
添加服务
# chkconfig --add zabbix_server
# chkconfig --add zabbix_agentd
设置服务器开机自动启动
  注:执行chkconfig时如出现zabbix_server 服务不支持 chkconfig,编辑zabbix_server和zabbix_agentd中开头添加以下内容即可(#chkconfig:345 61 61)
  # chkconfig zabbix_server on
# chkconfig zabbix_agentd on
# /etc/init.d/zabbix_server start
Zabbix server started.
# /etc/init.d/zabbix_agentd start
# ps -ef |grep zabbix
zabbix    1803   10 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180518030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180618030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180718030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    180818030 08:21 ?      00:00:00 /usr/local/sbin/zabbix_agentd
zabbix    1814   10 08:21 ?      00:00:00 /usr/local/sbin/zabbix_server
root      204320060 08:23 pts/0    00:00:00 grep zabbix
# netstat -lantp |grep 10050
tcp      0      0 0.0.0.0:10050               0.0.0.0:*                   LISTEN      1803/zabbix_agentd
#netstat -lantp |grep 10051
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文件目录下面。
  #cp -r frontends/php /var/www/html/zabbix
  #/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

  #wget http://nginx.org/download/nginx-1.9.9.tar.gz
  #tar zxf nginx-1.9.9.tar.gz
  #cd 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
  #make && make install
  3.配置nginx参数(修改成下列内容支持PHP)
  #cp -r frontends/php /usr/local/nginx/html/zabbix
  #vi /usr/local/nginx/conf/nginx.conf
  server {
  listen       88;
  server_name127.0.0.1;
  

  #charset koi8-r;
  

  #access_loglogs/host.access.logmain;
  

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

  #error_page404            /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_indexindex.php;
  fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;
  include      fastcgi_params;
  }
  4.启动
  #chown -R /usr/local/nginx
  #/usr/local/nginx/sbin/nginx         //启动nginx
  #/etc/init.d/php-fpm start          //启动php
  

  11.修改PHP参数
  # vi /etc/php.ini
  
  ; 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    #修改一下时区
# /etc/init.d/httpd restart
  在浏览器里输入localhost/zabbix出现zabbix安装界面点击next,下一步出现PHP bacmathno   Fail错误
  #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]
查看完整版本: CentOS 6.3 配置 zabbix