Nginx + ElasticSearch + Kibana结合

Nginx + ElasticSearch + Kibana结合

  1. 操作系统
  2. 软件下载
  3. 安装编译工具及库文件
  4. 安装 PCRE
  5. 安装 Nginx
  6. ElasticSearch配置
  7. Kibana配置
  8. Nginx配置
  9. 启动Nginx

对人工智能感兴趣点下面链接

现在人工智能非常火爆,很多朋友都想学,但是一般的教程都是为博硕生准备的,太难看懂了。最近发现了一个非常适合小白入门的教程,不仅通俗易懂而且还很风趣幽默。所以忍不住分享一下给大家。点这里可以跳转到教程。

https://www.cbedai.net/u014646662

1 操作系统

Centos7.6

2 软件下载

prec: https://sourceforge.net/projects/pcre/files/pcre/

nginx: http://nginx.org/en/download.html

本次安装包(放置/opt):

Prec:pcre-8.43.tar.gz

Nginx:nginx-1.17.3.tar.gz

3 安装编译工具及库文件

yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel

4 安装 PCRE

解压安装包:

tar zxvf pcre-8.43.tar.gz
mv pcre-8.43 pcre
cd pcre

编译安装:

./configure

make && make install

查看版本

pcre-config --version

5 安装 Nginx

解压安装包:

tar zxvf nginx-1.17.3.tar.gz

mv nginx-1.17.3 nginx

cd nginx

编译安装:

./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-pcre=/opt/pcre

make

make install

查看版本

/usr/local/nginx/sbin/nginx -v

6 ElasticSearch配置

进入nginx配置目录

cd /usr/local/nginx/conf

创建文件:vim es.conf

upstream es.com.cn {
    server elk01:9200 weight=1;    
    server elk02:9200 weight=1;
    server elk03:9200 weight=1;
}
  
server {
    listen 80;
    server_name es.com.cn;
    access_log logs/bbs.access.log;
    error_log logs/bbs.error.log;
    #root html;
    #index index.html index.htm index.jsp index.php;
  
    location / {
        proxy_pass http://es.com.cn; #这里的http://es.com.cn与上面的upstream要一样
  
        #Proxy Settings
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout 90;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
    }
}

 

7 Kibana配置

如果要需要认证:

安装

yum install httpd-tools

添加用户(第一个用户需要加 -c,再次添加不需要 -c)

htpasswd -c -b  /usr/local/nginx/conf/htpasswd.users username password

进入nginx配置目录

cd /usr/local/nginx/conf

创建文件:vim es.conf

upstream kibana.com.cn {
    server elk01:5601;    
    server elk02:5601;
    server elk03:5601;
}
  
server {
    listen 5601;
    server_name kibana.com.cn;
    access_log logs/bbs.access.log;
    error_log logs/bbs.error.log;
    #root html;
    #index index.html index.htm index.jsp index.php;
  
    location / {
        proxy_pass http://kibana.com.cn; #这里的http://kibana.com.cn与上面的upstream要一样
        #下面三行有登录验证的配置
        auth_basic "login";
        auth_basic_user_file /usr/local/nginx/conf/htpasswd.users;#自己配置的文件
        autoindex on;
        #Proxy Settings
        proxy_redirect off;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
        proxy_max_temp_file_size 0;
        proxy_connect_timeout 90;
        proxy_send_timeout 90;
        proxy_read_timeout 90;
        proxy_buffer_size 4k;
        proxy_buffers 4 32k;
        proxy_busy_buffers_size 64k;
        proxy_temp_file_write_size 64k;
    }
}

 

8 Nginx配置

进入nginx配置目录

cd /usr/local/nginx/conf

编辑 vim nginx.conf

#user  nobody;
worker_processes  8; #cpu核数

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  65535;
}


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;

    #加载es
    include es.conf;
    include kibana.conf;

    ……下面内容省略

}

9 启动Nginx

创建pid文件

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

启动(重新加载配置文件)

/usr/local/nginx/sbin/nginx -s reload

 

 

 

 

 

 

 

 

发布了139 篇原创文章 · 获赞 273 · 访问量 666万+

猜你喜欢

转载自blog.csdn.net/u014646662/article/details/99722710