zabbix安装的环境要LNMP(linux+nginx+mysql+PHP)或LAMP(linux+apache+mysql+PHP)
先安装阿里源epel源
yum -y install wget
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -P /etc/yum.repos.d/ http://mirrors.aliyun.com/repo/epel-7.repo
再手写zabbix源
vim /etc/yum.repo.d/zabbix.repo
[zaibbx]
name=zabbix
baseurl=http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/
enabled=1
gpgcheck=0
缓存
sudo yum clean all
sudo yum makecache
一、先安装mysql数据库
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
yum -y install mysql-community-server
vim /etc/my.cnf
skip_name_resolve=on
innodb_file_per_table=on
systemctl restart mysqld
systemctl enable mysqld
mysql_secure_installation 配置mysql
mysql -uroot -pAbcd1234
create database zabbix charset 'utf8'; #创建一个名叫zabbix的数据库
grant all on zabbix.* to zabbix@'127.0.0.1' identified by 'Abcd1234'; #创建一个zabbix的用户密码为Abcd1234,并允许通过127.0.0.1进行连接
grant all on zabbix.* to zabbix@'192.168.0.%' identified by 'Abcd1234';
flush privileges; #刷新权限
exit
systemctl restart mysqld
二、开始安装php环境
yum -y install gcc-c++ php-fpm php-mysql php bzip2 lrzsz
常用的PHP开发库(php-gd、curl、php-mysql)
systemctl restart php-fpm
systemctl enable php-fpm
三、安装服务端的zabbix
yum -y install zabbix-server-mysql zabbix-web zabbix-agent zabbix-web-mysql zabbix-sender zabbix-get
zabbix server数据库初始化:
2.x:三个sql脚本;依次执行;
3.x:一个sql脚本:create.sql
rpm -ql zabbix-server-mysql
cd /usr/share/doc/zabbix-server-mysql-3.2.6/
gzip -d create.sql.gz
mysql -h127.0.0.1 -u zabbix -p zabbix < create.sql #-p这里指数据库
cd /etc/zabbix
cp zabbix_server.conf{,.backup}
vim zabbix_server.conf
通用参数:
ListenPort=10051
SourceIP= #当有多个IP时,将哪个IP作为原IP
LogType=file #自我独立记录格式记性
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=1024 #0表示不滚动
PidFile=/var/run/zabbix/zabbix_server.pid #服务端PID路径
DBHost=127.0.0.1 #数据库所在IP地
DBName=zabbix #数据库的名字
DBUser=zabbix #数据库连接的用户
DBPassword=Abcd1234 #数据库连接的用户密码
DBSocket=/var/lib/mysql/mysql.sock #前文主机设置为localhost,用户连接数据库所用的sock位置
systemctl restart zabbix-server
systemctl enable zabbix-server
启动服务:
systemctl start zabbix-server.service
注意:centos7.0和7.1需要升级trousers
四、安装apache
yum -y install httpd
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai
systemctl restart httpd
systemctl enable httpd
firewall-cmd --add-service=mysql --permanent ; firewall-cmd --reload
setenforce 0
登入默认是admin 密码:zabbix
参考资料:
http://dengxi.blog.51cto.com/4804263/1743146
http://www.ttlsa.com/zabbix/install-zabbix-on-linux-5-ttlsa/