阿牛 发表于 2019-1-22 11:33:44

CentOS 6.0 上源码安装zabbix

  开源zabbix 服务器监控
  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 agent需要安装在被监视的目标服务器上,它主要完成对硬件信息或与操作系统有关的内存,CPU等信息的收集。zabbix agent可以运行在Linux ,Solaris, HP-UX, AIX, Free BSD, Open BSD, OS X, Tru64/OSF1, Windows NT4.0, Windows 2000/2003/XP/Vista)等系统之上。
  zabbix server可以单独监视远程服务器的服务状态;同时也可以与zabbix agent配合,可以轮询zabbix agent主动接收监视数据(trapping方式),同时还可被动接收zabbix agent发送的数据(trapping方式)
  扩展阅读:http://www.oschina.net/p/zabbix
  环境: LAMPCentos 6.3-i386
  1、安装快速&EPEL 软件源

EPEL 安装




[*]适用于Centos 5&Red Hat5
[*]rpm -Uvh http://mirrors.ustc.edu.cn/epel/5/i386/epel-release-5-4.noarch.rpm
[*]rpm -Uvh http://mirrors.ustc.edu.cn/epel/5/x86_64/epel-release-5-4.noarch.rpm
[*]
[*]适用与系统Centos 6&Red Hat 6
[*]rpm -Uvh http://mirrors.ustc.edu.cn/epel/6/i386/epel-release-6-8.noarch.rpm
[*]rpm -Uvh http://mirrors.ustc.edu.cn/epel/6/x86_64/epel-release-6-8.noarch.rpm

网易163源(可忽略)

使用方法点击 http://mirrors.163.com/.help/centos.html


[*]mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
[*]cp /root/CentOS6-Base-163.repo /etc/yum.repos.d/

更新缓存


[*]yum makecache

  2、安装 LAMP +zabbix server 所需软件


[*]yum install -y mysql-server httpd php mysql-devel gcc net-snmp-devel curl-devel perl-DBI php-gd php-mysql php-bcmath php-mbstring php-xml wget make libtermcap-devel OpenIPMI-devel zlib-develglibc-develgcc automakelibidn-devel openssl-devel iksemel iksemel-devel

  3、下载zabbix-server软件包

下载地址http://www.zabbix.com/download.php


[*]使用wget下载
[*]wget -c http://nchc.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.0.4/zabbix-2.0.4.tar.gz
[*]解压到当前目录
[*]tar -zxf zabbix-2.0.4.tar.gz
[*]将zabbix mysql的数据库文件copy 到一个便捷路径,便于数据库导入
[*]cp /root/zabbix-2.0.4/database/mysql/* /mnt

  4、数据库部分




[*]启动mysql
[*]service mysqld start
[*]为root 创建mysql 密码
[*]mysqladmin -u root password 'new-password-here'
[*]登陆mysql
[*]mysql -u root -p
[*]创建zabbix数据库
[*]mysql> create database zabbix character set utf8;
[*]返回状态:Database changed
[*]查看
[*]mysql> show databases;
[*]进入zabbix 库下
[*]mysql> use zabbix;
[*]导入zabbix 的数据sql,导入顺序必须是下面的
[*]mysql> source /mnt/schema.sql
[*]mysql> source /mnt/data.sql
[*]mysql> source /mnt/images.sql
[*]导入返回状态:Query OK
[*]查看mysql> show tables;
[*]mysql> quit
[*]ps:/mnt 路径下是 先前已经将 /root/zabbix-2.0.4/database/mysql/* 复制在/mnt下, 方便这里 source。数据库导入还有其他方式

mysql 登陆如果出现错误


[*]ERROR 1045 (28000): Access denied for user 'root'@'localhost' (usingpassword: YES)
[*]处理方式
[*]service mysqld stop
[*]mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
[*]mysql -u root mysql
[*]mysql> UPDATE user SET Password=PASSWORD('密码自己设定') where USER='root' and host='root' or host='localhost';
[*]mysql> FLUSH PRIVILEGES;
[*]mysql> quit
[*]service mysqld start
[*]mysql -uroot -p
[*]Enter password:   

  5、zabbix server 编译安装




[*]创建zabbix 用户及用户组
[*]groupadd -g 130 zabbix
[*]useradd -u 130 -g zabbix -c 'Zabbix monitoring' zabbix
[*]也可 useradd zabbix

进入到zabbix解压目录


[*]执行
[*]./configure--prefix=/usr/local/zabbix --enable-server --with-mysql --with-net-snmp --with-jabber --with-libcurl --with-openipmi --enable-agent
[*]结束后 查看下列几项
[*]Enable server:         yes
[*]With database:         MySQL
[*]WEB Monitoring via:    cURL
[*]Native Jabber:         yes
[*]SNMP:                  net-snmp
[*]IPMI:                  openipmi
[*]Enable agent:          yes
[*]正确后执行
[*]make && make install

拷贝zabbix web 文件到html目录下并改名


[*]cp -rf /root/zabbix-2.0.4/frontends/php /var/www/html/
[*]cd /var/www/html/ && mv php zabbix

修改php 相关参数


[*]vi /etc/php.ini
[*]修改下面这几项
[*]max_execution_time = 300
[*]date.timezone = Asia/Shanghai
[*]post_max_size = 32M
[*]mbstring.func_overload = 2
[*]max_input_time = 300

  6、关闭防火墙&SELINUX

[*]service iptables stop   
[*]chkconfig --level 0123456iptablesoff   
[*]selinux 修改为disabled.   
[*]vi /etc/selinux/config   
[*]SELINUX=disabled   
[*]启动http
[*]service httpd restart
[*]service mysqld restart


  7、安装web前端

hhtp://IP/zabbix
http://blog.运维网.com/attachment/201212/184657680.png

填写数据库 port 和数据库root 用户密码,填写完后点击Test ...
http://blog.运维网.com/attachment/201212/184735396.png
  Host 也可写成 localhost ;Name 可写可不写
http://blog.运维网.com/attachment/201212/184735132.png   http://blog.运维网.com/attachment/201212/184735177.png   http://blog.运维网.com/attachment/201212/184735808.pnghttp://blog.运维网.com/attachment/201212/184759677.pnghttp://blog.运维网.com/attachment/201212/120455253.png

复制启动脚本并修改




[*]cp zabbix-2.0.4/misc/init.d/fedora/core/* /etc/init.d/
[*]修改执行zabbix启动脚本里的目录执行
[*]vi /etc/init.d/zabbix_server
[*]vi /etc/init.d/zabbix_agentd
[*]server 和agentd 修改内容一样
[*]BASEDIR=/usr/local/zabbix
[*]另外还需 修改server 配置文件,添加DBpassword并取消注释(关键)
[*]vi /usr/local/zabbix/etc/zabbix_server.conf
[*]DBName=zabbix
[*]DBUser=root
[*]DBPassword=your-root-mysql-password



[*]service zabbix_server start
[*]添加为服务,并开机自启动
[*]chkconfig --add zabbix_server
[*]chkconfig --add zabbix_agentd
[*]chkconfig --level 35 zabbix_server on
[*]chkconfig --level 35 zabbix_agentd on
[*]chkconfig --level 35 httpd on
[*]chkconfig --level 35 mysqld on
http://blog.运维网.com/attachment/201212/122659247.png

  内容参考http://www.zabbix.com/wiki/



页: [1]
查看完整版本: CentOS 6.0 上源码安装zabbix