介紹
極限網關 (INFINI Gateway) 是一個面向 Elasticsearch 的高性能應用網關,它包含豐富的特性,使用起來也非常簡單。極限網關工作的方式和普通的反向代理一樣,我們一般是將網關部署在 Elasticsearch 集群前面, 將以往直接發送給 Elasticsearch 的請求都發送給網關,再由網關轉發給請求到后端的 Elasticsearch 集群。因為網關位於在用戶端和后端 Elasticsearch 之間,所以網關在中間可以做非常多的事情, 比如可以實現索引級別的限速限流、常見查詢的緩存加速、查詢請求的審計、查詢結果的動態修改等等。
特性
極限網關是專為 Elasticsearch 而量身打造的應用層網關,地表最強,沒有之一!
高可用,不停機索引,自動處理后端 Elasticsearch 的故障,不影響數據的正常攝取
寫入加速,可自動合並獨立的索引請求為批量請求,降低后端壓力,提高索引效率
查詢加速,可配置查詢緩存,Kibana 分析儀表板的無縫智能加速,全面提升搜索體驗
透明重試,自動處理后端 Elasticsearch 節點故障和對查詢請求進行遷移重試
流量克隆,支持復制流量到多個不同的后端 Elasticsearch 集群,支持流量灰度遷移
一鍵重建,優化過的高速重建和增量數據的自動處理,支持新舊索引的透明無縫切換
安全傳輸,自動支持 TLS/HTTPS,可動態生成自簽證書,也可指定自簽可信證書
精准路由,多種算法的負載均衡模式,索引和查詢可分別配置負載路由策略,動態靈活
限速限流,支持多種限速和限流測規則,可以實現索引級別的限速,保障后端集群的穩定性
並發控制,支持集群和節點級別的 TCP 並發連接數控制,保障后端集群和節點穩定性
無單點故障,內置基於虛擬 IP 的高可用解決方案,雙機熱備,故障自動遷移,避免單點故障
請求透視,內置日志和指標監控,可以對 Elasticsearch 請求做全面的數據分析
安裝步驟
cd /opt/
[root@test13 opt]# mkdir es-gateway
[root@test13 opt]# cd es-gateway/
[root@test13 es-gateway]# wget http://release.elasticsearch.cn/gateway/snapshot/gateway-1.2.0_SNAPSHOT-237-linux64.tar.gz
[root@test13 es-gateway]# tar zxvf gateway-1.2.0_SNAPSHOT-237-linux64.tar.gz
驗證下載腳本
[root@test13 es-gateway]# ./gateway-linux64 --help
Usage of ./gateway-linux64:
-config string
the location of config file, default: gateway.yml (default "gateway.yml")
-cpu int
the number of CPUs to use (default -1)
-cpuprofile string
write cpu profile to this file
-daemon
run in background as daemon
-debug
run in debug mode, gateway will quit with panic error
-log string
the log level,options:trace,debug,info,warn,error (default "info")
-memprofile string
write memory profile to this file
-pidfile string
pidfile path (only for daemon mode)
-pprof string
enable and setup pprof/expvar service, eg: localhost:6060 , the endpoint will be: http://localhost:6060/debug/pprof/ and http://localhost:6060/debug/vars
-v version
[root@test13 es-gateway]# mkdir bin
[root@test13 es-gateway]# mv gateway-linux64 bin/gateway
[root@test13 es-gateway]# mkdir /etc/gateway
創建配置文件
[root@test13 es-gateway]# vim /etc/gateway/gateway.yml
保存內容
path.data: data
path.logs: log
vi /usr/lib/systemd/system/gateway.service
[Unit]
Description=infini-gateway
After=network.target
[Service]
Type=forking
WorkingDirectory=/opt/es-gateway
ExecStart=/opt/es-gateway/bin/gateway -daemon -pidfile /var/run/gateway.pid -config /etc/gateway/gateway.yml
ExecStop=/bin/kill `cat /var/run/gateway.pid`
PrivateTmp=true
User=root
Group=root
LimitNOFILE=16384:163840
[Install]
WantedBy=multi-user.target
systemctl daemon-reload
systemctl start gateway
查看狀態
[root@test13 es-gateway]# systemctl status gateway
● gateway.service - infini-gateway
Loaded: loaded (/usr/lib/systemd/system/gateway.service; disabled; vendor preset: disabled)
Active: active (running) since 五 2021-06-25 14:00:01 CST; 4s ago
Process: 16995 ExecStart=/opt/es-gateway/bin/gateway -daemon -pidfile /var/run/gateway.pid -config /etc/gateway/gateway.yml (code=exited, status=0/SUCCESS)
Main PID: 17004 (gateway)
CGroup: /system.slice/gateway.service
└─17004 /opt/es-gateway/bin/gateway -daemon -pidfile /var/run/gateway.pid -config /etc/gate...
6月 25 14:00:01 test13 systemd[1]: Starting infini-gateway...
6月 25 14:00:01 test13 gateway[16995]: ___ _ _____ __ __ __ _
6月 25 14:00:01 test13 gateway[16995]: / _ \ /_\ /__ \/__\/ / /\ \ \/_\ /\_/\
6月 25 14:00:01 test13 gateway[16995]: / /_\///_\\ / /\/_\ \ \/ \/ //_\\\_ _/
6月 25 14:00:01 test13 gateway[16995]: / /_\\/ _ \/ / //__ \ /\ / _ \/ \
6月 25 14:00:01 test13 gateway[16995]: \____/\_/ \_/\/ \__/ \/ \/\_/ \_/\_/
6月 25 14:00:01 test13 gateway[16995]: [GATEWAY] A light-weight, powerful and high-performance el...way.
6月 25 14:00:01 test13 gateway[16995]: [GATEWAY] 1.2.0_SNAPSHOT, 65606c7, Fri Jun 18 21:44:25 202...vice
6月 25 14:00:01 test13 gateway[16995]: [GATEWAY] started in background, pid: 16996
6月 25 14:00:01 test13 systemd[1]: Started infini-gateway.
Hint: Some lines were ellipsized, use -l to show in full.
本文由博客一文多發平台 OpenWrite 發布!