zabbix分散式監控環境完全編譯安裝部署
很多文件使用的是yum安裝mysql、http、php等工具。這裡採用原始碼安裝的形式,實現從LNMP-zabbix的全程記錄。
一、LNMP平臺搭建
參考:http://www.ttlsa.com/nginx/nginx-install-on-linux/
http://swht1278.blog.51cto.com/7138082/1623886
1.nginx的安裝
1.1 依賴環境的部署
yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel pcre-devel pcre-static gd-*
1.2 建立nginx使用者及使用者組
groupadd -r nginx && useradd -s /sbin/nologin -g nginx -r nginx
1.3 下載最新nginx安裝包
wget -P /usr/local/src/ http://nginx.org/download/nginx-1.9.1.tar.gz
1.4 編譯安裝nginx
cd /usr/local/src/ && tar xf nginx-1.9.1.tar.gz
./configure –prefix=/usr/local/nginx –lock-path=/usr/local/nginx/nginx.lock –user=nginx –group=nginx –with-http_ssl_module –with-http_flv_module –with-http_stub_status_module –with-http_gzip_static_module –http-client-body-temp-path=/usr/local/nginx/client/ –http-proxy-temp-path=/usr/local/nginx/proxy/ –http-fastcgi-temp-path=/usr/local/nginx/fcgi/ –http-uwsgi-temp-path=/usr/local/nginx/uwsgi –http-scgi-temp-path=/usr/local/nginx/scgi –with-pcre –with-file-aio –with-http_image_filter_module && make && make install
1.5 nginx啟動指令碼
==============================
vim /etc/init.d/nginx chmod +x /etc/init.d/nginx
#!/bin/bash
#
# Startup script for 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: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/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=”/usr/local/nginx/sbin/nginx”
prog=$(basename $nginx)
NGINX_CONF_FILE=”/usr/local/nginx/conf/nginx.conf”
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
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
==================================================
1.6 nginx的啟動和關閉
service nginx start|reload|restart|stop
chkcofnig nginx on
或者:
啟動 /usr/local/nginx-1.5.1/sbin/nginx
關閉 /usr/local/nginx-1.5.1/sbin/nginx -s stop
重啟 /usr/local/nginx-1.5.1/sbin/nginx -s reload
2.mysql的安裝
參考:二進位制原始碼包安裝mysql連線 http://www.ttlsa.com/mysql/install-mysql5_6/
自定義編譯原始碼包安裝mysql連線:http://swht1278.blog.51cto.com/7138082/1658992
2.1 編譯環境安裝(適用於最小化安裝的Linux系統)
yum -y install wget gcc* make openssl openssl-devel openssl-clients ncurses-devel -y && yum groupinstall ” Development tools”
2.2 mysql原始碼下載
wget -P /usr/local/src/ http://cdn.mysql.com/Downloads/MySQL-5.6/mysql-5.6.20.tar.gz
#wget -P /usr/local/src/ http://mirrors.sohu.com/mysql/MySQL-5.6/mysql-5.6.25.tar.gz
wget -P /usr/local/src/ http://down1.chinaunix.net/distfiles/cmake-2.8.10.2.tar.gz
2.3 原始碼安裝cmake編譯環境
cd /usr/local/src/ && tar xf cmake-2.8.10.2.tar.gz
cd cmake-2.8.10.2 && ./configure –prefix=/usr/local/cmake && make && make install
vim /etc/profile
#set cmake
export PATH==$PATH:/usr/local/cmake/bin
source /etc/profile
2.4 原始碼安裝mysql-5.6
groupadd mysql && useradd -r -g mysql -s /etc/nologin mysql #(建立mysql使用者不需要密碼和登入系統)
mkdir -p /home/mysql/data && mkdir /home/mysql/var
cd /usr/local/src/ && tar xf mysql-5.6.20.tar.gz && cd mysql-5.6.20
cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/home/mysql/data -DSYSCONFDIR=/etc -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system -DWITH_LIBWRAP=0 -DMYSQL_UNIX_ADDR=/home/mysql/var/mysql.sock -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci && make && make install
編譯報錯解決參考:http://blog.163.com/sz2273_pr/blog/static/41264296201361354426670/
環境變數配置
vim /etc/profile
在末行新增export PATH=$PATH:/usr/sbin/:/usr/local/mysql/bin
儲存退出執行:source /etc/profile
2.5 初始化資料庫
/usr/local/mysql/scripts/mysql_install_db –basedir=/usr/local/mysql –datadir=/home/mysql/data –user=mysql –default-storage-engine=MyISAM
2.6 修改配置檔案my.cnf
============================================
vim /etc/my.cnf
[client]
default-character-set=utf8
#auto-rehash
socket = /home/mysql/var/mysql.sock
[mysqld]
# GENERAL #
user = mysql
slave-skip-errors=1022,1032,1062
basedir = /usr/local/mysql
default-storage-engine = MyISAM
socket = /home/mysql/var/mysql.sock
pid-file = /home/mysql/var/mysql.pid
port = 3306
# MyISAM #
key_buffer_size = 1344M
myisam_recover = FORCE,BACKUP
# SAFETY #
max_allowed_packet = 16M
max_connect_errors = 1000000
skip_name_resolve
# DATA STORAGE #
datadir = /home/mysql/data
long_query_time = 1
# BINARY LOGGING #
log-bin = /home/mysql/data/mysql-bin.log
expire-logs-days = 14
sync-binlog = 1
server-id = 1
max_binlog_size = 500M
# REPLICATION #
relay-log = /home/mysql/data/relay-bin.log
slave-net-timeout = 60
# CACHES AND LIMITS #
tmp_table_size = 32M
max_heap_table_size = 32M
max_connections = 500
thread_cache_size = 50
open_files_limit = 65535
table_definition_cache = 4096
table_open_cache = 4096
# INNODB #
innodb_data_file_path = ibdata1:128M;ibdata2:10M:autoextend
innodb_flush_method = O_DIRECT
innodb_log_files_in_group = 2
innodb_lock_wait_timeout = 50
innodb_log_file_size = 256M
innodb_flush_log_at_trx_commit = 1
innodb_file_per_table = 1
innodb_thread_concurrency = 8
innodb_buffer_pool_size = 8G
# LOGGING #
log-error = /home/mysql/data/mysql-error.log
log-queries-not-using-indexes = 1
slow-query-log = 1
long_query_time = 1
slow-query-log-file = /home/mysql/data/mysql-slow.log
# FOR SLAVE #
#binlog-format = ROW
#log-slave-updates = true
#gtid-mode = on
#enforce-gtid-consistency = true
#master-info-repository = TABLE
#relay-log-info-repository = TABLE
#sync-master-info = 1
#slave-parallel-workers = 2
#binlog-checksum = CRC32
#master-verify-checksum = 1
#slave-sql-verify-checksum = 1
#binlog-rows-query-log_events = 1
#report-port = 3306
#report-host = 10.1.1.10
============================================
2.7 mysql的啟動與關閉
cp support-files/mysql.server /etc/init.d/mysql && chmod +x /etc/init.d/mysql
service mysql start|stop|relaod|restart
chkconfig mysql on
3. PHP編譯安裝
參考:nginx連線PHP 5.5 http://www.ttlsa.com/nginx/nginx-php-5_5/
3.1 編譯環境安裝
yum install gcc make gd-devel libjpeg-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel -y
3.2 原始碼包下載
wget -P /usr/local/src/ http://cn2.php.net/distributions/php-5.6.9.tar.gz
3.3 編譯安裝php5.6.9
cd /usr/local/src/ && tar xf php-5.6.9.tar.gz && cd php-5.6.9
./configure –prefix=/usr/local/php-5.6.9 –with-config-file-path=/usr/local/php-5.6.9/etc –with-bz2 –with-curl –enable-ftp –enable-sockets –disable-ipv6 –with-gd –with-jpeg-dir=/usr/local –with-png-dir=/usr/local –with-freetype-dir=/usr/local –enable-gd-native-ttf –with-iconv-dir=/usr/local –enable-mbstring –enable-calendar –with-gettext –with-libxml-dir=/usr/local –with-zlib –with-pdo-mysql=mysqlnd –with-mysqli=mysqlnd –with-mysql=mysqlnd –enable-dom –enable-xml –enable-fpm –with-libdir=lib64 –enable-bcmath && make && make install
3.4 配置PHP
cp php.ini-production /usr/local/php-5.6.9/etc/php.ini
cp /usr/local/php-5.6.9/etc/php-fpm.conf.default /usr/local/php-5.6.9/etc/php-fpm.conf
=================================
開啟php.ini配置檔案,修改如下引數為如下值,否則zabbix安裝不了。
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300 #這個引數修改是在文件的第383行,相關資訊在本文件下面有介紹
date.timezone PRC
==============================
3.5 啟動PHP-fpm
/usr/local/php-5.6.9/sbin/php-fpm
3.6 nginx配置
===============================
location /
{
try_files $uri $uri/ /index.php?$args;
}
location ~ .*.(php)?$
{
expires -1s;
try_files $uri =404;
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass unix:/var/run/phpfpm.sock;
}
=================================
二、編譯安裝zabbix
2.1 依賴環境安裝
yum install net-snmp-devel libxml2-devel libcurl-devel -y
2.2 下載zabbix原始碼包
wget -p /usr/local/src/ http://jaist.dl.sourceforge.net/project/zabbix/ZABBIX%20Latest%20Stable/2.4.5/zabbix-2.4.5.tar.gz
2.3 編譯安裝zabbix
cd /usr/local/src/ && tar xf zabbix-2.4.5.tar.gz && cd zabbix-2.4.5
./configure –prefix=/usr/local/zabbix-2.4.5/ –enable-server –enable-agent –with-mysql –with-net-snmp –with-libcurl –with-libxml2 && make && make install
2.4 建立使用者
groupadd -r zabbix && useradd -s /sbin/nologin -g zabbix -r zabbix
2.5 初始化資料庫
mysql -uroot -pPasswd
mysql>create database zabbix default charset utf8;
mysql>quit;
mysql -uroot -pPasswd zabbix < database/mysql/schema.sql #初始化proxy庫
#初始化server庫
mysql -uroot -p zabbix < database/mysql/images.sql
mysql -uroot -p zabbix < database/mysql/data.sql
mysql設定密碼
$mysql
mysql>use mysql;
mysql>update user set password=password(`yzkj2015`) where user=`root`;
mysql> flush privileges;
2.6 配置zabbix
mkdir /etc/zabbix && cp conf/zabbix_server.conf /etc/zabbix/ && vim /etc/zabbix/zabbix_server.conf
==============
DBName=zabbix
DBUser=root
DBPassword=yzkj2015
DBPort=3306
==============
2.7 zabbix_server啟動
/usr/local/zabbix-2.4.5/sbin/zabbix_server
2.8 zabbix客戶端配置
建立使用者
groupadd -r zabbix && useradd -s /sbin/nologin -g zabbix -r zabbix
編譯安裝
cd /usr/local/src/ && tar xf zabbix-2.4.5.tar.gz && cd zabbix-2.4.5
./configure –prefix=/usr/local/zabbix-2.4.5/ –enable-agent && make && make install
修改配置檔案
vim /usr/local/zabbix-2.2.2/etc/zabbix_agentd.conf
Server=127.0.0.1 #被動接受某個IP地址的檢查
ServerActive=127.0.0.1 #主動將資料傳送給該IP地址
Hostname=Zabbix server
客戶端啟動
/usr/local/zabbix-2.4.5/sbin/zabbix_agentd
2.9 瀏覽器安裝
網站檔案拷貝
mkdir /home/zabbix && cp -rp /usr/local/src/zabbix-2.4.5/frontends/php/* /home/zabbix && cp /home/zabbix/conf/zabbix.conf.php.example /home/zabbix/conf/zabbix.conf.php
報錯PHP option max_input_time 60 300 Fail
解決:原因是php.ini檔案裡面有兩個引數,第一個max_input_time預設是-1,第二個則是預設為60,需要修改成300
121 ; max_input_time
122 ; Default Value: -1 (Unlimited)
123 ; Development Value: 60 (60 seconds)
124 ; Production Value: 60 (60 seconds)
125 max_input_time = 300
383 max_input_time = 300
報錯:Error connecting to database: No such file or directory
原因是:Database host寫成了localhost
解決:Database type MySQL
Database host 127.0.0.1
Database port 3306
Database name zabbix
User root #可以是zabbix,這樣安全,但要記得密碼要對應
Password *****
備註:這個地方的配置可以在/home/zabbix/conf/zabbix.conf.php中進行修改。路徑根據自己的實際情況進行設定查詢
2.10 使用預設賬號登入首頁
admin
zabbix
至此,zabbix的原始碼安裝實驗完成,接下來的將是對zabbix的配置進行學習,請參照另外文件。
參考文章:http://www.ttlsa.com/zabbix/install-zabbix-on-linux-5-ttlsa/
宣告:該文件僅供學習使用,對於參考文章作者表示衷心感謝,我這篇文件僅僅是對整個搭建過程進行細緻的引數調節,以及符合我們自身的生產情況。各位看官只關注學習就好~
相關文章
- Zabbix監控安裝部署
- 分散式監控系統Zabbix--完整安裝記錄 -新增apache監控分散式Apache
- 分散式監控系統Zabbix-完整安裝記錄 -新增埠監控分散式
- 【監控】Zabbix安裝
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄(6)-微信報警部署分散式
- 分散式監控系統Zabbix--完整安裝記錄 -新增web頁面監控分散式Web
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄(2)-新增mysql監控分散式MySql
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄(5)-郵件報警部署分散式
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄(1)分散式
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄(0)分散式
- zabbix的主動模式監控和zabbix-proxy分散式監控模式分散式
- Zabbix企業分散式監控工具分散式
- 編譯安裝zabbix編譯
- 分散式監控系統Zabbix--完整安裝記錄(7)-使用percona監控MySQL分散式MySql
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄 - 新增shell指令碼監控分散式指令碼
- centos6.2lnmp環境下安裝zabbix(中文環境)並且監控客戶端CentOSLNMP客戶端
- 編譯安裝LAMP環境編譯LAMP
- zabbix環境安裝搭建
- zabbix安裝中文環境
- 分散式監控系統之Zabbix proxy分散式
- 分散式監控系統Zabbix-新增windows監控主機分散式Windows
- 分散式監控系統之Zabbix基礎分散式
- zabbix監控客戶端安裝客戶端
- 分散式監控系統Zabbix-3.0.3-完整安裝記錄(4)-解決zabbix監控圖中出現中文亂碼問題分散式
- hadoop完全分散式環境搭建Hadoop分散式
- lnmp環境安裝-原始碼編譯LNMP原始碼編譯
- CPP編譯器安裝(Windows環境)編譯Windows
- 分散式監控系統Zabbix-圖形集中展示外掛Graphtree安裝筆記分散式筆記
- Zabbix 4.0企業級分散式監控實戰分散式
- 分散式監控系統之Zabbix基礎使用分散式
- zabbix一鍵安裝lnmp環境LNMP
- hbase2.0.4完全分散式環境搭建分散式
- hadoop 2.8.5完全分散式環境搭建Hadoop分散式
- 分散式監控系統之Zabbix主動、被動及web監控分散式Web
- zabbix agent原始碼編譯安裝原始碼編譯
- zabbix系統監控部署(上)
- Linux 環境下編譯安裝 RedisLinux編譯Redis
- opensuse linux安裝gcc編譯環境LinuxGC編譯