zabbix4.0构建实录

Posted bixiaoyu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了zabbix4.0构建实录相关的知识,希望对你有一定的参考价值。

nginx

#wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

[[email protected] ~]# yum -y install zlib pcre pcre-devel openssl openssl-devel
[[email protected] ~]# useradd -s /sbin/nologin nginx

[[email protected] ~]# yum install -y nginx

mysql数据库部署】

# wget https://repo.mysql.com/mysql57-community-release-el7.rpm

# rpm -ivh mysql57-community-release-el7.rpm

[[email protected]-server ~]# yum install mysql-server mysql mysql-devel

[[email protected]-server ~]# systemctl start mysqld
[[email protected]-server ~]# grep "password" /var/log/mysqld.log 
2018-10-23T00:47:33.152924Z 1 [Note] A temporary password is generated for [email protected]: 3e/=lUA;7#+B

mysql> alter user user() identified by 123456.Bxy;
Query OK, 0 rows affected (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

【注意】

如果不更改密码的话,无法执行任何sql语句,会报错如下:同时要满足密码策略,如果非要修改简单的密码,可以对策略进行修改:

mysql> use mysql;
ERROR 1820 (HY000): You must reset your password using ALTER USER statement before executing this statement.

mysql> alter user user() identified by 123456.Bxy;   #注意,授权root密码必须要满足四种不同字符:否则修改失败~
Query OK, 0 rows affected (0.00 sec)


现在想要将密码策略修改一下,密码长度改成六位数;密码复杂度不要那么复杂,直接修改成123456即可

首先要修改set global validate_password_policy=0

第二要修改密码长度为6

set global validate_password_length=6;

php安装】

#yum -y install libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel curl curl-devel openssl openssl-devel openldap openldap-devel

# wget http://soft.y100edu.net/php/php-7.2.11.tar.gz
#tar zxvf php-7.2.11.tar.gz -C /usr/src/

#cd /usr/src/php-7.2.11/

#./configure --prefix=/usr/local/php --with-config-file-scan-dir=/etc/php.d --with-config-file-path=/etc --with-mysqli=/usr/bin/mysql_config --enable-mbstring --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --with-openssl -enable-xml --enable-sockets --enable-fpm --with-mcrypt --with-bz2 --with-curl --enable-bcmath --with-gettext --with-pcre-regex --enable-xml --enable-fpm --with-imap-ssl --with-mhash --with-xmlrpc --with-gd

#make test
#make install

#cp php.ini-production /etc/php.ini

post_max_size = 16M
max_execution_time = 300
memory_limit = 128M
max_input_time = 300
date.timezone = Asia/Shanghai

 

#cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf

#cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

[[email protected] php-7.2.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

整合lnmp环境

[[email protected] conf]# egrep -v "#|^$" /etc/nginx/nginx.conf
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
    keepalive_timeout  65;
    server {
        listen       80;
        server_name  localhost;
        location / {
            root   /var/www/html/;
            index index.php index.html index.htm;
        }
           location ~ .php$ {
             root           /var/www/html;
               fastcgi_pass   127.0.0.1:9000;
               fastcgi_index  index.php;
               fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
               include        fastcgi_params;
           }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

 

[Zabbix部署]

[[email protected] ~]# yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libevent libevent-devel

[[email protected] ~]# cd /usr/src/zabbix-4.0.1/
[[email protected] zabbix-4.0.1]# ./configure --prefix=/usr/local/zabbix --with-mysql --with-net-snmp --with-libcurl --enable-server --enable-agent --enable-proxy --with-libxml2

[[email protected] zabbix-4.0.1]# make 

[[email protected] zabbix-4.0.1]# make install

[[email protected] conf]# ln -s /usr/local/zabbix/sbin/zabbix_server /usr/local/sbin/

LogFile=/var/log/zabbix/zabbix_server.log     #zabbix server日志输出位置
DBHost=localhost     #指定数据库地址,如果数据库在本机,默认即可
DBName=zabbixDB      #数据库名称
DBUser=zabbix        #连接数据库用户名称
DBPassword=123456.Bxy     #连接数据库对应的用户密码
StartPollers=5          #用于设置zabbix服务启动pollers(主动收集数据进程数),数值越大,则服务器吞吐量越大,但是对系统资源消耗很大
StartTrappers=5          #用于设置zabbix server启动时启动Trappers(负责处理agent推送过来的数据进程数量),Agent为主动模式时,该值需要设置大一些
StartDiscoverers=10       #用于设置zabbix server服务启动时启动的Discovers(发现)进程数量,如果discoveres进程忙时,需要提高数值
ListenIP=0.0.0.0       
Timeout=4
AlertScriptsPath=/usr/local/zabbix/share/zabbix/alertscripts    #存放zabbix server运行脚本
LogSlowQueries=3000    

 

mysql> create database zabbixDB charset=utf8;
Query OK, 1 row affected (0.01 sec)

mysql> grant all privileges on zabbixDB.* to [email protected]‘localhost‘ identified by ‘123.com‘;
Query OK, 0 rows affected, 1 warning (0.06 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

[[email protected]_server mysql]# mysql -uzabbix -p123.com  zabbixDB < schema.sql 
[[email protected]_server mysql]# mysql -uzabbix -p123.com zabbixDB < images.sql 
[[email protected]_server mysql]# mysql -uzabbix -p123.com zabbixDB < data.sql 

[email protected] mysql]# cp -a /usr/src/zabbix-4.0.1/frontends/php/*   /var/www/html/

[[email protected] mysql]# cp /usr/src/zabbix-4.0.1/misc/init.d/tru64/zabbix_* /etc/init.d/
[[email protected] mysql]# chmod +x /etc/init.d/ -R

[[email protected] mysql]# /etc/init.d/zabbix_server start

技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片

技术分享图片

[[email protected] ~]# cd /var/www/html/conf/

[[email protected] conf]# mv zabbix.conf_(3).php zabbix.conf.php

技术分享图片

 

技术分享图片

 






















以上是关于zabbix4.0构建实录的主要内容,如果未能解决你的问题,请参考以下文章

zabbix4.0编译安装

企业监控Zabbix4.0搭建

源码编译LNMP+最新版zabbix4.0

LNMP与Zabbix4.0 环境部署

ZABBIX4.0.2监控历史数据存放Elasticsearch及集群高可用方案

zabbix4.0部署