首页 技术 正文
技术 2022年11月17日
0 收藏 836 点赞 3,298 浏览 3594 个字

一、系统环境

[root@kong ~]# service iptables status
iptables: Firewall is not running.
[root@kong ~]# getenforce
Disabled
[root@kong ~]# cat /etc/system-release
CentOS release 6.7 (Final)
[root@kong ~]# uname -a
Linux kong 2.6.-.el6.x86_64 # SMP Thu Jul :: UTC x86_64 x86_64 x86_64 GNU/Linux

二、kong的安装

    根据kong的官网文档进行安装  官网:https://konghq.com/install/

  1、yum源配置

[root@kong ~]# cat /etc/yum.repos.d/bintray-kong-kong-community-edition-rpm.repo
[bintraybintray-kong-kong-community-edition-rpm]
name=bintray-kong-kong-community-edition-rpm
baseurl=https://kong.bintray.com/kong-community-edition-rpm/centos/6
gpgcheck=
repo_gpgcheck=
enabled=

  2、安装kong  默认安装的 kong-0.10.4-1.noarch,官网已经更新到了0.13.x了,也可以手动下载最新版的rpm包安装

[root@kong ~]# yum install -y kong

  如果安装是报如下错误,就在/etc/yum.conf 配置文件 sslverify=false后,重新执行上面命令

https://kong.bintray.com/kong-community-edition-rpm/centos/6/kong-community-edition-0.10.4.el6.noarch.rpm: [Errno 14] Peer cert cannot be verified or peer cert invalid

  3、安装 kong 需要的数据库,默认选择的是postgreSQL,kong支持2种数据库存储(postgreSQL 和 Cassandra

    postgreSQL官网:https://www.postgresql.org/download/

    Cassandra官网:http://cassandra.apache.org/download/

    

    这里我们以postgreSQL为例进行安装

    a、配置yum源

      https://www.postgresql.org/download/linux/redhat/

yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-6-x86_64/pgdg-centos10-10-2.noarch.rpmyum install postgresql10yum install postgresql10-serverservice postgresql- initdb
chkconfig postgresql- on

    b、修改postgreSQL配置文件

      /var/lib/pgsql/10/data/postgresql.conf

listen_addresses = 'localhost'替换成如下:listen_addresses = '*'

      /var/lib/pgsql/10/data/pg_hba.conf

host    all             all             127.0.0.1/            ident换成如下:host    all             all             127.0.0.1/            trust

    c、启动postgreSQL

service postgresql- start

    d、创建kong需要的库、授权  并 把相关的数据写入库

[root@base ~]# su - postgres
-bash-4.1$ psql
psql (8.4., server 10.3)
WARNING: psql version 8.4, server version 10.0.
Some psql features might not work.
Type "help" for help.postgres=# CREATE USER kong; CREATE DATABASE kong OWNER kong;
CREATE ROLE
CREATE DATABASE
postgres=# quit
postgres-# \q
-bash-4.1$ exit
logout
[root@base ~]# kong migrations up
...................
response-ratelimiting migrated up to: ---321512_response-rate-limiting_policies
migrating acl for database kong
acl migrated up to: ---841841_init_acl
migrations ran

    e、修改普通用户描述符,至少4096

ulimit -HSn 65535
echo "ulimit -HSn 65535" >> /etc/rc.local

  4、启动 kong

[root@base ~]# kong start
Kong started[root@base ~]# netstat -lntp|grep nginx
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx
tcp 0.0.0.0: 0.0.0.0:* LISTEN /nginx[root@base ~]# curl -i -X GET http://localhost:8001/
HTTP/1.1 OK
Date: Thu, Apr :: GMT
Content-Type: application/json; charset=utf-
Transfer-Encoding: chunked
Connection: keep-alive
Access-Control-Allow-Origin: *
Server: kong/0.10.{"timers":{"running":,"pending":},"configuration":{"admin_error_log":"logs\/error.log","cassandra_lb_policy":"RoundRobin","admin_access_log":"logs\/admin_access.log","ca ..................
..............................

三、Kong UI管理工具

  安装说明:https://github.com/PGBI/kong-dashboard

  1、安装kong管理工具的环境依赖  nodejs 及 npm

    nodejs 及 npm安装教程:https://nodejs.org/en/download/package-manager/#enterprise-linux-and-fedora

curl --silent --location https://rpm.nodesource.com/setup_9.x | sudo bash -yum -y install nodejs

  2、使用 npm 安装 kong-dashboard

npm install -g kong-dashboard
nohup kong-dashboard start --kong-url http://192.168.1.128:8001 &也可以基于basic 认证,在登录是要求输入密码nohup kong-dashboard start --kong-url http://192.168.1.128:8001 --basic-auth admin=123456 &

  3、访问 kong-dashboard   http://192.168.1.128:8080 (输入刚刚配置的账号密码)

API gateway 之 kong 安装  (二)

四、Kong 桌面管理工具

  Kong 桌面管理工具:https://github.com/ajaysreedhar/kongdash 有linux版本,windows版本,mac版本。

  下载地址:https://github.com/ajaysreedhar/kongdash/releases/download/v0.3.0/kongdash-0.3.0-ia32.exe

  访问地址:http://192.168.1.128:8001/

API gateway 之 kong 安装  (二)

下一篇: Go调用cpp类
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,105
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,582
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,429
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,200
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,836
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,919