在阅读本文档前,你需要先阅读部署先决条件文档来完成部署
shenyu
前的环境准备工作.
本文是介绍在集群环境中快速部署ShenYu
网关。
在阅读本文档时,你可以先阅读二进制包部署。
在你的网关管理端服务器下载并解压apache-shenyu-${current.version}-admin-bin.tar.gz 。
配置你的数据库,进入/conf
目录,在application.yaml
文件中修改spring.profiles.active
节点为mysql
, pg
or h2
。
配置你的数据同步方式,进入/conf
目录,在application.yaml
文件中修改shenyu.sync
节点为websocket
, http
, zookeeper
, etcd
, consul
或者 nacos
。
进入bin
目录,启动ShenYu Bootstrap。
> windows: start.bat > linux: ./start.sh
在你的网关启动器服务器下载并解压apache-shenyu-${current.version}-bootstrap-bin.tar.gz 。
配置你的数据同步方式,进入/conf
目录,在application.yaml
文件中修改shenyu.sync
节点为websocket
, http
, zookeeper
, etcd
, consul
或者 nacos
,这个配置必须与ShenyYu Admin
的配置保持相同。
进入bin
目录,启动ShenYu Admin。
> windwos : start.bat > linux : ./start.sh
在完成这些操作后,你将成功部署
ShenYu Boostrap
集群。假如你
10.1.1.1
和10.1.1.2
两台服务器在将部署ShenYu Bootstrap
,并且在10.1.1.3
部署nginx。
下载并安装nginx。
在nginx.conf
文件中修改upstream
和server
节点的配置。
upstream shenyu_gateway_cluster { ip_hash; server 10.1.1.1:9195 max_fails=3 fail_timeout=10s weight=50; server 10.1.1.2:9195 max_fails=3 fail_timeout=10s weight=50; } server { listen 9195; location / { proxy_pass http://shenyu_gateway_cluster; proxy_set_header HOST $host; proxy_read_timeout 10s; proxy_connect_timeout 10s; } }
> windows: ./nginx.exe > linux: /usr/local/nginx/sbin/nginx
ShenYu Bootstrap
或者Nginx
的日志文件中查看请求被分发到那台服务器上。