zabbix搭建
#/bin/bash
#防火墙关闭
systemctl stop firewalld.service
systemctl disable firewalld.service
sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
grep SELINUX=disabled /etc/selinux/config
setenforce 0
###############
#yum源
cd /etc/yum.repos.d/
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
yum clean all
yum makecache
rpm -ivh http://repo.webtatic.com/yum/el6/latest.rpm
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
yum update
cat > zabbix.repo <<EOF
[zabbix]
name=zabbix
baseurl=http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64
gpgchenck=0
enabled=1
EOF
rpm -i https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
yum -y install epel-rpm-macros.noarch epel-release.noarch
yum repolist
########################
#数据库
yum -y install mysql mysql-devel mysql-server
systemctl start mysqld
mysqld --initialize -u root
cat >> /etc/my.cnf <<EOF
skip-grant-tables
EOF
systemctl restart mysqld
mysql -u root -e update mysql.user set password=password("123456") where user='root';
systemctl restart mysqld
mysql -uroot -p123456 -e CREATE DATABASE zabbix CHARSET 'utf8';
mysql -uroot -p123456 -e GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@"localhost" IDENTIFIED BY 'zabbix';
mysql -uroot -p123456 -e flush privileges;
sed -i 's/skip-grant-tables/#skip-grant-tables/g' /etc/my.cnf
######################
#zabbix server
yum -y install zabbix-server-mysql zabbix-get
rpm -ql zabbix-server-mysql
cd /usr/share/doc/zabbix-server*/
gunzip create.sql.gz
mysql -uroot -p123456 -Dzabbix < create.sql
systemctl start zabbix-server
vim /etc/zabbix/zabbix*.config
sedLogFile=/tmp/zabbix_server.log
PidFile=/tmp/zabbix_server.pid
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix #指定zabbix数据库密码
ListenIP=192.168.10.197 #服务器IP地址
#########################
#添加服务端口
vim /etc/services
zabbix-agent 10050/tcp # Zabbix Agent
zabbix-agent 10050/udp # Zabbix Agent
zabbix-trapper 10051/tcp # Zabbix Trapper
zabbix-trapper 10051/udp # Zabbix Trapper
#########################
#php和http
yum -y install httpd php php-mysql php-mbstring php-gd php-bcmath php-ldap php-xml
yum -y install zabbix-web zabbix-web-mysql php-fpm
vim /etc/httpd/conf.d/zabbix.conf
<virtualhost 172.20.101.114:80>
servername zabbix.zsythink.net
documentroot /usr/share/zabbix
php_value date.timezone Asia/Shanghai
<virtualhost>
systemctl restart httpd
systemctl restart mysqld
systemctl restart zabbix-server
systemctl restart php-fpm
##############################################
yum -y install zabbix-agent
systemctl restart zabbix-agent
修改指向服务端
##############################################