安装epel源
[[email protected] ~]# rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/7/x86_64/zabbix-release-2.4-1.el7.noarch.rpm
[[email protected] ~]# rpm -ivh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
安装zabbix-server
[[email protected] ~]# yum -y install zabbix zabbix-get zabbix-server zabbix-web-mysql zabbix-web zabbix-agent
安装mysql epel源
http://dev.mysql.com/downloads/repo/
选择对应的操作系统,然后点击网页下方No thanks, just start my download.
下载文件mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
安装mysql-server
[[email protected] tmp]# yum install -y mysql-server
配置MySQL配置文件
[[email protected] tmp]# vi /etc/my.cnf
添加语句
character-set-server=utf8
innodb_file_per_table=1
启动mysql
[[email protected] tmp]# service mysqld start
创建zabbix数据库
[[email protected] tmp]# mysqladmin -uroot password admin
[[email protected] tmp]# mysql -uroot -padmin
mysql> create database zabbix character set utf8;
mysql> grant all privileges on zabbix.* to [email protected] identified by ‘zabbix‘;
mysql> flush privileges;
下载解压最新tar包
[[email protected] tmp]# wget http://fossies.org/linux/misc/zabbix-2.4.5.tar.gz
[[email protected] tmp]# tar -xzvf zabbix-2.4.5.tar.gz
导入zabbix-server的数据库
[[email protected] tmp]# mysql -uroot -padmin
mysql> use zabbix
mysql> source /tmp/zabbix-2.4.5/database/mysql/schema.sql
如果安装zabbix-proxy,只导入schema即可,否则会报错
mysql> source /tmp/zabbix-2.4.5/database/mysql/images.sql
mysql> source /tmp/zabbix-2.4.5/database/mysql/data.sql
mysql> show tables;
配置zabbix_server.conf
[[email protected] mysql]# vi /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBSocket=/var/lib/mysql/mysql.sock
StartPollers=5
SNMPTrapperFile=/var/log/snmptt/snmptt.log
CacheSize=256M
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
新建文件夹
[[email protected] mysql]# mkdir -p /usr/lib/zabbix/alertscripts
[[email protected] mysql]# mkdir -p /usr/lib/zabbix/externalscripts
启动zabbix
[[email protected] mysql]# service zabbix-server start
报错
Aug 11 12:17:37 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
Aug 11 12:17:37 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.
Aug 11 12:17:37 localhost.localdomain systemd[1]: zabbix-server.service holdoff time over, scheduling restart.
Aug 11 12:17:37 localhost.localdomain systemd[1]: Stopping Zabbix Server...
Aug 11 12:17:37 localhost.localdomain systemd[1]: Starting Zabbix Server...
Aug 11 12:17:37 localhost.localdomain systemd[1]: zabbix-server.service start request repeated too quickly, refusing to start.
Aug 11 12:17:37 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
Aug 11 12:17:37 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.
解决
[[email protected] mysql]# yum update trousers -y
从新启动
[[email protected] mysql]# service zabbix-server start
启动httpd
[[email protected] mysql]# service httpd start
php配置
[[email protected] mysql]# vi /etc/httpd/conf.d/zabbix.conf
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Require all granted
php_value max_execution_time 300
php_value memory_limit 128M
php_value post_max_size 16M
php_value upload_max_filesize 2M
php_value max_input_time 300
php_value date.timezone Asia/Shanghai
</Directory>
输入网址
http://192.168.0.174/zabbix/
用户名admin 密码zabbix