编译安装zabbix 3.0及分开部署配置详解
实验系统:CentOS 6.6_x86_64
实验前提:提前准备好编译环境,防火墙和selinux都关闭
实验说明:本实验共有4台主机,IP及角色分配如拓扑
下载地址:试验中用到mariadb软件的下载地址,http://pan.baidu.com/s/1bnnYiMr
实验拓扑:
一、准备工作
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 http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%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 http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%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 http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%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
用浏览器访问http://192.168.19.76/zabbix,并按照提示安装:
这里出现权限报错,将配置文件下载下来保存到/var/www/html/zabbix/conf/zabbix.conf.php文件中。如果手动写入配置文件之后如果还报错,可以忽略,将浏览器关闭并重新打开连接即可。登录账号admin,登录密码zabbix:
vim /var/www/html/zabbix/conf/zabbix.conf.php //手动写入配置 ----------------------------------------------------------> <?php // Zabbix GUI configuration file. global $DB; $DB['TYPE'] = 'MYSQL'; $DB['SERVER'] = '192.168.19.66'; $DB['PORT'] = '0'; $DB['DATABASE'] = 'zabbix'; $DB['USER'] = 'zabbix'; $DB['PASSWORD'] = '123456'; // Schema name. Used for IBM DB2 and PostgreSQL. $DB['SCHEMA'] = ''; $ZBX_SERVER = '192.168.19.74'; $ZBX_SERVER_PORT = '10051'; $ZBX_SERVER_NAME = ''; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; ?>
五、安装Zabbix-Agent端
1.在agent.jason.com主机上安装:
wget http://iweb.dl.sourceforge.net/project/zabbix/ZABBIX%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-agent useradd -g zabbix-agent zabbix-agent ./configure --prefix=/usr/local/zabbix-agent --enable-agent make install
2.编辑配置文件:
mkdir /var/log/zabbix chown -R zabbix-agent:zabbix-agent /var/log/zabbix/ vim /usr/local/zabbix-agent/etc/zabbix_agentd.conf ------------------------------------------------------------> LogFile=/var/log/zabbix/zabbix_agentd.log Server=192.168.19.74 ServerActive=192.168.19.74 Hostname=agent.jason.com User=zabbix-agent <------------------------------------------------------------
/usr/local/zabbix-agent/sbin/zabbix_agentd -c /usr/local/zabbix-agent/etc/zabbix_agentd.conf
六、添加主机
这里我就大体截图一下来演示了,过程可能并不详细:
至此,演示过程全部结束,感谢大家的收看!如有问题,请联系QQ:82800452.