華為鯤鵬云服務最佳實踐-Zabbix-4.0 安裝配置指南
1、簡介
zaabix是一個基于WEB界面的提供分布式系統監視以及網絡監視功能的企業級的開源解決方案。
官方鏈接:https://www.zabbix.com/download
類別:運維工具
2、基礎環境
類別
子項
版本
獲取地址(方法)
華為云
華為云
虛擬機
RC3(916)
--
OS
CentOS
7.5
Kernel
4.14
軟件包
zabbix
4.2.5
https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.5/zabbix-4.2.5.tar.gz
mariadb-server
5.5.60
Repo源自帶
nginx
1.17.2
http://nginx.org/download/nginx-1.17.2.tar.gz
php
7.3.8
https://www.php.net/distributions/php-7.3.8.tar.xz
3、依賴安裝
搭建lnmp環境
Nginx+php+數據庫,使用自帶的mariadb
安裝mariadb-server(監聽端口為默認的3306)
yum ? reinstall mariadb-server
安裝php
wget ? https://www.php.net/distributions/php-7.3.8.tar.xz
tar ? xvf php-7.3.8.tar.xz
編譯前創建nginx用戶
useradd ? nginx –s /sbin/nologin
編譯
cd php-7.3.8
./configure ? --prefix=/usr/local/lnmp/php? ? --with-config-file-path=/usr/local/lnmp/php/etc --enable-mysqlnd ? --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd ? --with-openssl --with-snmp --with-gd --with-zlib --with-curl ? --with-libxml-dir --with-png-dir --with-jpeg-dir --with-freetype-dir ? --with-pear --with-gettext --with-gmp --enable-inline-optimization ? --enable-soap --enable-ftp --enable-sockets --enable-mbstring --enable-bcmath ? --enable-fpm --with-fpm-user=nginx --with-fpm-group=nginx --with-mcrypt ? --with-mhash
make ? && make install
配置php
cd /usr/local/lnmp/php/etc
cp ? php-fpm.conf.default php-fpm.conf
cp ? /usr/local/lnmp/php/etc/php-fpm.d/*conf.default /usr/local/lnmp/php/etc/php-fpm.d/*conf
復制解壓包中的php.ini-production(開發配置文件)到目錄(/usr/local/lnmp/php/etc)下并命名為php.ini,設置php.ini中的時區:date.timezone = Asia/Shanghai;其他參數根據實際情況酌情配置即可
vim ? php.ini
max_execution_time ? = 300?????? #不少于300秒
memory_limit ? = 128M???????????? #不少于128M
post_max_size ? = 16M???????????? #不少于16M
upload_max_filesize ? = 2M??????? #不少于2M
max_input_time ? = 300??????????? #不少于300秒
date.timezone ? = Asia/Shanghai? #一般東八區時間
cp sapi/fpm/init.d.php-fpm ? /etc/init.d/
cd? /etc/init.d/
chmod ? 755 init.d.php-fpm? #設置可執行權限
可以通過/etc/init.d/xxx start|stop的形式去管理服務,也可以通過systemctl的形式去管理。源碼包中也提供了php-fpm.service。
啟動php
/etc/init.d/init.d.php-fpm? start
下載安裝nginx、解壓、編譯安裝
wget http://nginx.org/download/nginx-1.17.2.tar.gz
tar ? xvf? nginx-1.17.2.tar.gz
cd ? nginx-1.17.2
./configure ? --prefix=/usr/local/lnmp/nginx --with-http_ssl_module ? --with-http_stub_status_module --with-pcre
make? && make install
配置nginx,修改項紅色標出
vim ? /usr/local/lnmp/nginx/conf/nginx.conf
3? user? nginx;
43???????? location / {
44???????????? root?? html;
45????????? ???index? ? index.php index.html index.htm;
46???????? ? }
47
48???????? ? #error_page? 404????????????? /404.html;
49
50???????? ? # redirect server error pages to the static page /50x.html
51???????? ? #
52???????? ? error_page?? 500 502 503 ? 504? /50x.html;
53???????? ? location = /50x.html {
54???????????? root?? html;
55???????? }
56
57???????? ? # proxy the PHP scripts to Apache listening on 127.0.0.1:80
58???????? ? #
59???????? ? #location ~ \.php$ {
60???????? ? #??? proxy_pass?? http://127.0.0.1;
61???????? ? #}
62
63???????? ? # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
64???????? ? #
65? ???????location ~ \.php$ {
66???????????? root?????????? html;
67???????????? fastcgi_pass?? 127.0.0.1:9000;
68???????????? fastcgi_index? index.php;
69???????????? #fastcgi_param? SCRIPT_FILENAME? /scripts$fastcgi_script_name;
70???????????? include??????? fastcgi_params;
71???????? ? }
執行以下命令檢驗nginx配置文件是否有誤
/usr/local/lnmp/nginx/sbin/nginx ? -t
啟動nginx
/usr/local/lnmp/nginx/sbin/nginx
4、組件編譯安裝
源碼編譯安裝zabbix
關閉firewalld和selinux或者將selinux設置警告模式
systemctl ? stop firewalld
setenforce ? 0
下載源碼并解壓
wget ? https://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/4.2.5/zabbix-4.2.5.tar.gz
tar ? –xvf zabbix-4.2.5.tar.gz
創建zabbix數據
庫進入解壓后的目錄database/mysql,導入zabbix三個sql文件
創建 Zabbix 數據庫
對于 Zabbix?server?和?proxy?守護進程以及 Zabbix 前端,必須需要一個數據庫。但是 Zabbix?agent?并不需要。
登錄數據庫、創建zabbix數據庫,并授權127.0.0.1登錄,賬號zabbix密碼Huawei12#$
mysql ? -uroot -pHuawei12#$
MariaDB ? [(none)]> create database zabbix character set utf8 collate utf8_bin;
MariaDB ? [(none)]> grant all privileges on zabbix.* to zabbix@127.0.0.1 identified ? by "Huawei12#$";
MariaDB ? [(none)]> quit
systemctl ? restart mariadb
systemctl ? enable mariadb
進入zabbix解壓目錄中的database/mysql目錄中,導入數據庫
mysql ? -h127.0.0.1 -uzabbix -pHuawei12#$? ? zabbix < schema.sql
mysql ? -h127.0.0.1 -uzabbix -pHuawei12#$? ? zabbix < images.sql
mysql ? -h127.0.0.1 -uzabbix -pHuawei12#$? ? zabbix < data.sql
創建用戶賬戶
groupadd ? zabbix
useradd ? -g zabbix zabbix
執行編譯 Zabbix
配置 Zabbix server 和 Zabbix proxy 的源代碼
./configure ? --enable-server --enable-agent? ? --with-mysql --enable-ipv6 --with-net-snmp --with-libcurl ? --with-libxml2 --prefix=/usr/local/zabbix
完成后執行make install安裝
啟動zabbix_server
/usr/local/zabbix/sbin/zabbix_server
配置Zabbix agent執行以下編譯選項
./configure ? --enable-agent
make ? install
/usr/local/zabbix/sbin/zabbix_server ? ??#啟動agent端
注意:為了方便服務的管理,可以配置systemctl或者/etc/init.d/兩種啟動方式
5、系統配置
簡單配置zabbix-server
復制zabbix-4.2.5/frontends/php文件到zabbix的web目錄,并將文件屬組設置為zabbix
mkdir ? /usr/local/lnmp/nginx/html/zabbix
cd ? /usr/local/lnmp/nginx/html
cp ? -arp /root/zabbix-4.2.5/frontends/php/* /usr/local/lnmp/nginx/html/zabbix/
chown ? -R apache. /usr/local/lnmp/nginx/html/zabbix
修改zabbix-server的配置文件,關聯數據庫
vim ? /usr/local/zabbix/etc/zabbix_server.conf
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=Huawei12#$?? //zabbix數據庫的授權登錄密碼
DBSocket=/var/lib/mysql/mysql.sock
啟動zabbix-server
/usr/local/zabbix/sbin/zabbix_server
如果安裝了zabbix agent 啟動zabbix_agent
/usr/local/zabbix/sbin/zabbix_agent
6、測試
測試內容:瀏覽器測試http://localhost/zabbix/setup.php
測試結果:如下
點擊下一步
所有配置ok,點擊下一步,連接數據庫
點擊下一步
提示少了配置文件,下載下來,放到說明的位置Save it as "/usr/local/lnmp/nginx/html/zabbix/conf/zabbix.conf.php"并設置權限644,屬主和屬組為apache
完成后點擊下一步
點擊完成即可登錄
默認賬戶:Admin/zabbix
例如zabbix_server的cpu使用情況
7、參考信息
zabbix官方wiki文檔
https://www.zabbix.com/manuals
8、FAQ
Q:nginx的access.log日志顯示訪問請求正常處理,但php頁面客戶端瀏覽器刷新不出來?
A:在/usr/local/lnmp/nginx/conf/fastcgi_params末尾追加以下內容
fastcgi_param ? SCRIPT_FILENAME? ? $document_root$fastcgi_script_name;
fastcgi_param ? PATH_INFO???? $fastcgi_script_name;
Q:編譯過程中提示缺少依賴?
A:極大可能需要安裝以下rpm包
yum ? install mysql-level libxml2-devel net-snmp-devel libevent-devel curl-devel
附件: 華為云鯤鵬云服務最佳實踐-Zabbix-4.0 安裝配置指南.pdf 408.37KB 下載次數:1次
PHP 鯤鵬 Zabbix
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。
版權聲明:本文內容由網絡用戶投稿,版權歸原作者所有,本站不擁有其著作權,亦不承擔相應法律責任。如果您發現本站中有涉嫌抄襲或描述失實的內容,請聯系我們jiasou666@gmail.com 處理,核實后本網站將在24小時內刪除侵權內容。