zoukankan      html  css  js  c++  java
  • zabbix4.0构建实录

    【Nginx】

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

    [root@centos ~]# yum -y install zlib pcre pcre-devel openssl openssl-devel
    [root@centos ~]# useradd -s /sbin/nologin nginx

    [root@zabbix-server ~]# yum install -y nginx

    【Mysql数据库部署】

    # wget https://repo.mysql.com/mysql57-community-release-el7.rpm
    
    # rpm -ivh mysql57-community-release-el7.rpm
    
    [root@zabbix-server ~]# yum install mysql-server mysql mysql-devel
    
    [root@zabbix-server ~]# systemctl start mysqld
    [root@zabbix-server ~]# grep "password" /var/log/mysqld.log 
    2018-10-23T00:47:33.152924Z 1 [Note] A temporary password is generated for root@localhost: 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

    [root@zabbix-server php-7.2.11]# cp php.ini-production /etc/php.ini

    [root@zabbix-server php-7.2.11]# vim /etc/php.ini

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

    [root@zabbix-server php-7.2.11]# cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
    [root@zabbix-server php-7.2.11]# cp /usr/local/php/etc/php-fpm.d/www.conf.default /usr/local/php/etc/php-fpm.d/www.conf

    [root@zabbix-server php-7.2.11]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

    [root@zabbix-server php-7.2.11]# chmod +x /etc/init.d/php-fpm

    [root@zabbix-server php-7.2.11]# /etc/init.d/php-fpm start 

    整合lnmp环境

    [root@zabbix-server 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;
            }
        }
    }

    [root@zabbix-server php-7.2.11]# mkdir -p /var/www/html/

    [root@zabbix-server php-7.2.11]# cat /var/www/html/index.php
    <?php
    phpinfo();
    ?>

    重启Nginx,测试php页面是否整合成功~

    [Zabbix部署]

    [root@zabbix-server ~]# yum -y install net-snmp net-snmp-devel curl curl-devel libxml2 libevent libevent-devel 

    [root@zabbix-server ~]# tar zxvf zabbix-4.0.1.tar.gz -C /usr/src/

    [root@zabbix-server ~]# cd /usr/src/zabbix-4.0.1/

    [root@zabbix-server zabbix-4.0.1]# ./configure --prefix=/usr/local/zabbix --enable-agent --enable-server --with-libcurl --with-mysql --with-net-snmp --enable-proxy --with-libxml2

    [root@zabbix-server zabbix-4.0.1]# make 

    [root@zabbix-server zabbix-4.0.1]# make install

    [root@zabbix-server conf]# ln -s /usr/local/zabbix/sbin/zabbix_server /usr/local/sbin/

    [root@zabbix-server zabbix-4.0.1]# useradd -M -s /sbin/nologin zabbix

    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    

     创建zabbx数据库和授权用户

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

    mysql> grant all privileges on zabbixDB.* to zabbix@'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)

    导入zabbix表信息

    [root@zabbix_server mysql]# mysql -uzabbix -p123.com  zabbixDB < schema.sql 
    [root@zabbix_server mysql]# mysql -uzabbix -p123.com zabbixDB < images.sql 
    [root@zabbix_server mysql]# mysql -uzabbix -p123.com zabbixDB < data.sql 

    [root@zabbix-server html]# cp -a /usr/src/zabbix-4.0.1/frontends/php/*  /var/www/html/

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

    [root@zabbix-server mysql]# /etc/init.d/zabbix_server start

    [root@zabbix-server ~]# cd /var/www/html/conf/

    [root@zabbix-server conf]# mv zabbix.conf_(3).php zabbix.conf.php

    【部署zabbix agent】

    #wget    http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-agent-3.4.11-1.el7.x86_64.rpm

    rpm -ivh zabbix-agent-3.4.11-1.el7.x86_64.rpm

    [root@zabbix-server conf]# egrep -v "#|^$" /usr/local/zabbix/etc/zabbix_agentd.conf
    LogFile=/var/log/zabbix/zabbix_agentd.log
    Server=192.168.37.138
    StartAgents=3       #启动agent进程数量,默认三个,如果设置为0,则表示关闭agent被动模式(也就是zabbix server主动来获取agent数据)
    ServerActive=192.168.37.138      #启动agent主动模式(agent端主动向zabbix server 推送数据)agent将主动收集到的数据发送到zabbix server端
    Hostname=192.168.37.138
    Include=/etc/zabbix/zabbix_agent.d/      
    UnsafeUserParameters=1     #启动agent端自定义item功能

     systemctl start zabbix-agent

    -s指定zabbix-agent端口地址,-p指定agent监听端口,-k表示监控项,也就是item,如果有数据表示zabbix server可以从agent获取数据配置成功~

    # /usr/local/zabbix/bin/zabbix_get -s 192.168.37.138 -p 10050 -k "system.uptime"
    48754

  • 相关阅读:
    【BZOJ1087】状压dp
    【数据库课程设计】
    【BZOJ1295】最短路
    vue组件间通信六种方式(完整版)
    常见六大Web安全攻防解析
    4、css之position
    hue集成各种组件
    1.25-1.26 Coordinator数据集和oozie bundle
    1.22-1.24 Oozie企业使用案例
    1.18-1.21 Oozie Coordinator调度
  • 原文地址:https://www.cnblogs.com/bixiaoyu/p/9966478.html
Copyright © 2011-2022 走看看