概述

Nginx能够实现HTTP、HTTPS协议的负载均衡,也能够实现TCP协议的负载均衡。那么,问题来了,可不可以通过Nginx实现Apache Doris数据库的负载均衡呢?答案是:可以。接下来,就让我们一起探讨下如何使用Nginx实现Apache Doris的负载均衡。

环境准备

注意:使用Nginx实现Apache Doris数据库的负载均衡,前提是要搭建Apache Doris的环境,Apache Doris FE的IP和端口分别如下所示, 这里我是用一个FE来做演示的,多个FE只需要在配置里添加多个FE的IP地址和端口即可

IP: 172.31.7.119

端口: 9030

通过Nginx访问MySQL的Apache Doris和端口如下所示。

IP : 172.31.7.119

端口:6030

安装依赖

sudo apt-get install build-essential

sudo apt-get install libpcre3 libpcre3-dev

sudo apt-get install zlib1g-dev

sudo apt-get install openssl libssl-dev

安装Nginx

sudo wget http://nginx.org/download/nginx-1.18.0.tar.gz

sudo tar zxvf nginx-1.18.0.tar.gz

cd nginx-1.18.0

sudo ./configure --prefix=/usr/local/nginx --with-stream --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module

sudo make && make install

配置反向代理

我这里是新建了一个配置文件

vim /usr/local/nginx/conf/default.conf

然后再里面加上下面的内容

events {

worker_connections 1024;

}

stream {

upstream mysqld {

hash $remote_addr consistent;

server 172.31.7.119:9030 weight=1 max_fails=2 fail_timeout=60s;

##注意这里如果是多个FE,加载这里就行了

}

###这里是配置代理的端口,超时时间等

server {

listen 6030;

proxy_connect_timeout 30s;

proxy_timeout 30s;

proxy_pass mysqld;

}

}

启动Nginx

指定配置文件启动

cd /usr/local/nginx

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

验证

mysql -uroot -P6030 -h172.31.7.119

参数解释:

-u 指定Doris用户名

-p 指定Doris密码,我这里密码是空,所以没有

-h 指定Nginx代理服务器IP

-P 指定端口

mysql -uroot -P6030 -h172.31.7.119

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 13

Server version: 5.1.0 Doris version 0.15.1-rc09-Unknown

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;

+--------------------+

| Database |

+--------------------+

| information_schema |

| test |

+--------------------+

2 rows in set (0.00 sec)

mysql> use test;

Reading table information for completion of table and column names

You can turn off this feature to get a quicker startup with -A

Database changed

mysql> show tables;

+------------------+

| Tables_in_test |

+------------------+

| dwd_product_live |

+------------------+

1 row in set (0.00 sec)

mysql> desc dwd_product_live;

+-----------------+---------------+------+-------+---------+---------+

| Field | Type | Null | Key | Default | Extra |

+-----------------+---------------+------+-------+---------+---------+

| dt | DATE | Yes | true | NULL | |

| proId | BIGINT | Yes | true | NULL | |

| authorId | BIGINT | Yes | true | NULL | |

| roomId | BIGINT | Yes | true | NULL | |

| proTitle | VARCHAR(1024) | Yes | false | NULL | REPLACE |

| proLogo | VARCHAR(1024) | Yes | false | NULL | REPLACE |

| shopId | BIGINT | Yes | false | NULL | REPLACE |

| shopTitle | VARCHAR(1024) | Yes | false | NULL | REPLACE |

| profrom | INT | Yes | false | NULL | REPLACE |

| proCategory | BIGINT | Yes | false | NULL | REPLACE |

| proPrice | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| couponPrice | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| livePrice | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| volume | BIGINT | Yes | false | NULL | REPLACE |

| addedTime | BIGINT | Yes | false | NULL | REPLACE |

| offTimeUnix | BIGINT | Yes | false | NULL | REPLACE |

| offTime | BIGINT | Yes | false | NULL | REPLACE |

| createTime | BIGINT | Yes | false | NULL | REPLACE |

| createTimeUnix | BIGINT | Yes | false | NULL | REPLACE |

| amount | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| views | BIGINT | Yes | false | NULL | REPLACE |

| commissionPrice | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| proCostPrice | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| proCode | VARCHAR(1024) | Yes | false | NULL | REPLACE |

| proStatus | INT | Yes | false | NULL | REPLACE |

| status | INT | Yes | false | NULL | REPLACE |

| maxPrice | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| liveView | BIGINT | Yes | false | NULL | REPLACE |

| firstCategory | BIGINT | Yes | false | NULL | REPLACE |

| secondCategory | BIGINT | Yes | false | NULL | REPLACE |

| thirdCategory | BIGINT | Yes | false | NULL | REPLACE |

| fourCategory | BIGINT | Yes | false | NULL | REPLACE |

| minPrice | DECIMAL(18,2) | Yes | false | NULL | REPLACE |

| liveVolume | BIGINT | Yes | false | NULL | REPLACE |

| liveClick | BIGINT | Yes | false | NULL | REPLACE |

| extensionId | VARCHAR(128) | Yes | false | NULL | REPLACE |

| beginTime | BIGINT | Yes | false | NULL | REPLACE |

| roomTitle | TEXT | Yes | false | NULL | REPLACE |

| beginTimeUnix | BIGINT | Yes | false | NULL | REPLACE |

| nickname | TEXT | Yes | false | NULL | REPLACE |

+-----------------+---------------+------+-------+---------+---------+

40 rows in set (0.06 sec)

