LNMP zabbix 4.4 安装

硬件配置需求
环境
平台
CPU/内存
数据库
硬盘
监控主机数
小型
CentOS
2CPU/1GB
MySQL、InnoDB
普通
100
中型
CentOS
2CPU/2GB
MySQL、InnoDB
普通
500
大型
Red Hat Enterpirse Linux
4CPU/8GB
MySQL、InnoDB或PostgreSQL
RAID 10 或 SSD
大于1000
超大型
Red Hat Enterpirse Linux
8CPU/16GB
MySQL、InnoDB或PostgreSQL
RAID 10 或 SSD
大于10000

zabbix版本

4.4 
https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
3.0 LTS 稳定版
http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
4.0 LTS 正式版
https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
pre-4.0版
http://repo.zabbix.com/zabbix/3.5/rhel/7/x86_64/zabbix-release-3.5-1.el7.noarch.rpm

环境准备

Linux 7.7.1908
nginx 1.16.1
zabbix-server 4.4
zabbix-agent  4.4
mysql 5.7.29
php 5.4.16
关闭防火墙及selinux
systemctl stop firewalld && systemctl disable firewalld
sed -i 's/SELINUX=enforcing/SELINUX=disabled/'/etc/selinux/config

zabbix安装配置

安装MySQL数据库与知识库
rpm -i https://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
安装Zabbix服务器、前端、代理
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y

配置Zabbix-server

mv /etc/zabbix/zabbix_server.conf  /etc/zabbix/zabbix_server.conf.bak
vim /etc/zabbix/zabbix_server.conf
 
LogFile=/var/log/zabbix/zabbix_server.log
LogFileSize=0
PidFile=/var/run/zabbix/zabbix_server.pid
SocketDir=/var/run/zabbix
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
DBPort=3306
SNMPTrapperFile=/var/log/snmptrap/snmptrap.log
CacheSize=1024M
Timeout=4
AlertScriptsPath=/usr/lib/zabbix/alertscripts
ExternalScripts=/usr/lib/zabbix/externalscripts
LogSlowQueries=3000

配置zabbix-agent/

mv /etc/zabbix/zabbix_agent.conf  /etc/zabbix/zabbix_agent.conf.bak
vim /etc/zabbix/zabbix_agentd.conf
 
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=
ListenPort=10050
ServerActive=
Hostname=
Include=/etc/zabbix/zabbix_agentd.d

数据库安装配置

安装数据库
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
yum localinstall mysql57-community-release-el7-8.noarch.rpm -y
检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"
yum install mysql-community-server -y
启动MySQL服务
systemctl start mysqld
登录数据库
#查看随机密码
grep 'temporary password' /var/log/mysqld.log

#登陆数据库 
mysql -uroot -p
修改validate_password_policy参数的值
set global validate_password_policy=0;
再修改密码的长度
set global validate_password_length=1;
修改默认密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'xuewenlong@123';
允许root远程登陆*
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'xuewenlong@123' WITH GRANT OPTION;
创建zabbix数据库和用户
mysql –uroot –p
mysql>  create database zabbix character set utf8;
Query OK, 1 row affected (0.00 sec)
mysql> grant all privileges on zabbix.* to 'zabbix'@'localhost' identified by 'zabbix'; 
Query OK, 0 rows affected, 1 warning (0.00 sec) 
mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
导入模板数据
方法1
source /usr/share/doc/zabbix-server-mysql-3.4.7/create/schema.sql
source /usr/share/doc/zabbix-server-mysql-3.4.7/create/images.sql
source /usr/share/doc/zabbix-server-mysql-3.4.7/create/data.sql
方法2
zcat /usr/share/docc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix 

nginx安装配置

安装nginx
yum install nginx -y
配置nginx
vim /etc/nginx/conf.d/default.conf
 ...
    location / {
        root   /usr/share/zabbix;
        index  index.php;
    }
...
    location ~ \.php$ {
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /usr/share/zabbix$fastcgi_script_name;
        include        fastcgi_params;
    }
...
修改zabbix前端文件权限
chown  nginx:nginx /usr/share/zabbix/*
chmod -R 755 /usr/share/zabbix/*
启动nginx
systemctl restart nginx

PHP安装配置

安装php
yum install php-fpm  php-gd php-mbstring php-bcmath php-gd  php-xmlwriter  php-xmlreader -y
修改配置文件
sed -i "s#max_execution_time = 30#max_execution_time = 600#g" /etc/php.ini
sed -i "s#max_input_time = 60#max_input_time = 600#g" /etc/php.ini
sed -i "s#memory_limit = 128M#memory_limit = 256M#g" /etc/php.ini
sed -i "s#post_max_size = 8M#post_max_size = 32M#g" /etc/php.ini
sed -i "s#upload_max_filesize = 2M#upload_max_filesize = 16M#g" /etc/php.ini
sed -i "s/;date.timezone =/date.timezone = Asia\/Shanghai/g" /etc/php.ini
启动php-fpm
systemctl start  php-fpm
启动所有服务
systemctl start zabbix-server
systemctl start zabbix-agent
systemctl start nginx 
systemctl start mysqld
systemctl start  php-fpm
设置开机启动项
systemctl enable  zabbix-server  zabbix-agent  mysqld  nginx  php-fpm
检查端口
[root@zabbix-server]# netstat -pntl 
tcp   0   0 127.0.0.1:9000   0.0.0.0:*   LISTEN    5118/php-fpm: maste 
tcp   0   0 0.0.0.0:80       0.0.0.0:*   LISTEN    5046/nginx: master  
tcp6  0   0 :::10050         :::*        LISTEN    5577/zabbix_agentd  
tcp6  0   0 :::10051         :::*        LISTEN    4821/zabbix_server  
tcp6  0   0 :::3306          :::*        LISTEN    1703/mysqld 
连接到新安装的Zabbix前端: http://server_ip
posted @ 2020-04-30 13:41  SRE运维博客  阅读(299)  评论(0编辑  收藏  举报