需求背景

前几天FE节点频繁挂掉导致datax任务大量失效,然后查看Doris管网三种负载均衡
jdbc链接试用于客户端操作负载
由于内网环境且已经有Nginx安装包了所以用Nginx

安装Nginx(带stream模块)

  1. 进入soft_pkg目录
    cd /opt/soft_pkg
  2. 上传zlib-1.2.8.tar.gz,pcre-8.32.tar.gz,openssl-1.0.2k.tar.gz,nginx-1.18.0.tar.gz到soft_pkg         

  3. 编辑openssl,依次执行以下命令
    tar -zxf  openssl-1.0.2k.tar.gz
    cd openssl-1.0.2k
    ./config && make && make install
  4. 编辑zlib,依次执行以下命令
    tar -zxf  zlib-1.2.8.tar.gz
    cd zlib-1.2.8
    ./configure && make && make install
  5. 编辑pcre,依次执行以下命令
    tar -zxf pcre-8.32.tar.gz
    cd pcre-8.32
    ./configure && make && make install
  6. 编辑nginx,依次执行以下命令
    tar -zxf nginx-1.18.0.tar.gz
    cd nginx-1.18.0
    #安装到/usr/local
    ./configure --prefix=/usr/local/nginx --with-pcre=../pcre-8.32 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-1.0.2k --with-poll_module --with-stream --with-stream_ssl_module --with-http_stub_status_module --with-http_ssl_module
    

Doris查看FE节点命令

Nginx负载均衡配置文件


worker_processes  1;

events {
    worker_connections  1024;
}

# doris三台FE节点负载均衡
stream {
  upstream mysqld {
    # hash $remote_addr consistent;
    server 1xx.1.2x.xx:8030 weight=1 max_fails=2 fail_timeout=60s;
    server 1xx.1.2x.1xx:8030 weight=1 max_fails=2 fail_timeout=60s;
    # server 1xx.1.2x.2xx9:8030 weight=1 max_fails=2 fail_timeout=60s;
	server 1xx.1.2x.2xx:8030 backup;
    ##注意这里如果是多个FE,加载这里就行了
  }
  ###这里是配置代理的端口,超时时间等
  server {
      listen 6030;
      proxy_connect_timeout 300s;
      proxy_timeout 300s;
      proxy_pass mysqld;
  }
  upstream mysqld2 {
    server 1xx.1.2x.xx:9030 weight=1 max_fails=2 fail_timeout=60s;
    server 1xx.1.2x.1xx:9030 weight=1 max_fails=2 fail_timeout=60s;
    server 1xx.1.2x.2xx:9030 backup;
  }
  server {
      listen 7030;
      proxy_connect_timeout 300s;
      proxy_timeout 300s;
      proxy_pass mysqld2;
  }
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log  logs/access.log  main;

    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;

        location / {
            root   html;
            index  index.html index.htm;
        }
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
       
    }
	include /usr/local/nginx/conf/nginx_*.conf;
}

Nginx常用命令

启动服务 sbin目录下:./usr/local/nginx/sbin/nginx
退出服务:nginx -s quit
强制关闭服务:nginx -s stop
重载服务:nginx -s reload(重载服务配置文件,类似于重启,但服务不会中止)
验证配置文件:nginx -t
使用配置文件:nginx -c “配置文件路径”
使用帮助:nginx -h

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