zabbix是什麼:是一個基於WEB界面的提供分佈式系統監視以及網絡監視功能的企業級的開源解決方案。zabbix能監視各類網絡參數,保證服務器系統的安全運營;並提供靈活的通知機制以讓系統管理員快速定位/解決存在的各類問題。zabbix由2部分構成,zabbix server與可選組件zabbix agent。zabbix server能夠經過SNMP,zabbix agent,ping,端口監視等方法提供對遠程服務器/網絡狀態的監視,數據收集等功能,它能夠運行在Linux,Solaris,HP-UX,AIX,Free BSD,Open BSD,OS X等平臺上。php
<!--more-->html
LNmp | 192.168.1.10 |
---|---|
[root@localhost ~]# ls (上傳文件) libmcrypt-2.5.7.tar.gz pcre-8.39.tar.gz zlib-1.2.8.tar.gz initial-setup-ks.cfg nginx-1.14.0.tar.gz php-5.6.27.tar.gz
[root@localhost ~]# tar zxf pcre-8.39.tar.gz [root@localhost ~]# tar zxf zlib-1.2.8.tar.gz [root@localhost ~]# tar zxf nginx-1.14.0.tar.gz [root@localhost ~]# groupadd www //建立用戶 [root@localhost ~]# useradd -g www www -s /sbin/nologin [root@localhost ~]# cd nginx-1.14.0/ [root@localhost nginx-1.14.0]# yum -y install gcc gcc-c++ make libtool zlib zlib-devel pcre pcre-devel openssl openssl-devel //安裝依賴包 [root@localhost nginx-1.14.0]# ./configure --prefix=/usr/local/nginx1.14 --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-pcre=/root/pcre-8.39 --with-zlib=/root/zlib-1.2.8 --with-http_ssl_module --with-http_gzip_static_module //安裝nginx [root@localhost nginx-1.14.0]# make && make install //解析 [root@localhost nginx-1.14.0]# ln -s /usr/local/nginx1.14/sbin/nginx /usr/local/sbin/ //軟鏈接
[root@localhost nginx-1.14.0]# nginx [root@localhost nginx-1.14.0]# netstat -anpt | grep 80 tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 14014/nginx: master tcp 0 0 192.168.1.10:22 192.168.1.250:56180 ESTABLISHED 2843/sshd: root@not
[root@localhost nginx-1.14.0]# cd [root@localhost ~]# tar zxf libmcrypt-2.5.7.tar.gz [root@localhost ~]# cd libmcrypt-2.5.7/ [root@localhost libmcrypt-2.5.7]# ./configure --prefix=/usr/local/libmcrypt && make && make install [root@localhost ~]# cd [root@localhost ~]# tar zxf php-5.6.27.tar.gz [root@localhost ~]# cd php-5.6.27/ [root@localhost php-5.6.27]# yum -y install libxml2-devel opensll-devel bzip2-devel libcurl-devel libjpeg-devel libpng-devel freetype-devel [root@localhost php-5.6.27]# ./configure --prefix=/usr/local/php5.6 --with-config-file-path=/etc --with-mysql=mysqlnd --with-mysqli=mysqlnd --with-gd --with-iconv --with-libxml-dir=/usr --with-mhash --with-mcrypt=/usr/local/libmcrypt --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-curl [root@localhost php-5.6.27]# make && make install
[root@localhost php-5.6.27]# cp php.ini-production /etc/php.ini [root@localhost php-5.6.27]# vim /etc/php.ini [root@localhost php-5.6.27]# cp sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm [root@localhost php-5.6.27]# chkconfig --add php-fpm [root@localhost php-5.6.27]# chkconfig php-fpm on //開機自啓 [root@localhost php-5.6.27]# chmod +x /etc/init.d/php-fpm [root@localhost php-5.6.27]# cp /usr/local/php5.6/etc/php-fpm.conf.default /usr/local/php5.6/etc/php-fpm.conf [root@localhost php-5.6.27]# /etc/init.d/php-fpm start Starting php-fpm done [root@localhost php-5.6.27]# netstat -anpt | grep 9000 tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 15019/php-fpm: mast
[root@localhost php-5.6.27]# vim /usr/local/nginx1.14/conf/nginx.conf 第65行 location ~ \.php$ { root html; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; include fastcgi.conf; } 第43行 location / { root html; index index.php index.html index.htm; }
vim /usr/local/nginx1.10/html/index.php <?php phpinfo(); ?>
nginx -s reload
[root@localhost ~]# ls //上傳文件 mysql-5.7.22-linux-glibc2.12-x86_64.tar.gz mysql.sh [root@localhost ~]# sh mysql.sh [root@localhost ~]# mysql -u root -p Enter password: //密碼123 Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 6 Server version: 5.7.22 MySQL Community Server (GPL) Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql>
[root@localhost ~]# cd /usr/src/ [root@localhost src]# ls fping-3.12.tar.gz zabbix-3.2.1.tar.gz //上傳文件 [root@localhost src]# tar zxf fping-3.12.tar.gz [root@localhost src]# cd fping-3.12/ [root@localhost fping-3.12]# ./configure && make && make install [root@localhost fping-3.12]# useradd zabbix -s /sbin/nologin //建立用戶 [root@localhost fping-3.12]# chown zabbix:zabbix /usr/local/sbin/fping [root@localhost fping-3.12]# cd .. [root@localhost src]# tar zxf zabbix-3.2.1.tar.gz [root@localhost src]# cd zabbix-3.2.1/ [root@localhost zabbix-3.2.1]# yum -y install net-snmp-devel curl-devel java-devel OpenIPMI-devel libssh2-devel //安裝依賴 [root@localhost zabbix-3.2.1]# ./configure --prefix=/usr/local/zabbix --enable-server --enable-agent --enable-java --with-mysql=/usr/local/mysql/bin/mysql_config --with-net-snmp --with-libcurl --with-openipmi //解析安裝 *********************************************************** * Now run 'make install' * * * * Thank you for using Zabbix! * * <http://www.zabbix.com> * *********************************************************** [root@localhost zabbix-3.2.1]# make && make install
[root@localhost zabbix-3.2.1]# ln -s /usr/local/zabbix/bin/* /usr/local/bin/ [root@localhost zabbix-3.2.1]# ln -s /usr/local/zabbix/sbin/* /usr/local/sbin/
mysql> create database zabbix character set utf8; //建立用戶 Query OK, 1 row affected (0.00 sec) mysql> grant all privileges on zabbix.* to zabbix@localhost identified by '123.com'; Query OK, 0 rows affected, 1 warning (0.00 sec) mysql> quit Bye [root@localhost mysql]# cd /usr/src/zabbix-3.2.1/database/mysql/ [root@localhost mysql]# mysql -u zabbix -p123.com -hlocalhost zabbix < schema.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@localhost mysql]# mysql -u zabbix -p123.com -hlocalhost zabbix < images.sql mysql: [Warning] Using a password on the command line interface can be insecure. [root@localhost mysql]# mysql -u zabbix -p123.com -hlocalhost zabbix < data.sql mysql: [Warning] Using a password on the command line interface can be insecure. mysql> use zabbix //查看數據庫 Reading table information for completion of table and column names You can turn off this feature to get a quicker startup with -A Database changed mysql> show tables; +----------------------------+ | Tables_in_zabbix | +----------------------------+ | acknowledges | | actions | | alerts | | application_discovery | | application_prototype | | application_template | | applications | | auditlog | | auditlog_details | | autoreg_host | | conditions | | config | | corr_condition | | corr_condition_group | | corr_condition_tag | | corr_condition_tagpair | [root@localhost ~]# chown -R zabbix:zabbix /usr/local/zabbix/ //給予權限
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_server.conf DBHost=192.168.1.10 DBPort=3306 DBName=zabbix DBUser=zabbix Timeout=4 LogFile=/usr/local/zabbix/logs/zabbix_server.log PidFile=/usr/local/zabbix/logs/zabbix_server.pid DBPassword=123.com DBSocket=/usr/local/mysql/mysql.sock FpingLocation=/usr/local/sbin/fping LogSlowQueries=3000 [root@localhost ~]# ldconfig [root@localhost ~]# vim /etc/ld.so.conf include ld.so.conf.d/*.conf /usr/local/mysql/lib [root@localhost ~]# mkdir /usr/local/zabbix/logs //建立文件 [root@localhost ~]# chown -R zabbix:zabbix /usr/local/zabbix/logs/ //給予權限 [root@localhost ~]# ldconfig
[root@localhost zabbix-3.2.1]# cd /usr/src/zabbix-3.2.1/misc/init.d/fedora/core [root@localhost core]# cp zabbix_agentd /etc/init.d/ [root@localhost core]# cp zabbix_server /etc/init.d/ [root@localhost core]# vim /etc/init.d/zabbix_server [root@localhost core]# vim /etc/init.d/zabbix_agentd 第22行:BASEDIR=/usr/local/zabbix 第31行:PIDFILE=/usr/local/zabbix/logs/$BINARY_NAME.pid [root@localhost core]# ls /usr/local/zabbix/logs/ //查看 zabbix_server.log zabbix_server.pid [root@localhost core]# cd /usr/src/zabbix-3.2.1/frontends/ [root@localhost frontends]# cp -r php/ /usr/local/nginx1.14/html/zabbix
[root@localhost frontends]# vim /etc/php.ini 第635行:post_max_size = 16M 第372行:max_execution_time = 300 第382行:max_input_time = 300 第702行:always_populate_raw_post_data = -1 第936行:date.timezone =Asia/Shanghai [root@localhost frontends]# /etc/init.d/php-fpm restart //重啓php Gracefully shutting down php-fpm . done Starting php-fpm done
[root@localhost frontends]# mysql -u root -p123 mysql> grant all on zabbix.* to zabbix@'192.168.1.%' identified by '123.com'; Query OK, 0 rows affected, 1 warning (0.00 sec)
[root@localhost frontends]# cd /usr/local/nginx1.14/html/zabbix/conf/ //上傳 [root@localhost conf]# ls maintenance.inc.php zabbix.conf.php zabbix.conf.php.example
默認用戶是admin 密碼是zabbixjava
在控制面版中的字體->選擇一種字體複製到桌面mysql
上傳到/usr/local/nginx1.14/html/zabbix/fonts/下linux
修改配置文件中的DejaVuSans替換成所選的字體名稱nginx
/usr/local/nginx1.10/html/zabbix/include/defines.inc.php :%s/DejaVuSans/simkai/g