实验系统:CentOS 6.6_x86_64
实验前提:提前准备好编译环境,防火墙和selinux都关闭
实验说明:本实验共有4台主机,IP及角色分配如拓扑
实验拓扑:
一、准备工作
1.修改hostname和hosts文件为如下表格中内容:
说明:mysql是zabbix数据存放主机,server是zabbix主服务主机,web是zabbix前端展示主机,agent是被监控主机。通常情况下这四个角色可以搭建在同一个主机上,在这个实验里是分开部署了。
2.同步时间:
ntpdate 192.168.70.21 //地址写你自己的时间服务器
二、安装mysql服务器
1.在mysql.jason.com主机上安装mysql:
tar xf mariadb-10.0.20-linux-x86_64.tar.gz -C /usr/local/
cd /usr/local/
ln -sv mariadb-10.0.20-linux-x86_64 mysql
useradd -r mysql
mkdir -pv /mydata/data
chown -R mysql.mysql /mydata/data/
cd mysql/
chown -R root.mysql .
scripts/mysql_install_db --user=mysql --datadir=/mydata/data/
cp support-files/my-large.cnf /etc/my.cnf
cp support-files/mysql.server /etc/init.d/mysqld
chkconfig --add mysqld
chkconfig mysqld on
2.编辑配置文件并启动:
vim /etc/my.cnf
----------------------------------------------->
[mysqld]
datadir = /mydata/data //增加此行
<-----------------------------------------------
service mysqld start
3.创建zabbix数据库和授权用户:
/usr/local/mysql/bin/mysql
------------------------------------>
CREATE DATABASE zabbix;
GRANT ALL ON zabbix.* TO 'zabbix'@'192.168.19.%' IDENTIFIED BY '123456';
GRANT ALL ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY '123456';
GRANT ALL ON zabbix.* TO 'zabbix'@'mysql.jason.com' IDENTIFIED BY '123456';
FLUSH PRIVILEGES;
4.导入数据库文件:
wget %20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2/database/mysql/
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < schema.sql //导入顺序不能错
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < images.sql
/usr/local/mysql/bin/mysql -uzabbix -p123456 zabbix < data.sql
三、安装Zabbix-Server服务器
1.在server.jason.com主机上编译安装zabbix:
yum -y install mysql-devel libxml2-devel net-snmp-devel libcurl-devel
wget %20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2
groupadd zabbix
useradd -g zabbix zabbix
./configure --prefix=/usr/local/zabbix-server --enable-server --with-mysql --with-net-snmp --with-libcurl --with-libxml2
make install
2.编辑配置文件并启动:
mkdir /var/log/zabbix
chown -R zabbix:zabbix /var/log/zabbix
vim /usr/local/zabbix-server/etc/zabbix_server.conf
------------------------------------------------------------->
LogFile=/var/log/zabbix/zabbix_server.log
DBHost=192.168.19.66
DBName=zabbix
DBUser=zabbix
DBPassword=123456
ListenIP=127.0.0.1,192.168.19.74
<-------------------------------------------------------------
/usr/local/zabbix-server/sbin/zabbix_server -c /usr/local/zabbix-server/etc/zabbix_server.conf //启动服务
查看端口,已经开始监听了:
四、安装Zabbix-Web服务器
1.在web.jason.com主机上安装httpd和php:
yum -y install httpd php php-mysql libXpm php-bcmath php-gd php-mbstring php-xml t1lib
mkdir /var/www/html/zabbix
wget %20Latest%20Development/3.0.0alpha2/zabbix-3.0.0alpha2.tar.gz
tar xf zabbix-3.0.0alpha2.tar.gz
cd zabbix-3.0.0alpha2/frontends/php/
cp -a . /var/www/html/zabbix/
2.配置php并启动httpd:
vim /etc/php.ini
----------------------------------------->
date.timezone = Asia/Shanghai
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
----------------------------------------->
service httpd start
用浏览器访问,并按照提示安装: