1、
说明:本例用源码包来安装zabbix,但是zabbix的后台数据库在这里选择mysql,然而mysql的安装方式不在选择源码了,而是选择已经编译好的通用linux包(tar包)
zabbix源码包:zabbix-3.0.3.tar.gz
mysql通用linux包:mysql-advanced-5.6.23-linux-glibc2.5-x86_64.tar.gz
2、tar 包安装mysql
1:增加mysql用户
useradd mysql
2:解压mysql-advanced-5.6.23-linux-glibc2.5-x86_64.tar.gz到/usr/local/
tar -xzvf mysql-advanced-5.6.23-linux-glibc2.5-x86_64.tar.gz -C/usr/local/
3:准备好数据目录和配置文件
ln -s /usr/local/mysql-advanced-5.6.23-linux-glibc2.5-x86_64 /usr/local/mysqlchown -R mysql.mysql /usr/local/mysql/datam -rf /usr/local/mysql/data//usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysqlrm -rf /etc/my.cnftouch /etc/my.cnf##根据环境要求在/etc/my.cnf中增加对应的配置##cat /etc/my.cnf##[mysqld]##basedir=/usr/local/mysql##datadir=/usr/local/mysql/data
4:安装mysql_install_db时(第5步)要用到的依赖包
yum -y install perl-Data-Dumper
5:安装mysql
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/ --user=mysql
6:配置服务脚本和开机启动
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqldchkconfig mysqld on
7:启动mysql
service mysqld start
3、初始化zabbix自用的后台数据库
tar -xzvf zabbix-3.0.3.tar.gz cd zabbix-3.0.3//usr/local/mysql/bin/mysql -h127.0.0.1 -e"create database zabbix char set utf8;"/usr/local/mysql/bin/mysql -h127.0.0.1 -e"grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';"/usr/local/mysql/bin/mysql -h127.0.0.1 -e"grant all on zabbix.* to zabbix@'127.0.0.1' identified by 'zabbix';"/usr/local/mysql/bin/mysql -h127.0.0.1 -e"grant all on zabbix.* to zabbix@'%' identified by 'zabbix';"/usr/local/mysql/bin/mysql -h127.0.0.1 zabbix <./database/mysql/schema.sql/usr/local/mysql/bin/mysql -h127.0.0.1 zabbix <./database/mysql/images.sql/usr/local/mysql/bin/mysql -h127.0.0.1 zabbix <./database/mysql/data.sql
4、增加zabbix用户
useradd zabbix
5、安装相关依赖为编译zabbix做准备
yum -y install gcc gcc-c++ mysql-devel libxml2-devel curl-devel unixODBC-devel net-snmp-devel OpenIPMI-devel
6、编译安装zabbix-server端
./configure --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --prefix=/usr/local/zabbix3make install
7、配置zabbix-server、连接到mysql的方式
/usr/local/zabbix3/etc/#vim zabbix_server.conf #DBHost=localhost#DBName=zabbix#DBUser=zabbix#DBPassword=zabbix#DBSocket=/tmp/mysql.sock#DBPort=3306
8、启动zabbix_server 端
cd /usr/local/zabbix3/sbin./zabbix_server
9、到此为止zabbix_server端就安装好了,那我们怎么访问zabbix呢?zabbix提供了一个友好的zabbix web界面;也就是说想要通过界面访问zabbix,我们还要配置一个zabbix界面,这个界面也就只是一个用php编写的网站啦。所以下面的步骤就是要把这个网站安装好
10、安装php,appache和相关的依赖
yum -y install php-mysql php-bcmath php-mbstring php-gd php-xml php httpd
11、源码包解压后有个frontends/php的目录,这里面保存的就是那个用php写的网站了;
cp -r /root/zabbix-3.0.3/frontends/php/* /var/www/html/
12、启动httpd开始web前端的配置
service httpd start
13、zabbix对php的默认配置有一定的要求,所以Next step可以看到如下错误
这里只要修改/etc/php.ini 这个配置文件就可以了
14、配置完成后界面如下: