• 纯内网环境下搭建zabbix


      1 ##!/bin/bash
      2 #Data: Fri May  4 09:37:26 CST 2018
      3 #Founder: <daasbank-yankai>
      4 #describe: One button installation zabbix3.4
      5 #Edition: V1
      6 #OS: Centos7.2x86_64 cp
      7 . /etc/init.d/functions
      8 MMM=`rpm -qa | grep mariadb`
      9 Route=/usr/local/src
     10 ################################################################
     11 #mount iamges!
     12 ################################################################
     13 function MOUNT(){
     14 rm -rf /etc/yum.repos.d/*
     15 mount /usr/local/src/CentOS-7-x86_64-DVD-1511.iso /mnt
     16 cp -f /usr/local/src/conf/zabbix.repo /etc/yum.repos.d/zabbix.repo
     17 sleep 3
     18 yum install -y make apr* autoconf automake curl-devel gcc gcc-c++  openssl openssl-devel perl  compat* mpfr cpp glibc libgomp 
     19 sleep 3
     20 yum install -y libstdc++-devel keyutils-libs-devel libcom_err-devel libsepol-devel libselinux-devel krb5-devel zlib-devel libXpm*
     21 sleep 3
     22 yum install -y freetype libjpeg* libpng* libtool* libxml2 libxml2-devel patch libcurl-devel bzip2-devel freetype-devel2 
     23 sleep 3
     24 yum install -y freetype-devel  net-snmp-devel freetype-devel net-snmp-devel net-snmp net-snmp-devel curl-devel 
     25 sleep 3
     26 yum install -y java-1.8.0-openjdk java-1.8.0-openjdk-devel  OpenIPMI-devel  libssh2-devel
     27 }
     28 ################################################################
     29 #Install MySQL5.7.18
     30 ################################################################
     31 function Mysql(){
     32 if [ -n $MMM ];then
     33         rpm -e mariadb-libs --nodeps 2&>/dev/null
     34     else
     35         echo "Mariadb error!!!"
     36 fi
     37 tar zxf $Route/mysql-5.7.18-linux-glibc2.5-x86_64.tar.gz && {
     38     mv $Route/mysql-5.7.18-linux-glibc2.5-x86_64 /usr/local/mysql && 
     39         cd /usr/local/mysql/ && mkdir data && mkdir log && echo "export PATH=$PATH:/usr/local/mysql/bin" >> /etc/profile
     40     if [ "$?" -eq 0 ];then
     41         source /etc/profile && groupadd mysql && useradd -r -g mysql -s /bin/false mysql
     42     else
     43         echo "Mysql error !!!"
     44     fi
     45 }
     46 cp -f /usr/local/src/conf/my.cnf /etc/my.cnf
     47     if [ -f /etc/my.cnf ];then
     48         chmod 750 data/ && chown -R mysql . && chgrp -R mysql . && bin/mysqld --initialize --user=mysql && cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld && service mysqld start
     49     else
     50         echo "/etc/my.cnf error !!!"
     51     fi
     52 #######################################################################
     53 #Mysql password install
     54 #######################################################################
     55 ln -s /usr/local/mysql/bin/mysql /usr/local/sbin 
     56 ln -s /usr/local/mysql/bin/mysqladmin /usr/local/sbin
     57 PASS=`cat /usr/local/mysql/log/mysql.err | grep password | awk '{print $11}'` 
     58 mysqladmin -uroot -p${PASS} password 111111 &> /dev/null
     59     if [ "$?" -eq 0 ];then
     60         echo "Mysql password is ok!"
     61     else
     62         echo "Mysql password is not ok!!!"
     63     fi
     64 }
     65 #######################################################################
     66 #Install Nginx1.12.2
     67 #######################################################################
     68 function Nginx(){
     69 cd $Route && {
     70 tar zxf $Route/nginx-1.12.2.tar.gz &&  cd nginx-1.12.2/ && 
     71     ./configure  --prefix=/usr/local/nginx --with-http_dav_module   --with-http_stub_status_module --with-http_addition_module --with-http_sub_module --with-http_flv_module --with-http_mp4_module --with-http_ssl_module --with-http_gzip_static_module --user=nginx --group=nginx && make && make install
     72 useradd -M -s /sbin/nologin nginx
     73 }
     74 if [ "$?" -eq  0 ];then
     75         ln -s /usr/local/nginx/sbin/nginx /usr/local/sbin && /usr/local/nginx/sbin/nginx 
     76     else
     77         echo "Nginx Install error!!!"
     78         exit 1
     79 fi
     80 }
     81 ########################################################################
     82 #Intsall LIB.so
     83 ########################################################################
     84 function Lib(){
     85 cd $Route && {
     86 tar zxf libevent-2.1.8-stable.tar.gz && cd libevent-2.1.8-stable && ./configure && make && make install
     87     if [ "$?" -eq 0 ];then
     88         echo "libevent install is ok!!!"
     89     else
     90         echo "libevent install is not ok!!!"
     91     fi
     92 }
     93 cd $Route && {
     94 tar zxf libmcrypt-2.5.7.tar.gz && cd libmcrypt-2.5.7 && ./configure && make && make install 
     95     if [ "$?" -eq 0 ];then
     96         echo "libmcrypt-2.5.7 install is ok!!!"
     97     else
     98         echo "libmcrypt-2.5.7 install is not ok!!!"
     99     fi
    100 }
    101 cd $Route && {
    102 tar zxf fping-3.10.tar.gz && cd fping-3.10.tar.gz && ./configure && make && make install 
    103     if [ "$?" -eq 0 ];then
    104         echo "fping-3.10.tar.gz install is ok!!!"
    105     else
    106         echo "fping-3.10.tar.gz install is not ok!!!"
    107     fi
    108 }
    109 }
    110 ##########################################################################
    111 #Install php5.6
    112 ##########################################################################
    113 function php(){
    114 cd $Route && {
    115 tar zxf php-5.6.25.tar.gz && cd php-5.6.25  && 
    116     ./configure --prefix=/usr/local/php5.6 --with-config-file-path=/etc  --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql-sock=/usr/local/mysql/mysql.sock --with-gd --with-iconv --with-libxml-dir=/usr --with-mhash --with-mcrypt --with-config-file-scan-dir=/etc/php.d --with-bz2 --with-zlib --with-freetype-dir --with-png-dir --with-jpeg-dir --enable-xml --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --enable-mbregex --enable-fpm --enable-mbstring --enable-ftp --enable-gd-native-ttf --with-openssl --enable-pcntl --enable-sockets --with-xmlrpc --enable-zip --enable-soap --without-pear --with-gettext --enable-session --with-mcrypt --with-curl
    117 if [ "$?" -eq  0 ];then
    118     make && make install
    119 else
    120     echo "php install ./configure error!!!!"
    121 fi
    122 }
    123 cd $Route/php-5.6.25 && {
    124     cp php.ini-production /etc/php.ini && cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm && chmod +x /etc/init.d/php-fpm && chkconfig --add php-fpm && chkconfig php-fpm on 
    125 }
    126     if [ "$?" -eq 0 ];then
    127         cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf
    128     else
    129         echo "php Environmental Science ERROR!!!"
    130     fi
    131 if [ ! -d /usr/local/php5.6/etc/php-fpm.conf ]
    132      then    
    133         cp -f /usr/local/src/conf/php-fpm.conf /usr/local/php5.6/etc/php-fpm.conf
    134      else
    135         echo "php-fpm.conf ERROR!!!"
    136 fi
    137 systemctl start php-fpm && echo "php install is ok!!!"
    138 }
    139 ##################################################################################
    140 #Install nginx && php config!
    141 ##################################################################################
    142 function nginx-php(){
    143 if [ -f /usr/local/nginx/conf/nginx.conf ];then
    144     cp -f /usr/local/src/conf/nginx.conf /usr/local/nginx/conf/nginx.conf       
    145 else
    146     echo "Nginx && php ERROR!!!"
    147 fi
    148 touch /usr/local/nginx/html/daasbank.php
    149 cat << daasbank-lnmp >/usr/local/nginx/html/daasbank.php
    150 <?php  
    151 phpinfo();  
    152 ?>  
    153 daasbank-lnmp
    154 /usr/local/nginx/sbin/nginx -s reload
    155 if [ "$?" -eq 0 ];then
    156     echo "LNMP is ok! Please Visit http://IP/daasbank.php"
    157     else
    158         echo "LNMP is not ok!!!"
    159 fi
    160 }
    161 ############################################################################
    162 #Install zabbix3.4.1
    163 ############################################################################
    164 function zabbix(){
    165 groupadd zabbix && useradd -g zabbix zabbix
    166         cp -f /usr/local/src/conf/php.ini /etc/php.ini
    167 cd $Route && {
    168     tar zxf zabbix-3.4.1.tar.gz && cd zabbix-3.4.1 && 
    169     ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl
    170     if [ "$?" -eq 0 ];then
    171         make && make install 
    172     else
    173         echo "zabbix install error !!!"
    174     fi
    175 }
    176 ln -s /usr/local/zabbix/bin/* /usr/local/bin/  
    177 ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
    178 /usr/local/mysql/bin/mysql -uroot -p111111 -e "create database zabbix character set utf8;"
    179 /usr/local/mysql/bin/mysql -uroot -p111111 -e "grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';"
    180 if [ "$?" -eq 0 ]
    181     then
    182         echo "user zabbix mysql is ok!!!"
    183     else
    184         echo "user zabbix mysql is not ok!!!"
    185 fi
    186 cd $Route/zabbix-3.4.1/database/mysql && {
    187     /usr/local/mysql/bin/mysql  -uzabbix -pzabbix -hlocalhost zabbix < schema.sql
    188     /usr/local/mysql/bin/mysql  -uzabbix -pzabbix -hlocalhost zabbix < images.sql   
    189     /usr/local/mysql/bin/mysql  -uzabbix -pzabbix -hlocalhost zabbix < data.sql 
    190 }
    191         if [ "$?" -eq 0 ]
    192             then
    193                 echo "zabbix is mysql database is ok!"
    194             else
    195                 echo "zabbix is mysql database is not ok!"
    196         fi
    197 cp -f /usr/local/src/conf/zabbix_server.conf  /usr/local/zabbix/etc/zabbix_server.conf
    198 mkdir -p /usr/local/zabbix/logs  &&  chown -R zabbix:zabbix /usr/local/zabbix/
    199 cat << daasbank-zabbix >/etc/ld.so.conf  
    200 include ld.so.conf.d/*.conf  
    201 /usr/local/mysql/lib  
    202 /usr/local/lib  
    203 daasbank-zabbix
    204 /usr/local/nginx/sbin/nginx -s reload && /etc/init.d/php-fpm restart
    205 if [ "$?" -eq 0 ];then
    206     echo "zabbix && nginx && php restart is ok!!!"
    207 else
    208     echo "zabbix && nginx && php restart is not ok!!!"
    209 fi
    210 cd $Route/zabbix-3.4.1/ && {
    211  cp misc/init.d/fedora/core/zabbix_server /etc/rc.d/init.d/zabbix_server  
    212  cp misc/init.d/fedora/core/zabbix_agentd /etc/rc.d/init.d/zabbix_agentd  
    213  chmod +x /etc/rc.d/init.d/zabbix_server  && chmod +x /etc/rc.d/init.d/zabbix_agentd 
    214  chkconfig --add zabbix_server   
    215  chkconfig --add zabbix_agentd  
    216  chkconfig zabbix_server on  
    217  chkconfig zabbix_agentd on
    218     sed -i 's$BASEDIR=/usr/local$BASEDIR=/usr/local/zabbix/$g' /etc/rc.d/init.d/zabbix_server  
    219     sed -i 's*PIDFILE=/tmp/$BINARY_NAME.pid*PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid*g'  /etc/rc.d/init.d/zabbix_server
    220     sed -i 's$BASEDIR=/usr/local$BASEDIR=/usr/local/zabbix/$g' /etc/rc.d/init.d/zabbix_agentd  
    221     sed -i 's*PIDFILE=/tmp/$BINARY_NAME.pid*PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid*g' /etc/rc.d/init.d/zabbix_agentd  
    222 ldconfig && systemctl daemon-reload   
    223 /etc/init.d/zabbix_agentd start  &>/dev/null  
    224 /etc/init.d/zabbix_server start  &>/dev/null
    225 }
    226     if [ "$?" -eq 0 ];then
    227         mkdir /usr/local/nginx/html/zabbix/  && echo  "zabbix Being configured....."
    228     else
    229         echo "zabbix start is not ok!!!"
    230     fi
    231 if [ -d /usr/local/nginx/html/zabbix ];then  
    232         cp -r $Route/zabbix-3.4.1/frontends/php/* /usr/local/nginx/html/zabbix/
    233     else
    234         echo "zabbix mkdir error!!!"
    235 fi
    236 chown -R nginx:nginx /usr/local/nginx/html/zabbix
    237     if [ "$?" -eq 0 ];then
    238         echo "zabbix install is ok pleses http://IP/zabbix"
    239     else
    240         echo "zabbix install is not ok!!! error!"
    241     fi
    242 }
    243 function main(){
    244     MOUNT
    245     Mysql
    246     Nginx
    247     Lib
    248     php
    249     nginx-php
    250     zabbix
    251 }
    252 main
  • 相关阅读:
    python简单的运算
    Typora的基本格式使用
    在Eclipse中在线安装Emmet和图文使用教程
    6月末的总结
    TF-IDF学习笔记
    idea调试SpringMvc, 出现:”Can't find catalina.jar"错误的解决方法
    idea调试SpringMvc, 出现:”javax.servlet.ServletException: java.lang.IllegalStateException: Cannot create a session after the response has been committed"错误的解决方法
    idea调试SpringMvc, 出现:”通配符的匹配很全面, 但无法找到元素 'mvc:annotation-driven' 的声明“错误的解决方法
    idea调试SpringMvc, 出现:java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderListener错误的解决办法
    Zabbix 漏洞分析
  • 原文地址:https://www.cnblogs.com/optimus-prime/p/9480907.html
Copyright © 2020-2023  润新知