1. ngx_http_upstream_consistent_hash 模块安装与配置
ngx_http_upstream_consistent_hash 模块是⼀个负载均衡器,使⽤⼀个内部⼀致性hash算法来选择合适的后端节点。
该模块可以根据配置参数采取不同的⽅式将请求均匀映射到后端机器,
consistent_hash $remote_addr:可以根据客户端ip映射
consistent_hash $request_uri:根据客户端请求的uri映射
consistent_hash $args:根据客户端携带的参数进⾏映
ngx_http_upstream_consistent_hash 模块是⼀个第三⽅模块,需要我们下载安装后使⽤
- github下载nginx⼀致性hash负载均衡模块 https://github.com/replay/ngx_http_consistent_hash

- 将下载的压缩包上传到nginx服务器,并解压
我们已经编译安装过nginx,此时进⼊当时nginx的源码⽬录,执⾏如下命令
./configure —add-module=/root/ngx_http_consistent_hash-mastermakemake install
Nginx就可以使⽤啦,在nginx.conf⽂件中配置
2. 参考资料
- Nginx的第三方模块:https://www.nginx.com/resources/wiki/modules/
- Nginx的ngx_http_consistent_hash模块的官网使用文档:https://www.nginx.com/resources/wiki/modules/consistent_hash/
