日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

分分钟一键部署Zabbix Server

發布時間:2025/1/21 编程问答 64 豆豆
生活随笔 收集整理的這篇文章主要介紹了 分分钟一键部署Zabbix Server 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


為了方便把安裝Zabbix的過程整理成自動化一鍵部署腳本,有興趣可以參考,都是些基本的命令:


#!/bin/bash #Zabbix?一鍵部署腳本 #安裝zabbix3.0.4,依賴php-5.6.25src_home=`pwd` echo?-n?"正在配置iptables防火墻……" /etc/init.d/iptables?save?>>?/dev/null chkconfig??iptables?off if?[?$??-eq?0?];then echo?-n?"Iptables防火墻初始化完畢!" fiecho?-n?"正在關閉SELinux……" setenforce?0?>?/dev/null?2>&1 sed?-i?'/^SELINUX=/s/=.*/=disabled/'?/etc/selinux/config if?[?$??-eq?0?];thenecho?-n?"SELinux初始化完畢!" fiecho?-n?"正在安裝nginx?yum?源……" yum?-y?install?wget wget?http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm rpm?-ivh?nginx-release-centos-6-0.el6.ngx.noarch.rpm if?[?$??-eq?0?];thenecho?-n?"Nginx?yum?源?初始化完畢!" fiecho?-n?"正在安裝epel-release?yum?源……" rpm?-Uvh?http://mirrors.ustc.edu.cn/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm rpm?-Uvh?http://rpms.famillecollet.com/enterprise/remi-release-6.rpm if?[?$??-eq?0?];thenecho?-n?"epel-release?yum?源?初始化完畢!" fiecho?-n?"正在安裝php-5.6.25的編譯所需相關軟件……" yum?-y?install?make?gcc?nginx??libmcrypt?php-mcrypt?mysql-server?mysql-devel?net-snmp-devel?libcurl-devel?php?php-mysql?php-bcmath?php-mbstring?php-gd?php-xml?bzip2-devel?libmcrypt-devel?libxml2-devel?gd?gd-devel?libcurl* if?[?$??-eq?0?];thenecho?-n?"php-5.6.25依賴初始化完畢!" fiecho?-n?"正在添加zabbix用戶……" useradd?-M?-s?/sbin/nologin?zabbix?&&?echo?"OK" echo?-n?"正在啟動mysqld服務……" service?mysqld?start if?[?$??-eq?0?];thenecho?-n?"Mysql啟動完畢!" fi#echo?-n?"正在為mysql的root用戶設置密碼……" #mysql_user_root_password="password" #mysql_user_zabbix_password="zabbix" #mysqladmin?-uroot?-p?password?$mysql_user_root_password echo?"正在執行mysql語句,創建zabbix數據庫,授權zabbix訪問數據庫" mysql?-e?"create?database?zabbix?character?set?utf8;grant?all?privileges?on?zabbix.*?to?zabbix@'%'?identified?by?'zabbix';grant?all?privileges?on?zabbix.*?to?zabbix@'127.0.0.1'?identified?by?'zabbix';grant?all?privileges?on?zabbix.*?to?zabbix@localhost?identified?by?'zabbix';flush?privileges;" #echo?"正在執行mysql語句,創建zabbix數據庫,授權zabbix訪問數據庫" #mysql?-uroot?-p"$mysql_user_root_password"?-e?"create?database?zabbix?character?set?utf8"?&&?echo?"創建zabbix數據庫完成" #mysql?-uroot?-p"$mysql_user_root_password"?-e?"grant?all?privileges?on?zabbix.*?to?zabbix@localhost?identified?by?'$mysql_user_zabbix_password'"?&&?echo?"授權zabbix本地登錄數據庫" #mysql?-uroot?-p"$mysql_user_root_password"?-e?"grant?all?privileges?on?zabbix.*?to?zabbix@'%'?identified?by?'$mysql_user_zabbix_password'"?&&?echo?"授權任何主機本地登錄數據庫"#zabbix一鍵部署第三方軟件包的解壓目錄 echo?-n?"編譯安裝php-5.6.25....可能需要幾分鐘" tar?zxf?${src_home}/php-5.6.25.tar.gz cd?${src_home}/php-5.6.25?&&?./configure?--prefix=/usr/local/php?--with-config-file-path=/etc?--enable-fpm???--with-libxml-dir?--with-gd?--with-jpeg-dir?--with-png-dir?--with-freetype-dir?--with-iconv-dir?--with-zlib-dir?--with-mcrypt?--enable-soap?--enable-gd-native-ttf??--enable-mbstring?--enable-exif??--with-pear?--with-curl?--enable-bcmath?--with-gettext?--with-mysqli?--enable-sockets cd?${src_home}/php-5.6.25?&&?make?-j?4?&&?make?install cdecho?-n?"正在配置啟動php-fpm....請稍等" /bin/cp?${src_home}/php-5.6.25/php.ini-production?/etc/php.ini cp?${src_home}/php-5.6.25/sapi/fpm/init.d.php-fpm?/etc/init.d/php-fpm chmod?777?/etc/init.d/php-fpm cd?/usr/local/php/etc/?&&?cp?php-fpm.conf.default?php-fpm.conf cd service?php-fpm?start if?[?$??-eq?0?];thenecho?-n?"php-fpm啟動完畢!" fi#zabbix編譯安裝 echo?-n?"正在導入zabbix數據到mysql數據庫中...." tar?zxf?${src_home}/zabbix-3.0.4.tar.gz mysql?-uzabbix?-pzabbix?zabbix?<?${src_homie}/zabbix-3.0.4/database/mysql/schema.sql mysql?-uzabbix?-pzabbix?zabbix?<?${src_homie}/zabbix-3.0.4/database/mysql/p_w_picpaths.sql mysql?-uzabbix?-pzabbix?zabbix?<?${src_homie}/zabbix-3.0.4/database/mysql/data.sql if?[?$??-eq?0?];thenecho?-n?"zabbix數據導入啟動完畢!" fi echo?-n?"正在安裝zabbix編譯依賴軟件包....可能需要幾分鐘" yum?-y?install?net-snmp-devel?curl-devel?javacc?java-1.8* echo?-n?"編譯安裝Zabbix-server....可能需要幾分鐘" cd?${src_home}/zabbix-3.0.4?&&?./configure?--prefix=/usr/local/zabbix?--enable-server?--enable-proxy?--enable-agent??--with-net-snmp?--with-libcurl?--enable-java?--with-mysql make?-j?4?&&?make?installecho?-n?"正在制作Zabbix-server啟動腳本...." echo?-e?"zabbix-agent?10050/tcp?#ZabbixAgent\nzabbix-agent?10050/udp?#Zabbix?Agent\nzabbix-trapper?10051/tcp?#ZabbixTrapper\nzabbix-trapper?10051/udp?#Zabbix?Trapper"?>>?/etc/services cp?${src_home}/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_server?/etc/init.d/ cp?${src_home}/zabbix-3.0.4/misc/init.d/fedora/core/zabbix_agentd?/etc/init.d/ cdchmod?777?/etc/init.d/zabbix_* sed?-i?'/BASEDIR=/s/$/\/zabbix/'?/etc/init.d/zabbix_server sed?-i?'/BASEDIR=/s/$/\/zabbix/'?/etc/init.d/zabbix_agentdecho?-n?"正在配置zabbix配置文件...." cd?/usr/local/zabbix/etc sed?'/#?DBHost=localhost/a\DBHost=localhost'?zabbix_server.conf?-i sed?'/#?DBPassword=/a\DBPassword=zabbix'?zabbix_server.conf?-i sed?'/#?EnableRemoteCommands=0/a\EnableRemoteCommands=1'?zabbix_agentd.conf?-i sed?'/#?ListenPort=10050/a\ListenPort=10050'?zabbix_agentd.conf?-i sed?'/#?User=zabbix/a\User=zabbix'?zabbix_agentd.conf?-i sed?'/#?AllowRoot=0/a\AllowRoot=1'?zabbix_agentd.conf?-i sed?'/#?UnsafeUserParameters=0/a\UnsafeUserParameters=1'?zabbix_agentd.conf?-i if?[?$??-eq?0?];thenecho?-n?"zabbix配置完畢!" fiecho?-n?"正在啟動zabbix_server?and?zabbix_agent...." service?zabbix_server?start service?zabbix_agentd?start chkconfig?zabbix_server?on chkconfig?zabbix_agentd?on cdecho?-n?"正在配置nginx反代zabbix...." cp?-r?${src_home}/zabbix-3.0.4/frontends/php?/usr/share/nginx/html/zabbix cd?/etc/nginx/conf.d/?&&?mv?default.conf?default.conf.bak cp?${src_home}/zabbix.conf?/etc/nginx/conf.d/ echo?-n?"配置完成,正在啟動nginx?web?server...." service?nginx?start if?[?$??-eq?0?];thenecho?-n?"Nginx啟動完畢!" fiecho?-n?"正在進行最后的zabbix?Install?,php參數修改....." sed?'/^post_max_size?=/s/=.*/=?16M/'?/etc/php.ini?-i sed?'/^max_execution_time?=/s/=.*/=?300/'?/etc/php.ini?-i sed?'/^max_input_time?=/s/=.*/=?300/'?/etc/php.ini?-i sed?-i?'/^;date.timezone/a\date.timezone?=??Asia/Shanghai'?/etc/php.ini sed?-i?'/^;always_populate_raw_post_data.*/a\always_populate_raw_post_data?=?-1'?/etc/php.ini sed?-i?'/^mysqli.default_socket?=/s/=.*/=?\/var\/lib\/mysql\/mysql.sock/'?/etc/php.ini echo?-n?"正在重新啟動php服務....." /etc/init.d/php-fpm?restart echo?-n?"正在初始化zabbix?Server...." cp?${src_home}/zabbix.conf.php?/usr/share/nginx/html/zabbix/conf/ echo?-n?"正在做最后的Zabbix?Server重啟....." /etc/init.d/zabbix_server?restart if?[?$??-eq?0?];thenecho?-n?"Zabbix?Server?啟動完畢!" fiecho?-n?"正在解決zabbix?server?亂碼問題,請你耐心等待....." cd?/usr/share/nginx/html/zabbix/fonts?&&?mv?DejaVuSans.ttf?DejaVuSans.ttf.bak cp?${src_home}/msyh.ttf?. cd?../include/?&&?sed?-i?'s/DejaVuSans/msyh/g'?defines.inc.php cd echo?-n?"恭喜你,Zabbix?部署到此完成,如有問題,請參照腳本單獨解決!!!" echo?-e?-n?"后續的操作:1、通過http://ip/zabbix?訪問你的zabbix?Web頁面,下一步....一直到底。2、你可能需要配置Nginx域名,通過域名訪問Zabbix?Server....?3、你需要自己自定義或者使用系統自帶模板,添加主機等等...."


腳本跑完沒報錯,在你的瀏覽器里輸入:http://172.16.2.21/zabbix/ 應該可以看到下面的頁面:



一鍵部署tar包我已經打包好了,請到附件下載:

連接:http://pan.baidu.com/s/1nuTaX2D?密碼:yckv

轉載于:https://blog.51cto.com/215687833/1901575

總結

以上是生活随笔為你收集整理的分分钟一键部署Zabbix Server的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。