准备工作 工作目录/opt
关闭防火墙 1 2 3 4 systemctl stop firewalld.service systemctl disable firewalld.service
关闭selinux 1 2 3 4 vim /etc/selinux/config SELINUX=disabled
Yum清华源 1 2 3 4 5 6 sudo sed -e 's|^mirrorlist=|#mirrorlist=|g' \ -e 's|^#baseurl=http://mirror.centos.org/centos|baseurl=https://mirrors.tuna.tsinghua.edu.cn/centos|g' \ -i.bak \ /etc/yum.repos.d/CentOS-*.repo sudo yum makecache
下载依赖环境 1 yum install -y deltarpm gcc gcc-c++ unixODBC-devel httpd mysql-devel libcurl libcurl-devel libevent libevent-devel curl-devel libxml2 libxml2-devel net-snmp-devel pcre-devel java-devel openssl-devel perl-ExtUtils-Embed at python subversion gperf make rpm-build git bzip2-devel gd gd-devel t1lib t1lib-devel GeoIP-devel libatomic_ops-devel zlib-devel unzip libstdc++* net-snmp net-snmp* gmp gmp-devel openldap openldap-devel libpcap-devel glib2-devel GeoIP-devel vim wget git libtool make automake mlocate pam-devel unzip screen openssl iptables-services bash-completion* libxslt* curl net-tools libssh2-devel
准备LNMP 本博客其他文章有讲到(那篇文章是很久以前写的,现在版本的zabbix对mysql有要求,这里补充以下mysql的安装方法)
安装Mariadb 添加阿里云源vim /etc/yum.repos.d/MariaDB.repo
1 2 3 4 5 6 7 8 [mariadb] name = MariaDB baseurl = http://yum.mariadb.org/10.8/centos7-amd64 gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB gpgcheck=1
下载mariadbyum install -y MariaDB-server MariaDB-client
1 2 3 4 5 6 7 8 9 10 11 12 13 systemctl start mariadb systemctl enable mariadb mysql -uroot use mysql grant all privileges on *.* to 'root' @'%' identified by '123456qwer' ; delete from mysql.user where User='' ; FLUSH PRIVILEGES; systemctl restart mariadb
安装Zabbix
下载zabbix-server 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 cd /optwget https://cdn.zabbix.com/zabbix/sources/stable/6.4/zabbix-6.4.5.tar.gz tar -zxvf zabbix-6.4.5.tar.gz cd zabbix-6.4.5/./configure --prefix=/usr/local/zabbix/zabbix-server --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --enable-java && make CFLAGS=-std=gnu99 && make install --prefix --enable-server --enable-agent --with-mysql --with-net-snmp --with-libcurl --with-libxml2 --with-unixodbc --enable-java vim /etc/profile export PATH=$PATH :/usr/local/zabbix/zabbix-server/sbin/:/usr/local/zabbix/zabbix-server/bin/source /etc/profile
创建zabbix数据库 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 mysql - uroot - p CREATE USER 'zabbix' @'localhost' IDENTIFIED BY 'zabbix' ;CREATE DATABASE `zabbix` CHARACTER SET utf8 COLLATE utf8_bin;grant all privileges on zabbix.* to zabbix@'localhost' identified by 'zabbix' ;flush privileges; set names utf8;exit mysql - uzabbix - pzabbix zabbix < / opt/ zabbix-6.4 .5 / database/ mysql/ schema.sql mysql - uzabbix - pzabbix zabbix < / opt/ zabbix-6.4 .5 / database/ mysql/ images.sql mysql - uzabbix - pzabbix zabbix < / opt/ zabbix-6.4 .5 / database/ mysql/ data.sql
Centos准备 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 useradd zabbix passwd zabbix chown -R zabbix:zabbix /usr/local/zabbix/zabbix-server/vim /usr/local/zabbix/zabbix-server/etc/zabbix_server.conf DBHost=localhost DBName=zabbix DBUser=zabbix DBPassword=zabbix DBPort=3306 Timeout=30 AlertScriptsPath=/usr/local/zabbix/zabbix-server/share/zabbix/alertscripts ExternalScripts=/usr/local/zabbix/zabbix-server/share/zabbix/externalscripts zabbix_server ps auxf |grep zabbix_server netstat -tulnp |grep zabbix rm -rf /usr/local/nginx/nginx/html/*cp -a /opt/zabbix-6.4.5/ui/* /usr/local/nginx/nginx/html/
1 2 3 4 5 6 7 8 9 10 11 12 13 14 vim /etc/opt/remi/php74/php.ini post_max_size = 16M max_execution_time = 300 max_input_time = 300 date.timezone = Asia/Shanghai systemctl restart php74-php-fpm.service Admin zabbix
zabbix客户端安装 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 useradd zabbix wget https://cdn.zabbix.com/zabbix/binaries/stable/6.0/6.0.3/zabbix_agent-6.0.3-linux-4.12-ppc64le-static.tar.gz tar -zxvf zabbix-3.4.15.tar.gz cd zabbix-3.4.15/./configure --prefix=/usr/local/zabbix_agent --enable-agent make && make install vim /usr/local/zabbix_agent/etc/zabbix_agentd.conf Server=服务端ip地址或域名 ServerActive=服务端ip地址或域名 Hostname=客户端主机名 HostMetadata=自动注册的关键字 /usr/local/zabbix_agent/sbin/zabbix_agentd