ELK——在 CentOS/Linux 把 Kibana 3.0 部署在 Nginx 1.9.12

遷移到:http://www.bdata-cap.com/newsinfo/1712690.html

上一篇文章《安裝 logstash 2.2.0、elasticsearch 2.2.0 和 Kibana 3.0》,介紹瞭如何安裝 Logstash、Elasticsearch 以及用 Python 的 SimpleHTTPServer 模塊部署 Kibana。html

本文介紹如何在 Linux 上把 Kibana 部署在 Nginx。linux

假設,我機器 IP 是 10.1.8.166,Kibana 和 Nginx 都安裝在這個機器上。nginx

  • 下載 Nginx。下載 Nginx,並上傳到你的服務器上,我放在 /usr/local/src/nginx。
  • 解壓 Nginx。
[root@vcyber nginx]# pwd
 
/usr/local/src/nginx
 
[root@vcyber nginx-1.9.12]# tar -zxvf nginx-1.5.9.tar.gz 
 
[root@vcyber nginx]# ls
 
nginx-1.9.12  nginx-1.9.12.tar.gz
 
[root@vcyber nginx]#
  • 配置 Nginx。指定把 Nginx 安裝到 /usr/local/nginx。
[root@vcyber nginx]# cd nginx-1.9.12
 
[root@vcyber nginx-1.9.12]# ls
 
auto     CHANGES.ru  configure  html     Makefile  objs    src
 
CHANGES  conf        contrib    LICENSE  man       README
 
[root@vcyber nginx-1.9.12]# ./configure --prefix=/usr/local/nginx
 
checking for OS
 
 + Linux 2.6.32-504.23.4.el6.x86_64 x86_64
 
checking for C compiler ... found
 
 + using GNU C compiler
 
 + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
 
checking for gcc -pipe switch ... found
 
checking for -Wl,-E switch ... found
 
checking for gcc builtin atomic operations ... found
 
checking for C99 variadic macros ... found
 
checking for gcc variadic macros ... found
 
checking for gcc builtin 64 bit byteswap ... found
 
checking for unistd.h ... found
 
……
 
./configure: error: the HTTP rewrite module requires the PCRE library.
 
You can either disable the module by using --without-http_rewrite_module
 
option, or install the PCRE library into the system, or build the PCRE library
 
statically from the source with nginx by using --with-pcre=<;path> option.
 
[root@vcyber nginx-1.9.12]#

具體配置參數,參看 http://nginx.org/en/linux_packages.html瀏覽器

報錯了~說,HTTP rewrite 模塊須要 pcre-devel 庫。安裝一個就行。由於我機器用了有段時間,也懶得看是否有,總之,沒有再安裝。服務器

  • 安裝 PCRE 庫。
[root@vcyber bin]# yum -y install pcre-devel
 
Loaded plugins: fastestmirror
 
Setting up Install Process
 
Loading mirror speeds from cached hostfile
 
 * base: mirrors.yun-idc.com
 
 * epel: mirrors.yun-idc.com
 
 * extras: mirrors.yun-idc.com
 
 * updates: mirrors.yun-idc.com
 
Resolving Dependencies
 
-->; Running transaction check
 
--->; Package pcre-devel.x86_64 0:7.8-7.el6 will be installed
 
-->; Finished Dependency Resolution
 
……
 
Complete!
 
[root@vcyber bin]#

Nginx 除了依賴 pcre-devel 庫,還有 openssl、openssl-devel、zlib-devel、gcc。若是你的機器上沒有,就用 yum 安裝一下。app

  • 再試一次
[root@vcyber nginx-1.9.12]# ls
auto     CHANGES.ru  configure  html     Makefile  objs    src
CHANGES  conf        contrib    LICENSE  man       README
[root@vcyber nginx-1.9.12]# ./configure --prefix=/usr/local/nginx
checking for OS
 + Linux 2.6.32-504.23.4.el6.x86_64 x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-16) (GCC)
checking for gcc -pipe switch ... found
……
 
Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library
 
  nginx path prefix: "/usr/local/nginx"
  ……
 
[root@vcyber nginx-1.9.12]#

此次成功了~elasticsearch

  • 編譯安裝 Nginx。
[root@vcyber nginx-1.9.12]# make & make install
  • 檢查是否安裝成功。
[root@vcyber sbin]# pwd
 
/usr/local/nginx/sbin
 
[root@vcyber sbin]# ./nginx -t
 
nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
 
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
 
[root@vcyber sbin]#

顯示,OK 和 successful。tcp

  • 啓動 Nginx
[root@vcyber sbin]# ./nginx
 
[root@vcyber sbin]#

在瀏覽器地址欄輸入,訪問80端口,ui

2016-03-14_161825

  • 把 Kibana 部署到 Nginx。

 

 

 

 

 

 

 

其實,很簡單~只須要修改 Nginx 配置 nginx.conf 的 server 小節便可。下面配置文件,是截取,並不完整。atom

[root@vcyber conf]# pwd
/usr/local/nginx/conf
[root@vcyber conf]# cat nginx.conf
 
#user  nobody;
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"';
 
   
  
    #access_log  logs/access.log  main;
 
    sendfile        on;
    #tcp_nopush     on;
 
    #keepalive_timeout  0;
    keepalive_timeout  65;
 
    #gzip  on;
 
   
  
    server {
        listen       80;
        server_name  localhost;
 
        #charset koi8-r;
 
   
  
        #access_log  logs/host.access.log  main;
 
        location / {
            #root   html;
            root /usr/local/kibana/kibana-3.0/src;
            index  index.html index.htm;
        }
        ……
    }
 
    ……
}
[root@vcyber conf]#

server.location 下的 root,指向你 Kibana 的位置,必須是 Kibana 的 src 位置。

 

安裝 logstash 2.2.0、elasticsearch 2.2.0 和 Kibana 3.0

爲調試 Logstash Grok 表達式,安裝 GrokDebuger 環境

相關文章
相關標籤/搜索