zabbix学習(一)——LNMP環境構築及びzabbixインストール
第一部:LNMP環境構築
一、環境説明:
OS: centos7.6_x64nginx:nginx-1.16.0php: php-7.1.11mysql:mysql-5.6.44
zabbix:zabbix-4.0.10
二、設置前の準備:
2.1 yumソースの準備
2.2依存関係のインストール
3.3ディレクトリの作成
二、nginx取付
2.1ユーザーの作成
2.2インストールパッケージのダウンロード
2.3コンパイルインストール
2.4ソフトリンクの確立後のアップグレードが便利で、ソフトリンクの確立
2.5 nginxにSysV init起動スクリプトを提供する
新しいファイル/etc/rc.d/init.d/nginx、内容は以下の通りです.
2.6このスクリプトに実行権限を付与する
2.7サービス管理リストに追加し、電源を入れて自動的に起動させる:
2.8 nginxサービスの開始
2.9 PATH環境変数の構成
2.10 nginxの構成
三、mysqlのインストール
3.1他のバージョンのmysqlまたはmariadbがインストールされているかどうかを確認します.
3.2 mysqlユーザーとグループの確立
3.3 mysqlのダウンロードとインストール
3.4環境変数の構成
3.5 mysqlプロファイルを次のように編集します.
3.6起動スクリプトの準備
basedir=/data/server/mysql datadir=/data/mysql
3.7 mysqlの初期化
3.8 mysqlを起動し、起動時の自己起動を設定する
3.8 mysqlを使用したインストールがシステム使用仕様に適合し、その開発コンポーネントをシステム使用にエクスポートするには、以下の手順が必要です.
四、phpのインストール
4.1 phpのダウンロード
4.2依存拡張パッケージのインストール
4.3コンパイルインストールphp
4.4 phpプロファイルの準備
4.5 php-fpmのプロファイルを提供する:
4.6 php-fpmのプロファイルを編集する:
4.7環境変数の設定
4.8 php-fpmにSysv initスクリプトを提供し、サービスリストに追加する:
五、nginxとphp 5を統合する
5.1 nginxを編集する.conf、次のオプションを有効にします.
5.2編集/data/server/nginx/fastcgi_params、その内容を次のように変更します.
5.3完全なプロファイルは次のとおりです.
5.4/data/webappsでindexを新規作成する.phpのテストページ、phpが正常に動作するかどうか、データベースに接続できるかどうかをテストします.
六、php拡張をインストールし、php
xcacheはphp 7をサポートしていない.1になったら、php原生のopcacheを使って代わります
6.2 php-fpmの再起動
七、サードパーティphp拡張モジュールのインストール方法
7.1ソースパッケージにインストールされた拡張モジュールbcmatch
# ls -lhrt/data/server/php-7.1.11/lib/php/extensions/no-debug-non-zts-20160303/ total 5.2M -rwxr-xr-x 1 root root 3.3M Jul 16 14:11 opcache.a -rwxr-xr-x 1 root root 1.6M Jul 16 14:11 opcache.so -rwxr-xr-x 1 root root 357K Jul 16 16:56 bcmath.so -rwxr-xr-x 1 root root 52K Jul 16 20:07 gettext.so
7.2プロファイルの編集、有効化
第2部:zabbixインストール
1、Zabbix Serverのインストール
1.1依存パッケージのインストール
1.2ソフトウェアパッケージのダウンロード
1.3ユーザーの作成
1.4データベースの作成
1.5データベースのインポート
1.6コンパイルインストール
1.7環境変数の構成
1.8 zabbix_の編集server.conf
1.9 zabbixのWebサーバディレクトリへのWebファイルのコピーのインストール
1.10 php構成を編集してzabbixの要求を満たす
1.11 zabbix serverの起動スクリプトの準備
1.12 zabbixの起動server
2、zabbix agentのインストール
2.1インストールagentのコンパイル
2.2プロファイルの編集
2.3 zabbixの準備Agentd起動スクリプト
2.4 zabbixの起動agent
参照リンク:https://www.zabbix.com/documentation/4.0/manual/installation/install
転載先:https://www.cnblogs.com/fang9045315/p/11202155.html
一、環境説明:
OS: centos7.6_x64nginx:nginx-1.16.0php: php-7.1.11mysql:mysql-5.6.44
zabbix:zabbix-4.0.10
二、設置前の準備:
2.1 yumソースの準備
# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# yum -y install epel-release
2.2依存関係のインストール
# yum -y install gcc automake autoconf libtool make cmake gcc-c++ glibc pcre pcre-devel zlib zlib-devel openssl openssl-devel
3.3ディレクトリの作成
# mkdir /data
# mkdir /data/package
# mkdir –p /data/server
# mkdir –p /data/webapps
# mkdir –p /data/logs
二、nginx取付
2.1ユーザーの作成
# groupadd -r nginx
# useradd -r -g nginx nginx
2.2インストールパッケージのダウンロード
# wget http://nginx.org/download/nginx-1.16.0.tar.gz
2.3コンパイルインストール
# tar –zxvf nginx-1.16.0.tar.gz
# cd nginx-1.16.0/
./configure --prefix=/data/server/nginx-1.16.0 \
--sbin-path=/data/server/nginx-1.16.0/sbin/nginx \
--conf-path=/data/server/nginx-1.16.0/nginx.conf \
--pid-path=/data/server/nginx-1.16.0/nginx.pid \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--http-proxy-temp-path=/var/tmp/nginx/proxy/ \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--with-select_module \
--with-poll_module \
--error-log-path=/data/logs/nginx/error.log \
--http-log-path=/data/logs/nginx/access.log \
--with-pcre
# make && make install
2.4ソフトリンクの確立後のアップグレードが便利で、ソフトリンクの確立
# ln -sv /data/server/nginx-1.16.0 /data/server/nginx
2.5 nginxにSysV init起動スクリプトを提供する
新しいファイル/etc/rc.d/init.d/nginx、内容は以下の通りです.
#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /data/server/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /data/server/nginx/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/data/server/nginx/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/data/server/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
make_dirs() {
# make required directories
user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -`
options=`$nginx -V 2>&1 | grep 'configure arguments:'`
for opt in $options; do
if [ `echo $opt | grep '.*-temp-path'` ]; then
value=`echo $opt | cut -d "=" -f 2`
if [ ! -d "$value" ]; then
# echo "creating" $value
mkdir -p $value && chown -R $user $value
fi
fi
done
}
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
make_dirs
echo -n $"Starting $prog: "
daemon $nginx -c $NGINX_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
configtest || return $?
stop
sleep 1
start
}
reload() {
configtest || return $?
echo -n $"Reloading $prog: "
killproc $nginx -HUP
RETVAL=$?
echo
}
force_reload() {
restart
}
configtest() {
$nginx -t -c $NGINX_CONF_FILE
}
rh_status() {
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
case "$1" in
start)
rh_status_q && exit 0
$1
;;
stop)
rh_status_q || exit 0
$1
;;
restart|configtest)
$1
;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit 2
esac
2.6このスクリプトに実行権限を付与する
# chmod +x /etc/rc.d/init.d/nginx
2.7サービス管理リストに追加し、電源を入れて自動的に起動させる:
# chkconfig --add nginx
# chkconfig nginx on
2.8 nginxサービスの開始
# service nginx start
2.9 PATH環境変数の構成
# echo 'export PATH=$PATH://data/server/nginx/sbin/' > /etc/profile.d/nginx.sh
# source /etc/profile.d/nginx.sh
2.10 nginxの構成
nginx , ,
# vim /data/server/nginx/nginx.conf
user nginx nginx;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
tcp_nopush on;
keepalive_timeout 65;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
include /data/server/nginx/conf.d/*.conf;
}
#
# mkdir /data/server/nginx/conf.d/
# mkdir -pv data/logs/nginx/{access,error}
#
# vim /data/server/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
index index.html;
root /data/webapps;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
access_log /data/logs/nginx/access/default.log main;
error_log /data/logs/nginx/error/default.log;
#
include /data/server/nginx/conf.d/rewrite/default.conf;
}
#
# vim /data/server/nginx/conf.d/rewrite/default.conf
rewrite ^(.*)-htm-(.*)$ $1.php?$2 last;
rewrite ^(.*)/simple/([a-z0-9\_]+\.html)$ $1/simple/index.php?$2 last;
rewrite ^(.*)/data/(.*)\.(htm|php)$ 404.html last;
rewrite ^(.*)/attachment/(.*)\.(htm|php)$ 404.html last;
rewrite ^(.*)/html/(.*)\.(htm|php)$ 404.html last;
#
# echo 'test nginx' > /data/webapps/index.html
# nginx -t
# service nginx restart
三、mysqlのインストール
3.1他のバージョンのmysqlまたはmariadbがインストールされているかどうかを確認します.
# rpm -qa|grep mariadb
mariadb-libs-5.5.52-1.el7.x86_64
# rpm -e --nodeps mariadb-libs-5.5.52-1.el7.x86_64
3.2 mysqlユーザーとグループの確立
# groupadd mysql
# useradd -r -g mysql mysql
3.3 mysqlのダウンロードとインストール
# wget https://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz
# tar xf mysql-5.6.44-linux-glibc2.12-x86_64.tar.gz
# mv mysql-5.6.44-linux-glibc2.12-x86_64 /data/server/mysql-5.6.44
# ln -sv /data/server/mysql-5.6.44 /data/server/mysql
# chown -R mysql.mysql /data/server/mysql*
3.4環境変数の構成
# echo "export PATH=$PATH:/data/server/mysql/bin" > /etc/profile.d/mysql.sh
# source /etc/profile.d/mysql.sh
3.5 mysqlプロファイルを次のように編集します.
# vim /etc/my.cnf
[mysqld]
basedir=/data/server/mysql
datadir=/data/mysql
socket=/data/server/mysql/mysql.sock
log-error=/data/logs/mysql/error.log
pid-file=/data/logs/mysql/mysql.pid
symbolic-links=0
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = 'SET NAMES utf8'
character-set-server = utf8
max_connections=1000
max_connect_errors=10000
thread_cache_size=100
thread_stack=192K
ssl=false
max_allowed_packet=60M
max_heap_table_size=64M
max_length_for_sort_data=8M
net_buffer_length=65536
skip-name-resolve ##ip/localhost
skip-external-locking ##system lock
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
[client]
socket=/data/server/mysql/mysql.sock
[mysql]
socket=/data/server/mysql/mysql.sock
3.6起動スクリプトの準備
# cp /data/server/mysql/support-files/mysql.server /etc/init.d/mysqld
# vim /etc/init.d/mysqld # basedir datadir /etc/my.cnf
…………
basedir=/data/server/mysql datadir=/data/mysql
…………
#
# chkconfig --add mysqld
3.7 mysqlの初期化
# mysql_install_db --user=mysql --basedir=/data/server/mysql/ --datadir=/data/mysql
3.8 mysqlを起動し、起動時の自己起動を設定する
# service enable mysqld && service sttart mysqld
mysql> delete from mysql.user where user = '' or host = '::1';
3.8 mysqlを使用したインストールがシステム使用仕様に適合し、その開発コンポーネントをシステム使用にエクスポートするには、以下の手順が必要です.
mysql man man :
/etc/man.config, :
# echo "/data/server/mysql/man" >> /etc/man_db.conf
mysql /usr/include:
:
# ln -sv /data/server/mysql/include /usr/include/mysql
mysql :
# echo '/data/server/mysql/lib' > /etc/ld.so.conf.d/mysql.conf
:
# ldconfig
四、phpのインストール
4.1 phpのダウンロード
# wget http://cn2.php.net/distributions/php-7.1.11.tar.gz
4.2依存拡張パッケージのインストール
# yum -y install libmcrypt libmcrypt-devel mhash mhash-devel mcrypt libxml2-devel bzip2-devel libcurl-devel libjpeg-devel libpng libpng-devel freetype freetype-devel libmcrypt libmcrypt-devel
4.3コンパイルインストールphp
# tar xf php-7.1.11.tar.gz
# cd /root/php-7.1.11
# ./configure --prefix=/data/server/php-7.1.11 \
--with-config-file-path=/data/server/php-7.1.11/etc \
--enable-fpm \
--with-mcrypt \
--enable-mbstring \
--enable-pdo \
--with-curl \
--disable-debug \
--disable-rpath \
--enable-inline-optimization \
--with-bz2 \
--with-zlib \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--with-mhash \
--enable-zip \
--with-pcre-regex \
--with-mysqli=/data/server/mysql/bin/mysql_config \
--with-gd \
--with-jpeg-dir \
--with-freetype-dir \
--with-png-dir \
--enable-calendar \
--with-openssl \
--with-bcmath \
--with-gettext
# make && make install
# ln -sv /data/server/php-7.1.11 /data/server/php
4.4 phpプロファイルの準備
# cp php.ini-production /data/server/php/etc/php.ini
4.5 php-fpmのプロファイルを提供する:
# cp /data/server/php/etc/php-fpm.conf.default /data/server/php/etc/php-fpm.conf
4.6 php-fpmのプロファイルを編集する:
# vim /data/server/php/etc/php-fpm.conf
pid
……
[global]
pid = run/php-fpm.pid
……
# cp /data/server/php/etc/php-fpm.d/www.conf.default /data/server/php/etc/php-fpm.d/www.conf
4.7環境変数の設定
# echo 'export PATH=$PATH:/data/server/php/sbin' > /etc/profile.d/php-fpm.sh
# echo 'export PATH=/data/server/php/bin:$PATH' >> /etc/profile.d/php-fpm.sh
# source /etc/profile.d/php-fpm.sh
4.8 php-fpmにSysv initスクリプトを提供し、サービスリストに追加する:
# cp sapi/fpm/init.d.php-fpm /etc/rc.d/init.d/php-fpm
# chmod +x /etc/rc.d/init.d/php-fpm
# chkconfig --add php-fpm
# chkconfig php-fpm on
php-fpm :
# systemctl start php-fpm
五、nginxとphp 5を統合する
5.1 nginxを編集する.conf、次のオプションを有効にします.
# vi /data/server/nginx/nginx.conf
location ~ \.(php|php5)$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
5.2編集/data/server/nginx/fastcgi_params、その内容を次のように変更します.
# cp fastcgi_params{,.bak}
# vim /data/server/nginx/fastcgi_params
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
php , :
location / {
root html;
index index.php index.html index.htm;
}
5.3完全なプロファイルは次のとおりです.
# cat /data/server/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;
index index.php index.html index.htm;
root /data/webapps;
location ~ \.(php|php5)$ {
root /data/webapps;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 1h;
}
access_log /data/logs/nginx/access/default.log main;
error_log /data/logs/nginx/error/default.log;
}
nginx :
# service nginx reload
5.4/data/webappsでindexを新規作成する.phpのテストページ、phpが正常に動作するかどうか、データベースに接続できるかどうかをテストします.
mysql> create user 'test'@'localhost' identified by 'test123';
mysql> flush privileges;
。
# vim /data/webapps/index.php
php
$servername = "localhost";
$username = "test";
$password = "test123";
//
$conn = new mysqli($servername, $username, $password);
//
if ($conn->connect_error) {
die(" : " . $conn->connect_error);
}
echo " ";
?>
php
phpinfo();
?>
六、php拡張をインストールし、php
xcacheはphp 7をサポートしていない.1になったら、php原生のopcacheを使って代わります
# vim /data/server/php/etc/php.ini
zend_extension=opcache.so
[opcache]
; opcache
opcache.enable=1
;CLI ,PHP OPcache
opcache.enable_cli=1
;OPcache , MB
opcache.memory_consumption=128
;PHP (string interning) 。 , 1000 “foobar”, PHP , 999 。 —— php-fpm , , php-fpm 。 , , 。
(megabytes) , 16, 16MB, 4MB
opcache.interned_strings_buffer=8
; PHP 。 , PHP 。
200, PHP 5.5.6 100000,PHP 5.5.6 1000000。 200 1000000 。
opcache.max_accelerated_files=4000
; ( ), 0
opcache.revalidate_freq=60
; “ ”。 , PHP PHP , 。 1 。
opcache.fast_shutdown=1
; ( 1),OPcache opcache.revalidate_freq (timestamp) 。
( 0),opcache.revalidate_freq ,PHP 。 , , ,
0, , PHP web 。
opcache.validate_timestamps=0
; Opcache File Cache( ), , Opcache opcode , , .
PHP /tmp Cache Opcode , PHP .
opcache.file_cache=/tmp
6.2 php-fpmの再起動
# service php-fpm restart
七、サードパーティphp拡張モジュールのインストール方法
7.1ソースパッケージにインストールされた拡張モジュールbcmatch
# cd /tmp/lnmp/php-7.1.11/ext/bcmath/
# /data/server/php/bin/phpize
# ./configure --with-php-config=/data/server/php/bin/php-config
# make && make install
Installing shared extensions: /data/server/php-7.1.11/lib/php/extensions/no-debug-non-zts-20160303/
# ls -lhrt/data/server/php-7.1.11/lib/php/extensions/no-debug-non-zts-20160303/ total 5.2M -rwxr-xr-x 1 root root 3.3M Jul 16 14:11 opcache.a -rwxr-xr-x 1 root root 1.6M Jul 16 14:11 opcache.so -rwxr-xr-x 1 root root 357K Jul 16 16:56 bcmath.so -rwxr-xr-x 1 root root 52K Jul 16 20:07 gettext.so
7.2プロファイルの編集、有効化
# vim /data/server/php-7.1.11/etc/php.ini
[bcmath]
extension=bcmath.so
第2部:zabbixインストール
1、Zabbix Serverのインストール
1.1依存パッケージのインストール
# yum -y install net-snmp gcc mysql-devel libxml2-devel net-snmp-devel libevent-devel curl-devel
1.2ソフトウェアパッケージのダウンロード
# wget https://sourceforge.net/projects/zabbix/files/ZABBIX%20Latest%20Stable/4.0.10/zabbix-4.0.10.tar.gz/download
1.3ユーザーの作成
# groupadd --system zabbix
# useradd --system -g zabbix -M -s /sbin/nologin -c "Zabbix Monitoring System" zabbix
1.4データベースの作成
mysql> create database zabbix character set utf8 collate utf8_bin;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
1.5データベースのインポート
# cd database/mysql
# mysql -uzabbix -pzabbix zabbix < schema.sql
# stop here if you are creating database for Zabbix proxy
# mysql -uzabbix -pzabbix zabbix < images.sql
# mysql -uzabbix -pzabbix zabbix < data.sql
1.6コンパイルインストール
# tar -zxvf zabbix-4.0.10.tar.gz
# ./configure --help
./configure --prefix=/data/server/zabbix-4.0.10 \
--enable-server \
--enable-agent \
--with-mysql \
--enable-ipv6 \
--with-net-snmp \
--with-libcurl \
--with-libxml2
# make install
# ln -sv /data/server/zabbix-4.0.10 /data/server/zabbix
1.7環境変数の構成
# echo 'export PATH=$PATH:/data/server/zabbix/sbin' > /etc/profile.d/zabbix.sh
# source /etc/profile.d/zabbix.sh
1.8 zabbix_の編集server.conf
# vim /data/server/zabbix/etc/zabbix_server.conf
DBPassword=zabbix
1.9 zabbixのWebサーバディレクトリへのWebファイルのコピーのインストール
# mkdir /data/webapps/zabbix
# cp -ap frontends/php/* /data/webapps/zabbix/
1.10 php構成を編集してzabbixの要求を満たす
# vim /data/server/php/etc/php.ini
post_max_size = 16M
max_execution_time = 300
max_input_time = 300
1.11 zabbix serverの起動スクリプトの準備
# vim /etc/rc.d/init.d/zabbix_server
#!/bin/sh
#
# zabbix server - this script starts and stops the zabbix server daemon
#
# chkconfig: - 85 15
# description: Zabbix Server is an Monitor server
# processname: zabbix
# config: /data/server/zabbix/etc/zabbix_server.conf
# pidfile: /tmp/zabbix_server.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
zabbix_server="/data/server/zabbix/sbin/zabbix_server"
prog=$(basename $zabbix_server)
ZABBIX_SERVER_CONF_FILE="/data/server/zabbix/etc/zabbix_server.conf"
lockfile=/var/lock/subsys/zabbix_server
start() {
[ -x $zabbix_server ] || exit 5
[ -f $ZABBIX_SERVER_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $zabbix_server -c $ZABBIX_SERVER_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
sleep 1
start
}
rh_status() {
status $prog
}
case "$1" in
start)
rh_status && exit 0
$1
;;
stop)
rh_status || exit 0
$1
;;
restart)
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
1.12 zabbixの起動server
# chkconfig --add zabbix_server
# chkconfig zabbix_server on
# service zabbix_server start
2、zabbix agentのインストール
2.1インストールagentのコンパイル
# ./configure --prefix=/data/server/zabbix-4.0.10 \
--enable-agent \
--with-mysql \
--enable-ipv6 \
--with-net-snmp \
--with-libcurl \
--with-libxml2
# make install
2.2プロファイルの編集
# vim /data/server/zabbix/etc/zabbix_agentd.conf
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
2.3 zabbixの準備Agentd起動スクリプト
# vim /etc/rc.d/init.d/zabbix_agentd
#!/bin/sh
#
# zabbix agent - this script starts and stops the zabbix agent daemon
#
# chkconfig: - 85 15
# description: Zabbix agentd is an Monitor agent
# processname: zabbix_agentd
# config: /data/server/zabbix/etc/zabbix_agentd.conf
# pidfile: /tmp/zabbix_agentd.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
zabbix_agentd="/data/server/zabbix/sbin/zabbix_agentd"
prog=$(basename $zabbix_agentd)
ZABBIX_AGENTD_CONF_FILE="/data/server/zabbix/etc/zabbix_agentd.conf"
lockfile=/var/lock/subsys/zabbix_agentd
start() {
[ -x $zabbix_agentd ] || exit 5
[ -f $ZABBIX_AGENTD_CONF_FILE ] || exit 6
echo -n $"Starting $prog: "
daemon $zabbix_agentd -c $ZABBIX_AGENTD_CONF_FILE
retval=$?
echo
[ $retval -eq 0 ] && touch $lockfile
return $retval
}
stop() {
echo -n $"Stopping $prog: "
killproc $prog -QUIT
retval=$?
echo
[ $retval -eq 0 ] && rm -f $lockfile
return $retval
}
restart() {
stop
sleep 1
start
}
rh_status() {
status $prog
}
case "$1" in
start)
rh_status && exit 0
$1
;;
stop)
rh_status || exit 0
$1
;;
restart)
$1
;;
status)
rh_status
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 2
esac
2.4 zabbixの起動agent
# chkconfig --add zabbix_agentd
# chkconfig zabbix_agentd on
# service zabbix_agentd start
参照リンク:https://www.zabbix.com/documentation/4.0/manual/installation/install
転載先:https://www.cnblogs.com/fang9045315/p/11202155.html