天天看點

基于Tengine-2.3.3 建構Nacos叢集

1,根據Dockerfile生成可運作的Tengine Docker鏡像包。

Dockerfile内容如下:

# 建立一個新的鏡像檔案,配置模闆:建立立的鏡像是以centos為基礎模闆
# 因為tengine必須運作在作業系統之上
FROM centos:7.9.2009

# 作者名  作者郵箱
MAINTAINER chinajeckxu <[email protected]>

#安裝依賴包
RUN yum -y install net-tools gcc openssl-devel pcre-devel zlib-devel make wget unzip nc tar

# 建立一個新目錄來存儲nginx檔案
RUN mkdir /usr/local/nginx

RUN mkdir /usr/local/nginx/tmp/

RUN mkdir /usr/local/nginx/tmp/proxy

RUN mkdir /usr/local/nginx/tmp/client

RUN mkdir /usr/local/nginx/tmp/fastcgi

RUN mkdir /usr/local/nginx/tmp/uwsgi

RUN mkdir /usr/local/nginx/tmp/scgi

RUN mkdir /tengine

RUN mkdir /tengine/tengine-2.3.3

WORKDIR /tengine

ADD tengine-2.3.3.tar.gz /tengine

WORKDIR /tengine/tengine-2.3.3

RUN ./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --with-http_ssl_module --with-http_v2_module --with-http_gzip_static_module --with-http_addition_module --with-stream --with-stream=dynamic --with-stream_ssl_module --with-stream_realip_module --with-http_dav_module --http-proxy-temp-path=/usr/local/nginx/tmp/proxy --http-client-body-temp-path=/usr/local/nginx/tmp/client --http-fastcgi-temp-path=/usr/local/nginx/tmp/fastcgi --http-uwsgi-temp-path=/usr/local/nginx/tmp/uwsgi --http-scgi-temp-path=/usr/local/nginx/tmp/scgi

RUN make

RUN make install

WORKDIR /usr/local/nginx/sbin

RUN ./nginx -V

RUN ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

VOLUME /tmp            

2,編寫Tengine配置檔案default.conf。

default.conf 檔案内容如下

load_module /usr/local/nginx/modules/ngx_stream_module.so;
events {
    worker_connections  1024;
}
http {
        upstream naocs-http-server  {
                server 192.168.125.243:8851;
                server 192.168.125.243:8853;
                server 192.168.125.243:8855;
        }
        server {
        listen 18848;
                location /nacos/ {
                        proxy_pass http://naocs-http-server;
                }
        }
}
stream {
        upstream naocs-grpc-server-9848  {
                server 192.168.125.243:9851;
                server 192.168.125.243:9853;
                server 192.168.125.243:9855;
        }
        server {
                listen 19848;
                proxy_pass naocs-grpc-server-9848;
        }
        upstream naocs-grpc-server-9849  {
                server 192.168.125.243:9852;
                server 192.168.125.243:9854;
                server 192.168.125.243:9856;
        }
        server {
                listen 19849;
                proxy_pass naocs-grpc-server-9849;
        }
}