标签:
一、基础环境
(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)
[root@server ~]# mount /dev/cdrom /mnt/iso/ mount: block device /dev/sr0 is write-protected, mounting read-only [root@server ~]# vim /etc/yum.repos.d/yum.repo [yum] name = yum gpgcheck = 0 baseurl = file:///mnt/iso :wq [root@server ~]# yum install gcc* httpd mysql-server php* net-snmp-devel curl curl-devel mysql-devel -y
如果上面yum无法使用就直接使用阿里yum源
[root@server ~]# rm -rf /etc/yum.repos.d/yum.repo [root@server ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo [root@server ~]# yum install gcc* httpd mysql-server php* net-snmp-devel curl curl-devel mysql-devel -y
[root@server ~]# vim /etc/httpd/conf/httpd.conf
276 ServerName localhost:80 # 修改为localhost:80
:wq
[root@server ~]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@server ~]# service mysqld start
[root@server ~]# chkconfig httpd on
[root@server ~]# chkconfig mysqld on
三、安装zabbix
# 安装JDK
[root@server zabbix-2.4.8]# rpm -qa | grep java
tzdata-java-2015e-1.el6.noarch
java-1.6.0-openjdk-1.6.0.35-1.13.7.1.el6_6.x86_64
java-1.5.0-gcj-1.5.0.0-29.1.el6.x86_64
java-1.7.0-openjdk-1.7.0.79-2.5.5.4.el6.x86_64
java_cup-0.10k-5.el6.x86_64
gcc-java-4.4.7-16.el6.x86_64
[root@server zabbix-2.4.8]# rpm -e --nodeps java-1.6.0-openjdk
[root@server zabbix-2.4.8]# rpm -e --nodeps java-1.5.0-gcj
[root@server zabbix-2.4.8]# rpm -e --nodeps java-1.7.0-openjdk
[root@server zabbix-2.4.8]# cd /usr/local/src/
[root@server src]# ls
jdk-8u77-linux-x64.tar.gz zabbix-2.4.8 zabbix-2.4.8.tar.gz
[root@server src]# tar xf jdk-8u77-linux-x64.tar.gz
[root@server src]# mv jdk1.8.0_77/ ../
[root@server src]# vim /etc/profile.d/jdk.sh
JAVA_HOME=/usr/local/jdk1.8.0_77
JAVA_BIN=$JAVA_HOME/bin
PATH=$PATH:$JAVA_BIN
CLASSPATH=$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME JAVA_BIN PATH CLASSPATH
:wq
[root@server src]# source /etc/profile.d/jdk.sh
[root@server src]# java -version
java 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
[root@server src]# useradd -r zabbix
[root@server src]# id zabbix
uid=498(zabbix) gid=498(zabbix) groups=498(zabbix)
[root@server src]# tar xf zabbix-2.4.8.tar.gz [root@server src]# cd zabbix-2.4.8 [root@server 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> *
***********************************************************
[root@server zabbix-2.4.8]# make && make install
[root@server zabbix-2.4.8]# ls /usr/local/zabbix-2.4.8/ # 安装成功
bin etc lib sbin share
[root@server zabbix-2.4.8]# cp -a frontends/php /var/www/html/zabbix
[root@server zabbix-2.4.8]# chown -R root:apache !$
chown -R root:apache /var/www/html/zabbix
[root@server zabbix-2.4.8]# chmod -R 754 !$
chmod -R 754 /var/www/html/zabbix
[root@server zabbix-2.4.8]# cp -a misc/init.d/fedora/core/zabbix_* /etc/init.d/
[root@server zabbix-2.4.8]# cd database/mysql/
[root@server mysql]# mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server 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 its
affiliates. Other names may be trademarks of their respective
owners.
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the current input statement.
mysql> create database zabbix character set utf8; #创建数据库zabbix,并且数据库编码使用utf8
insert into mysql.user(Host,User,Password) values(‘localhost‘,‘zabbix‘,password(‘123456‘)); #新建账户zabbix,密码123456
flush privileges; #刷新系统授权表
grant all on zabbix.* to ‘zabbix‘@‘127.0.0.1‘ identified by ‘123456‘ with grant option; #允许账户zabbix能从本机连接到数据库zabbix
flush 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.sql
mysql> source /usr/local/src/zabbix-2.4.8/database/mysql/data.sql
mysql> exit
Bye
[root@server 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 3
Server 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 its
affiliates. Other names may be trademarks of their respective
owners.
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)
[root@server 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 start
Starting zabbix_server: [ OK ]
[root@server conf]# service zabbix_agentd start
Starting zabbix_agentd: [ OK ]
以上操作完毕,刷新页面。
这样,zabbix就安装完毕。
标签:
原文地址:http://www.cnblogs.com/hukey/p/5458622.html