Kong-简介与安装(1)

网关的概念

随着移动互联网的兴起、开放合作思维的盛行,第三方合作者或内部系统的其他开发者都需要大量的接入企业核心业务能力,此时各业务系统将会面临同一系列的问题,例如:如何让调用方快速接入、如何让业务方安全地对外开放能力,如何应对和控制业务洪峰调用等等。于是就诞生了一个隔离企业内部业务系统和外部系统调用的屏障 - API网关,它负责在上层抽象出各业务系统需要的通用功能,

Kong 简介

Kong是一个在Nginx运行的Lua应用程序,由lua-nginx-module实现,对具体的客户端请求进行转发、通过插件的方式对接口进行、管数据管控、鉴权、限流、ACL、降级等


开发环境的搭建通过源码方式安装

首先从官网 把源代码Fork到自己的 github 空间里, 如果开发新的功能可以自己创建一个分支、如果Kong 的版本升级了,可以合并到自己的分支中,这样升级官方版本


1.安装Kong 相关的依赖组件

可以先查看一下官方文档的依赖文件 
https://github.com/Kong/kong/blob/master/.requirements

2.安装Kong OpenSSL 可以需求

(1)下载OpenSSL https://oomake.com/download/openssl 
(2)安装OpenSSL 

# tar -xzf openssl-1.1.0.tar.gz
# cd openssl-1.1.0
# mkdir /usr/local/openssl
# ./config --prefix=/usr/local/openssl
# make# make install

(3)创建软连接

# ln -s /usr/local/openssl/bin/openssl /usr/bin/openssl

3.安装OpenResty

(1) 下载OpenResty 
openresty-1.13.6.2.tar.gz
(2) 解压缩进入安装目录
(3) 如果需要使用Kong 的Stream模块(支持 TCP 负载等功能)  需要先安装补丁程序、可以参考 https://github.com/Kong/openresty-patches
(4) 进入安装目录

./configure \
 --with-pcre-jit \
 --with-http_ssl_module \
 --with-http_realip_module \
 --with-http_stub_status_module \
 --with-http_v2_module \
 --with-openssl=/usr/local/openssl-1.1.0 \  
(编译成功以后,就可以安装了) 
gmake && gmake install

安装成功以后,可以在安装目录下(默认/usr/local/openresty/) 的bin 目录下执行 ./openresty -V 查看安装是否成功

配置Resty 环境变量

vi /etc/profie  中添加环境变量
export RESTY=/usr/local/openresty/bin/resty

安装LuaRocks

wget https://github.com/luarocks/luarocks/archive/v3.0.3.tar.gz
./configure
make && make install
执行以上命令

安装Kong

1.通过Git 获取kong 的源代码如
git clone https://github.com/Kong/kong.git    -b (也可以是自己的Git分支)
2.进入安装目录执行
make install 
3.需要把Git 源码中 Bin/Kong 的可执行文件拷贝到 /usr/bin 目录中 


安装中可以遇到的问题

执行 ./openresty: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
执行 ln -s /lib64/libpcre.so.0.0.1 /lib64/libpcre.so.1  

你可能感兴趣的:(Kong-简介与安装(1))