使用说明
最后更新于:2022-04-02 06:55:22
网关管理是对FEBS Gateway的增强,也是对WebFlux编程的一次实践,相关代码位于cc.mrbird.febs.gateway.enhance目录下,主要包含黑名单控制、限流控制和相关日志记录等功能。默认网关增强是关闭的,要开启它需要进行如下操作:
1. 安装MongoDB。MongoDB下载地址:[https://www.mongodb.com/download-center/community](https://www.mongodb.com/download-center/community),下载后安装即可。我的安装路径为:D:\Program Files\MongoDB。
安装好后,在D盘的根目录(或者任意你喜欢的位置)新建mongodb文件夹,然后到D:\Program Files\MongoDB\Server\4.2\bin目录下打开CMD窗口,输入如下命令开启MongoDB:

启动后,浏览器访问:[http://localhost:27017/](http://localhost:27017/)

说明我们的MongoDB启动成功。
2. Navicat连接MongoDB。使用Navicat新建一个MongoDB连接:

连接后,新建一个名称为febs_cloud_route的db:

然后在该db下导入febs-cloud/sql/febs_cloud_route.sql SQL脚本即可。
3. 打开配置。访问Nacos控制台:[http://localhost:8001/nacos](http://localhost:8001/nacos),编辑febs-gateway.yaml配置:

修改好后,配置如下图所示:

4. 编辑IDEA环境变量,在febs-gateway模块中添加mongo.url和redis.url变量配置:

5. 重新启动febs-gateway模块,启动日志中输出如如下内容的话,说明网关增强开启成功:
```
2020-01-14 16:17:59 INFO main cc.mrbird.febs.gateway.enhance.service.impl.RouteEnhanceCacheServiceImpl Cache blacklist into redis >>>
2020-01-14 16:17:59 INFO main cc.mrbird.febs.gateway.enhance.service.impl.RouteEnhanceCacheServiceImpl Cache rate limit rules into redis >>>
```
';