本次测试主要是在 centos 系统环境实践,测试内容:集群多台服务器资源监控做后续铺垫。zabbix的简介和自身的特点。在这就不阐述了
查询防火墙状态
service iptables status
停止防火墙:
service iptables stop
防火墙配置状态查询:http://www.linuxidc.com/Linux/2012-06/63111.htm
环境准备:
1.需要确认防火墙是否关闭
2.Linux下安装zabbix需要有LAMP或者LNMP运行环境
一、安装LAMP环境
1.安装zabbix web所需要的依赖包
yum -y install httpd mysql mysql-server php php-mysql postgresql postgresql-server php-postgresql php-pgsql php-devel
2.启动apache服务并查看时候启动成功
启动:/etc/rc.d/init.d/httpd start
检测启动结果:ps aux | grep httpd
3.mysql数据库的配置:
启动:/etc/rc.d/init.d/mysqld start
检查启动结果:netstat -tulnp | grep 3306
修改root密码: mysqladmin -u root password ‘你想设置的密码’
登录:令mysql -u root -p
另:附lamp环境快速搭建:https://jingyan.baidu.com/article/3d69c5518e82e3f0cf02d7ea.html
一、安装zabbix服务端
官方也提供了安装文档:https://www.zabbix.com/documentation/2.4/manual/installation/install_from_packages
1.安装zabbix-release包
mkdir -p /home/tools //创建约定目录
wget -q http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-
1.el6.noarch.rpm //下载zabbix-release包
rpm -ivh zabbix-release-2.4-1.el6.noarch.rpm //安装
rpm -ql zabbix-release
2.安装zabbix
1)保留yum安装的rpm包
[root@localhost tools]# sed -i 's#keepcache=1#keepcache=0#g' /etc/yum.conf
[root@localhost tools]# grep keepcache /etc/yum.conf
keepcache=0
2)开始安装zabbix
yum -y install zabbix zabbix-server zabbix-server-mysql #<==ZABBIX SERVER相关
yum -y install zabbix-web zabbix-web-mysql #<==Apache、Php Web界面环境
yum -y install zabbix-agent #<== ZABBIX客户端
yum -y install mysql-server mysql #<==MySQL客户端与服务端
3.配置zabbix服务相关
1)配置mysql
[root@localhost tools]# \cp /usr/share/mysql/my-medium.cnf /etc/my.cnf
[root@localhost tools]# vim /etc/my.cnf
在[mysqld](第26行)标签下增加如下三行后保存
[mysqld]
character-set-server = utf8
init-connect = 'SET NAMES utf8'
collation-server = utf8_general_ci
[root@localhost tools]# /etc/init.d/mysqld start
2)初始化数据库环境
创建数据库
mysql> create database zabbix character set utf8 collate utf8_bin;
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;
导入表结构
[root@localhost tools]# cd /usr/share/doc/zabbix-server-mysql-2.4.6/create/
[root@localhost create]# mysql -u root -p zabbix < schema.sql
[root@localhost create]# mysql -u root -p zabbix < images.sql
[root@localhost create]# mysql -u root -p zabbix < data.sql
[root@localhost create]# mysqladmin -uroot password 123456
3)设置apache时区
sed -i 's#\# php_value date.timezone Europe/Riga#php_value date.timezone Asia/Shanghai#g' /etc/httpd/conf.d/zabbix.conf
grep Shanghai /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
4)更改zabbix server配置
[root@localhost ~]# cp /etc/zabbix/zabbix_server.conf /etc/zabbix/zabbix_server.conf.bak
[root@localhost ~]# sed -i 's@# DBPassword=@DBPassword=zabbix@g' /etc/zabbix/zabbix_server.conf
[root@localhost ~]# sed -i 's@# DBHost=localhost@DBHost=localhost@g' /etc/zabbix/zabbix_server.conf
-------------------------------------------------
vim /etc/zabbix/zabbix_server.conf
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
5)启动相关服务
[root@localhost ~]# /etc/init.d/zabbix-server start
Starting Zabbix server: [确定]
[root@localhost ~]# /etc/init.d/httpd start
正在启动 httpd: [确定]
[root@localhost ~]# lsof -i:10051|wc -l
[root@localhost ~]# lsof -i:80|wc -l
4.zabbix页面安装
访问地址http://172.16.87.223/zabbix/index.php
5.安装zabbix客户端
rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-
1.el6.noarch.rpm yum install zabbix-agent -y
vim /etc/zabbix/zabbix_agentd.conf //编辑添加server 服务端IP
Server=172.16.87.223
[root@localhost tools]# 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=172.16.87.223 (服务端ip)
ServerActive=127.0.0.1 (服务端ip)
Hostname=Zabbix server
Include=/etc/zabbix/zabbix_agentd.d/
/etc/init.d/zabbix-agentd start //启动zabbix
ok 到此zabbix 就搭建完成了! 另 附上zabbix 搭建资料:
http://www.cnblogs.com/liang-wei/p/5848923.html
https://www.cnblogs.com/zzzhfo/p/5820321.html
http://www.osyunwei.com/archives/7891.html
http://www.osyunwei.com/archives/7984.html