zabbix服务端安装(tar包安装)
关闭selinux及防火墙
[root@localhost /]# sed -i "s#SELINUX=enforcing#SELINUX=disabled#g" /etc/selinux/config #重启生效
[root@localhost /]# setenforce 0 #临时关闭
[root@localhost /]#service iptables stop
z[root@localhost /]# rpm -qa mysql*
下载MySQL5.6版本
[root@localhost /]# rpm -ivh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
[root@localhost /]# yum -y install mysql-server
[root@localhost /]# yum list installed | grep mysql
mysql-community-client.x86_64
5.6.32-2.el6 @mysql56-community
mysql-community-common.x86_64
5.6.32-2.el6 @mysql56-community
mysql-community-libs.x86_64
5.6.32-2.el6 @mysql56-community
mysql-community-release.noarch
mysql-community-server.x86_64
5.6.32-2.el6 @mysql56-community
修改mysql配置文件/etc/my.cnf,在[mysqld]中添加innodb_file_per_table=1
[root@localhost /]# vim /etc/my.cnf
innodb_file_per_table=1
[root@localhost /]# /etc/init.d/mysqld start
这是强烈建议安全数据库和指定的“根”的帐户密码,删除匿名登录等。它是按照指令后MySQL安全安装完成。
root@localhost /]# mysql_secure_installation
登陆数据库
[root@localhost /]# mysql -u root -p #这里的root密码为123456
mysql> CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
Query OK, 1 row affected (0.06 sec)
mysql> GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@localhost IDENTIFIED BY 'zabbixpass';
Query OK, 0 rows affected (0.02 sec)
mysql> show databases;+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+4 rows in set (0.03 sec)
mysql>
Zabbix 3需要PHP是至少5.4或更高版本。我们的CentOS 6.5库跟php 5.3.3因此我们需要安装一个新的。
[root@localhost /]# rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
安装所需要的包
[root@localhost /]# yum -y install httpd php56w php56w-gd php56w-mysql php56w-bcmath php56w-mbstring php56w-xml php56w-ldap
修改php配置
[root@localhost /]# vim /etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
date.timezone = Asia/Shanghai
always_populate_raw_post_data = -1
修改apache配置
[root@localhost /]# vim /etc/httpd/conf/httpd.conf
ServerName 127.0.0.1
DirectoryIndex index.html index.html.var index.php
启动apache
[root@localhost /]# /etc/init.d/httpd start
Starting httpd: [ OK ]
创建zabbix用户
[root@localhost /]# groupadd zabbix
[root@localhost /]# useradd -g zabbix zabbix
依赖包安装
[root@localhost mysql]# yum -y install gcc mysql-community-devel libxml2-devel unixODBC-devel net-snmp-devel libcurl-devel libssh2-devel OpenIPMI-devel openssl-devel openldap-devel
下载zabbix安装包、解压
用于上传下载文件(由于直接在虚拟机里下载较慢、在此直接下载到本地主机用lrzsz上传至虚拟机)
[root@localhost /]# yum -y install lrzsz
zabbix3.0.4下载地址
下载zabbix安装包、解压
用于上传下载文件(由于直接在虚拟机里下载较慢、在此直接下载到本地主机用lrzsz上传至虚拟机)
[root@localhost /]# yum -y install lrzsz
zabbix3.0.4下载地址
[root@localhost /]# wget http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/3.0.4/zabbix-3.0.4.tar.gz解压到当前目录根
[root@localhost /]# tar -zxvf zabbix-3.0.4.tar.gz
[root@localhost /]# cd /zabbix-3.0.4/database/mysql/
[root@localhost mysql]# ls
data.sql images.sql schema.sql
[root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <schema.sql
Enter password: #这里的root密码为123456
[root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <images.sql
Enter password:
[root@localhost mysql]# mysql -uroot -hlocalhost -p zabbix <data.sql
Enter password:
安装
[root@localhost mysql]# cd /zabbix-3.0.4
编译
[root@localhost zabbix-3.0.4]# ./configure --enable-server --enable-agent --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --with-ssh2 --with-openipmi --with-openssl --enable-java --prefix=/usr/local/zabbix
安装
[root@localhost zabbix-3.0.4]# make install
[root@localhost zabbix-3.0.4]# echo $?0
修改zabbix_server的配置
[root@localhost etc]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBName=zabbix
DBUser=zabbix
DBPassword=zabbixpass
创建一个新的web前端文件
[root@localhost conf]# mkdir /var/www/html/zabbix
移动源到刚才创建目录下
[root@localhost conf]#cd /zabbix-3.0.4/frontends/php/
[root@localhost php]# cp -a . /var/www/html/zabbix/
设置Apache作为Web用户接口文件的所有者
[root@localhost php]# chown -R apache:apache /var/www/html/zabbix
添加权限给Zabbix Web界面执行文件
[root@localhost php]# chmod +x /var/www/html/zabbix/conf/
添加Zabbix服务器和Zabbix代理启动脚本
[root@localhost php]# cp /zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server /etc/init.d/zabbix_server
[root@localhost php]# cp /zabbix-3.0.4/misc/init.d/fedora/core/zabbix_agentd /etc/init.d/zabbix_agentd
添加Zabbix服务器和Zabbix代理服务
[root@localhost php]# chkconfig --add /etc/init.d/zabbix_server
[root@localhost php]# chkconfig --add /etc/init.d/zabbix_agentd
[root@localhost php]# chkconfig httpd on
[root@localhost php]# chkconfig mysqld on
[root@localhost php]# chkconfig zabbix_server on
[root@localhost php]# chkconfig zabbix_agentd on
启动zabbix_server
[root@localhost php]# /etc/init.d/zabbix_server start #报错
Starting zabbix_server: /etc/init.d/functions: line 546: /usr/local/sbin/zabbix_server: No such file or directory
[FAILED]
[root@localhost php]# vim /etc/init.d/zabbix_server
BASEDIR=/usr/local/zabbix #更改下路径
[root@localhost php]# /etc/init.d/zabbix_server start
Starting zabbix_server: [ OK ]
[root@localhost php]# vim /etc/init.d/zabbix_agentd
BASEDIR=/usr/local/zabbix #更改下路径
[root@localhost php]# /etc/init.d/zabbix_agentd start
Starting zabbix_agentd: [ OK ]
zabbix web安装界面
http://192.168.244.155/zabbix/setup.php
默认登陆用户及密码Admin/zabbix