LAMP环境下zabbix安装配置

1、安装系统环境

[root@linux-node1 tools]# uname -r
2.6.32-573.el6.x86_64
[root@linux-node1 tools]# uname -m
x86_64
[root@linux-node1 tools]# uname -a
Linux linux-node1.oldboy.com 2.6.32-573.el6.x86_64 #1 SMP Thu Jul 23 15:44:03 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux

2、修改服务端、客户端主机名

[root@linux-node1 ~]# hostname linux-node1.oldboy.com
[root@linux-node1 ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=linux-node1.oldboy.com
NTPSERVERARGS=iburst
[root@linux-node2 ~]# hostname linux-node2.oldboy.com
[root@linux-node2 ~]# vim /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=linux-node2.oldboy.com
NTPSERVERARGS=iburst

3、域名绑定ip

[root@linux-node1 ~]# vim /etc/hosts
127.0.0.1     localhost localhost.localdomain localhost4 localhost4.localdomain4
::1           localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.40  linux-node1.oldboy.com
192.168.1.41  linux-node2.oldboy.com
[root@linux-node2 ~]# vim /etc/hosts
127.0.0.1     localhost localhost.localdomain localhost4 localhost4.localdomain4
::1           localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.1.40  linux-node1.oldboy.com
192.168.1.41  linux-node2.oldboy.com

4、服务端安装及配置

    4.1 安装依赖包

[root@linux-node1 ~]# yum install httpd php mysql mysql-server php-pdo php-mysql gcc gcc-c++ glibc mysql-devel libxml2-devel curl curl-devel\
net-snmp net-snmp-devel libssh2-devel OpenIPMI-devel php-gd php-xml php-mbstring php-bcmath

    4.2 下载安装包并上传到指定目录

[root@linux-node1 src]# ls
zabbix-2.4.7.tar.gz

    4.3修改mysql参数,并启动httpd和mysql

[root@linux-node1 src]# /etc/init.d/httpd start            #启动apache
Starting httpd:                                            [  OK  ]
[root@linux-node1 src]# cp /usr/share/mysql/my-medium.cnf  /etc/my.cnf  #拷贝中等mysql配置文件到/etc下 cp: overwrite `/etc/my.cnf'? y
[root@linux-node1 src]# vim /etc/my.cnf                    #在[mysqld]下添加以下几行
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
[root@linux-node1 src]# /etc/init.d/mysqld start           #修改好配置参数后,启动mysql

    4.4测试php是否正常

[root@linux-node1 html]# cat info.php 
<?php
phpinfo();
?>

    4.4如果网页页面访问不了,查看iptables是否关闭,应该提前关闭

[root@linux-node1 html]# /etc/init.d/iptables stop
iptables: Setting chains to policy ACCEPT: filter          [  OK  ]
iptables: Flushing firewall rules:                         [  OK  ]
iptables: Unloading modules:                               [  OK  ]

    4.5创建zabbix数据库、用户名、密码,刷新权限,并导入zabbix数据结构

mysql> create database zabbix;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
[root@linux-node1 mysql]# pwd
/usr/local/src/zabbix-2.4.7/database/mysql
#导入数据结构,按顺序导入
[root@linux-node1 mysql]# mysql -uzabbix -pzabbix zabbix < schema.sql 
[root@linux-node1 mysql]# mysql -uzabbix -pzabbix zabbix < images.sql 
[root@linux-node1 mysql]# mysql -uzabbix -pzabbix zabbix < data.sql 

    4.6源码安装zabbix

[root@linux-node1 ~]# cd /usr/local/src/zabbix-2.4.7
[root@linux-node1 zabbix-2.4.7]# ls
aclocal.m4  build      conf          configure     database   include     m4           man      NEWS    upgrades
AUTHORS     ChangeLog  config.guess  configure.ac  depcomp    INSTALL     Makefile.am  misc     README
bin         compile    config.sub    COPYING       frontends  install-sh  Makefile.in  missing  src
[root@linux-node1 zabbix-2.4.7]# ./configure --prefix=/usr/local/zabbix_server --enable-server --with-mysql --enable-ipv6 --with-net-snmp\
--with-libcurl --with-libxml2 --with-openipmi --with-ssh2 [root@linux-node1 zabbix-2.4.7]# make install

    4.7将zabbix所有页面文件拷贝到apache网站根目录下

[root@linux-node1 zabbix-2.4.7]# cd frontends/php
[root@linux-node1 php]# pwd
/usr/local/src/zabbix-2.4.7/frontends/php
[root@linux-node1 php]# mv * /var/www/html/
[root@linux-node1 php]# chown -R apache:apache /var/www/html/

    4.8修改zabbix配置文件参数

[root@linux-node1 php]# cd /usr/local/zabbix_server/
[root@linux-node1 zabbix_server]# ls
etc  lib  sbin  share
[root@linux-node1 zabbix_server]# cd etc
[root@linux-node1 etc]# ls
zabbix_server.conf  zabbix_server.conf.d
[root@linux-node1 etc]# grep '^[a-Z]' zabbix_server.conf
LogFile=/tmp/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix

    4.9启动zabbix

[root@linux-node1 etc]# /usr/local/zabbix_server/sbin/zabbix_server -c /usr/local/zabbix_server/etc/zabbix_server.conf

    4.10查看zabbix 运行

[root@linux-node1 etc]# lsof -i:10051
COMMAND     PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
zabbix_se 11240 zabbix    4u  IPv4  24148      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 11240 zabbix    5u  IPv6  24149      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 11244 zabbix    4u  IPv4  24148      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 11244 zabbix    5u  IPv6  24149      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 11245 zabbix    4u  IPv4  24148      0t0  TCP *:zabbix-trapper (LISTEN)
zabbix_se 11245 zabbix    5u  IPv6  24149      0t0  TCP *:zabbix-trapper (LISTEN)

    4.11进入web界面

LAMP环境下zabbix安装配置_第1张图片

     修改/etc/php.ini

    修改完之后,重启httpd服务

  /etc/init.d/httpd restart

    然后接着在页面配置zabbix直到配置完成,输入用户名密码登录

5、客户端安装

     5.1在服务端和客户端都安装zabbix22-agent

[root@linux-node1 ~]# yum install zabbix22-agent -y
[root@linux-node2 ~]# yum install zabbix22-agent -y

  5.2修改客户端配置文件,并启动客户端

[root@linux-node1 ~]# vim /etc/zabbix/zabbix_agentd.conf
[root@linux-node1 ~]# grep '^[a-Z]' /etc/zabbix/zabbix_agentd.conf 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.40
ServerActive=127.0.0.1
Hostname=Zabbix server
[root@linux-node1 ~]# /etc/init.d/zabbix-agentd start
Starting Zabbix agent:                                     [  OK  ]

 

你可能感兴趣的:(LAMP环境下zabbix安装配置)