一、基础环境
(1)centos6.7 x64
(2)JDK1.8 and zabbix-2.4.8(JDK是为了后期可以监控tomcat)
(3)虚拟机测试环境
二、安装LAMP环境
这里为了快速搭建使用yum安装,最好使用lnmp编译安装(地址:http://www.cnblogs.com/hukey/p/5304437.html)
[[email protected] ~]# mount /dev/cdrom /mnt/iso/ mount: block device /dev/sr0 is write-protected, mounting read-only [[email protected] ~]# vim /etc/yum.repos.d/yum.repo [yum] name = yum gpgcheck = 0 baseurl = file:///mnt/iso :wq [[email protected] ~]# yum install gcc* httpd mysql-server php* net-snmp-devel curl curl-devel mysql-devel -y
如果上面yum无法使用就直接使用阿里yum源
[[email protected] ~]# rm -rf /etc/yum.repos.d/yum.repo [[email protected] ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo [[email protected] ~]# yum install gcc* httpd mysql-server php* net-snmp-devel curl curl-devel mysql-devel -y[[email protected] ~]# vim /etc/httpd/conf/httpd.conf276 ServerName localhost:80 # 修改为localhost:80:wq[[email protected] ~]# service httpd restartStopping httpd: [ OK ]Starting httpd: [ OK ][[email protected] ~]# service mysqld start[[email protected] ~]# chkconfig httpd on[[email protected] ~]# chkconfig mysqld on
三、安装zabbix
# 安装JDK [[email protected] zabbix-2.4.8]# rpm -qa | grep java tzdata-java-2015e-1.el6.noarchjava-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.x86_64java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.x86_64java_cup-0.10k-5.el6.x86_64gcc-java-4.4.7-16.el6.x86_64[[email protected] zabbix-2.4.8]# rpm -e --nodeps java-1.6.0-openjdk[[email protected] zabbix-2.4.8]# rpm -e --nodeps java-1.5.0-gcj[[email protected] zabbix-2.4.8]# rpm -e --nodeps java-1.7.0-openjdk[[email protected] zabbix-2.4.8]# cd /usr/local/src/[[email protected] src]# lsjdk-8u77-linux-x64.tar.gz zabbix-2.4.8 zabbix-2.4.8.tar.gz[[email protected] src]# tar xf jdk-8u77-linux-x64.tar.gz[[email protected] src]# mv jdk1.8.0_77/ ../[[email protected] src]# vim /etc/profile.d/jdk.shJAVA_HOME=/usr/local/jdk1.8.0_77JAVA_BIN=$JAVA_HOME/binPATH=$PATH:$JAVA_BINCLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport JAVA_HOME JAVA_BIN PATH CLASSPATH:wq[[email protected] src]# source /etc/profile.d/jdk.sh[[email protected] src]# java -versionjava version "1.8.0_77" # 注意:这里的版本必须和我们刚刚安装的版本一致,否则后面会报错。Java(TM) SE Runtime Environment (build 1.8.0_77-b03)Java HotSpot(TM) 64-Bit Server VM (build 25.77-b03, mixed mode) # 编译安装ZABBIX[[email protected] src]# useradd -r zabbix[[email protected] src]# id zabbixuid=498(zabbix) gid=498(zabbix) groups=498(zabbix)[[email protected] src]# tar xf zabbix-2.4.8.tar.gz [[email protected] src]# cd zabbix-2.4.8 [[email protected] zabbix-2.4.8]# ./configure --prefix=/usr/local/zabbix-2.4.8 --enable-server --enable-agent --enable-java --with-net-snmp --with-libcurl --with-mysql=/usr/bin/mysql_config************************************************************ Now run ‘make install‘ ** ** Thank you for using Zabbix! ** <http://www.zabbix.com> ************************************************************ [[email protected] zabbix-2.4.8]# make && make install [[email protected] zabbix-2.4.8]# ls /usr/local/zabbix-2.4.8/ # 安装成功bin etc lib sbin share[[email protected] zabbix-2.4.8]# cp -a frontends/php /var/www/html/zabbix[[email protected] zabbix-2.4.8]# chown -R root:apache !$chown -R root:apache /var/www/html/zabbix[[email protected] zabbix-2.4.8]# chmod -R 754 !$chmod -R 754 /var/www/html/zabbix[[email protected] zabbix-2.4.8]# cp -a misc/init.d/fedora/core/zabbix_* /etc/init.d/[[email protected] zabbix-2.4.8]# cd database/mysql/[[email protected] mysql]# mysqlWelcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> create database zabbix character set utf8; #创建数据库zabbix,并且数据库编码使用utf8insert into mysql.user(Host,User,Password) values(‘localhost‘,‘zabbix‘,password(‘123456‘)); #新建账户zabbix,密码123456flush privileges; #刷新系统授权表grant all on zabbix.* to ‘zabbix‘@‘127.0.0.1‘ identified by ‘123456‘ with grant option; #允许账户zabbix能从本机连接到数据库zabbixflush privileges; #再次刷新系统授权表mysql> use zabbix #进入数据库mysql> source /usr/local/src/zabbix-2.4.8/database/mysql/schema.sql # 依次安装顺序,否则会报错。mysql> source /usr/local/src/zabbix-2.4.8/database/mysql/images.sqlmysql> source /usr/local/src/zabbix-2.4.8/database/mysql/data.sqlmysql> exitBye[[email protected] mysql]# mysql -uzabbix -p123456 -h 127.0.0.1 # 测试zabbix用户能否登录。Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 3Server version: 5.1.73 Source distribution Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or itsaffiliates. Other names may be trademarks of their respectiveowners. Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement. mysql> show databases;+--------------------+| Database |+--------------------+| information_schema || test || zabbix | # 能查看到zabbix库,说明就OK了。 +--------------------+3 rows in set (0.00 sec) [[email protected] zabbix-2.4.8]# cd /usr/local/zabbix-2.4.8/etc/
四、通过浏览器配置Zabbix
以上配置都可以在/etc/php.ini里进行调整
[root@server mysql]# vim /etc/php.ini [root@server mysql]# service httpd restart Stopping httpd: [ OK ] Starting httpd: [ OK ]
这里是需要对php程序里数据库信息进行修改。
[root@server mysql]# cd /var/www/html/zabbix/conf [root@server conf]# cp -a zabbix.conf.php.example zabbix.conf.php [root@server conf]# vim zabbix.conf.php <?php // Zabbix GUI configuration file. global $DB; $DB["TYPE"] = ‘MYSQL‘; $DB["SERVER"] = ‘127.0.0.1‘; $DB["PORT"] = ‘3306‘; $DB["DATABASE"] = ‘zabbix‘; $DB["USER"] = ‘zabbix‘; $DB["PASSWORD"] = ‘123456‘; // Schema name. Used for IBM DB2 and PostgreSQL. $DB["SCHEMA"] = ‘‘; $ZBX_SERVER = ‘localhost‘; $ZBX_SERVER_PORT = ‘10051‘; $ZBX_SERVER_NAME = ‘‘; $IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; ?>[root@server conf]# chmod 777 zabbix.conf.php
以上修改完成后,点击retry
点击Finish安装完成,跳转到登录页面
zabbix默认用户:admin 密码:zabbix
如果登录进来有这样的提示,就表示zabbix_server 服务没有开启。
[root@server conf]# sed -i ‘s@BASEDIR=/usr/local@BASEDIR=/usr/local/zabbix-2.4.8@g‘ /etc/init.d/zabbix_*[root@server conf]# service zabbix_server startStarting zabbix_server: [ OK ][root@server conf]# service zabbix_agentd startStarting zabbix_agentd: [ OK ]
以上操作完毕,刷新页面。
这样,zabbix就安装完毕。
时间: 2024-10-10 23:28:01