通过Nginx TCP反向代理实现Apache Doris负载均衡的更多相关文章

  1. linux下nginx【反向代理】配置【负载均衡】配置

    nginx 可以配置多个端口: 1.10088端口 配置反向代理,消除跨域问题. 2.10087端口 配置ip_hash模式的负载均衡,ip_hash可以绕开解决session共享的问题. nginx ...

  2. 简易nginx TCP反向代理设置

    nginx从1.9.0开始支持TCP反向代理,之前只支持HTTP.这是我的系统示意图: 为何需要? 为什么需要反向代理?主要是: 负载均衡 方便管控 比如我现在要更新后端服务器,如果不用负载均衡的话, ...

  3. .net core 跨平台开发 微服务架构 基于Nginx反向代理 服务集群负载均衡

    1.概述 反向代理(Reverse Proxy)方式是指以代理服务器来接受internet上的连接请求,然后将请求转发给内部网络上的服务器,并将从服务器上得到的结果返回给internet上请求连接的客 ...

  4. nginx之TCP反向代理

    实现Nginx tcp负载均衡 Nginx在1.9.0版本开始支持tcp模式的负载均衡,在1.9.13版本开始支持udp协议的负载,udp主要用于DNS的域名解析,其配置方式和指令和http 代理类似 ...

  5. Nginx (二) Nginx的反向代理负载均衡以及日志切割

    Nginx是一个高并发,高性能的服务器,可以进行反向代理以及网站的负载均衡.这些功能的运用都在配置文件中,也就是Nginx安装目录下的conf/nginx.conf. nginx.conf 1. 先来 ...

  6. nginx 反向代理 与 Apache backend的配置联合配置

    nginx 反向代理 与 Apache backend的配置联合配置: 说明: nginx 将http映射到Apache上的特定子目录. 配置方法步骤: 1.  设置域名, 子域名映射到指定服务器ip ...

  7. Nginx 笔记与总结(15)nginx 实现反向代理 ( nginx + apache 动静分离)

    在 nginx 中,proxy 用来实现反向代理,upstream 用来实现负载均衡. 例如有两台服务器,nginx 服务器作为代理服务器,执行 .html 文件,apache 服务器上执行 .php ...

  8. 【nginx网站性能优化篇(2)】反向代理实现Apache与Nginx的动静分离(LNMPA)

    为什么要使用反向代理 具体请参考这篇博文:[Linux常识篇(1)]所谓的正向代理与反向代理 在虚拟机上配置反向代理的步骤 首先假设你已经假设好了LNMP架构了,这时我们还要安装Apache和php, ...

  9. nginx启用TCP反向代理日志配置

    Nginx使用TCP反向代理日志配置不同于http 修改nginx配置文档/usr/local/nginx/conf/nginx.conf 设置日志格式 stream { log_format pro ...

随机推荐

  1. JVM分析工具与查看命令

    1.概述 无可避免地,我们都需要用到多线程的一天.单纯地使用多线程的参数设置,比如-Xms.-Xmx.-Xss等,还不足够,我们还要学会如何分析JVM里面的线程状况. 在进行java程序问题定位时,内 ...

  2. Zookeeper 文件系统 ?

    Zookeeper 提供一个多层级的节点命名空间(节点称为 znode).与文件系统不 同的是,这些节点都可以设置关联的数据,而文件系统中只有文件节点可以存放 数据而目录节点不行. Zookeeper ...

  3. Switch语句的条件只能接受什么类型的值

    switch语句只能针对基本数据类型使用,这些类型包括int.char.枚举.bool等.对于其他类型,则必须使用if语句. 在一个 switch 中可以有任意数量的 case 语句.每个 case ...

  4. Zookeeper 下 Server 工作状态 ?

    服务器具有四种状态,分别是 LOOKING.FOLLOWING.LEADING.OBSERVING. 1.LOOKING:寻找 Leader 状态.当服务器处于该状态时,它会认为当前集群中 没有 Le ...

  5. 微信APP支付V3版本签名 && APP下单/订单查询接口Python版实现

    问题背景 最近接入微信支付,微信官方并没有提供Python版的服务端SDK,因而只能根据文档手动实现一版,这里记录一下微信支付的整体流程.踩坑过程与最终具体实现. 微信支付APP下单流程 根据微信官方 ...

  6. C语言小游戏——2048

      2048   2048这款游戏的玩法很简单,每次可以选择上下左右滑动,每滑动一次,所有的数字方块都会往滑动的方向靠拢,系统也会在空白的地方乱数出现一个数字方块,相同数字的方块在靠拢.相撞时会相加. ...

  7. 什么是Viewport Meta(width详解)及在手机上的应用

    viewport是专为手机浏览器设计的一个meta标签: 有些屏幕很小有智能手机,但分辩率却可以做得很大,比如小米4的默认分辨率为:1920*1080,比许多电脑桌面的都还大,传统桌面网站直接放到手机 ...

  8. Django ElasticSearch Ionic 打造 GIS 移动应用 —— 架构设计

    搜索引擎是个好东西,GIS也是个好东西.当前还有Django和Ionic.最后效果图 构架设计 对我们的需求进行简要的思考后,设计出了下面的一些简单的架构. GIS架构说明 -- 服务端 简单说明: ...

  9. Episode 1:正视微信(试播)

    本期是 WEB VIEW 的第一期播客节目. 「不囿于 WEB,不止于 VIEW」,WEB VIEW 是由 yin 和敬礼主持的一档泛科技播客.节目中我们谨慎考量技术进步所带来的优缺点,提倡用「人治」 ...

  10. ES6-11学习笔记--异步迭代

    ES9提供异步迭代: for await of Symbol.asyncIterator   function getPromise(time) { return new Promise((resol ...