Kong API Gateway Install and Start

Submitted by Lizhe on Thu, 05/31/2018 - 09:20


sudo yum install epel-release

sudo yum install kong-community-edition-0.13.1.el7.noarch.rpm



sudo yum install https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-3.noarch.rpm


sudo yum install https://download.postgresql.org/pub/repos/yum/9.6/redhat/rhel-7.6-x86_64/pgdg-centos96-9.6-3.noarch.rpm

sudo yum install postgresql94

sudo yum install postgresql94-server

sudo /usr/pgsql-9.4/bin/postgresql94-setup initdb

sudo vi /var/lib/pgsql/9.4/data/postgresql.conf

                           listen_addresses = '*'          # what IP address(es) to listen on;

sudo vi /var/lib/pgsql/9.4/data/pg_hba.conf

                          # IPv4 local connections:
                          host    all             all               trust

sudo systemctl start postgresql-9.4


sudo su - postgres

-bash-4.2$ psql



postgres=# CREATE USER kong; CREATE DATABASE kong OWNER kong;


postgres=# \q
-bash-4.2$ kong migrations up

migrating core for database kong
core migrated up to: 2015-01-12-175310_skeleton
core migrated up to: 2015-01-12-175310_init_schema
core migrated up to: 2015-11-23-817313_nodes
core migrated up to: 2016-02-29-142793_ttls
core migrated up to: 2016-09-05-212515_retries
core migrated up to: 2016-09-16-141423_upstreams
core migrated up to: 2016-12-14-172100_move_ssl_certs_to_core
core migrated up to: 2016-11-11-151900_new_apis_router_1
core migrated up to: 2016-11-11-151900_new_apis_router_2
core migrated up to: 2016-11-11-151900_new_apis_router_3
core migrated up to: 2016-01-25-103600_unique_custom_id
core migrated up to: 2017-01-24-132600_upstream_timeouts
core migrated up to: 2017-01-24-132600_upstream_timeouts_2
core migrated up to: 2017-03-27-132300_anonymous
core migrated up to: 2017-04-18-153000_unique_plugins_id
core migrated up to: 2017-04-18-153000_unique_plugins_id_2
core migrated up to: 2017-05-19-180200_cluster_events
core migrated up to: 2017-05-19-173100_remove_nodes_table
core migrated up to: 2017-06-16-283123_ttl_indexes
core migrated up to: 2017-07-28-225000_balancer_orderlist_remove
core migrated up to: 2017-10-02-173400_apis_created_at_ms_precision
core migrated up to: 2017-11-07-192000_upstream_healthchecks
core migrated up to: 2017-10-27-134100_consistent_hashing_1
core migrated up to: 2017-11-07-192100_upstream_healthchecks_2
core migrated up to: 2017-10-27-134100_consistent_hashing_2
core migrated up to: 2017-09-14-121200_routes_and_services
core migrated up to: 2017-10-25-180700_plugins_routes_and_services
migrating response-transformer for database kong
response-transformer migrated up to: 2016-05-04-160000_resp_trans_schema_changes
migrating ip-restriction for database kong
ip-restriction migrated up to: 2016-05-24-remove-cache
migrating statsd for database kong
statsd migrated up to: 2017-06-09-160000_statsd_schema_changes
migrating jwt for database kong
jwt migrated up to: 2015-06-09-jwt-auth
jwt migrated up to: 2016-03-07-jwt-alg
jwt migrated up to: 2017-05-22-jwt_secret_not_unique
jwt migrated up to: 2017-07-31-120200_jwt-auth_preflight_default
jwt migrated up to: 2017-10-25-211200_jwt_cookie_names_default
migrating cors for database kong
cors migrated up to: 2017-03-14_multiple_orgins
migrating basic-auth for database kong
basic-auth migrated up to: 2015-08-03-132400_init_basicauth
basic-auth migrated up to: 2017-01-25-180400_unique_username
migrating key-auth for database kong
key-auth migrated up to: 2015-07-31-172400_init_keyauth
key-auth migrated up to: 2017-07-31-120200_key-auth_preflight_default
migrating ldap-auth for database kong
ldap-auth migrated up to: 2017-10-23-150900_header_type_default
migrating hmac-auth for database kong
hmac-auth migrated up to: 2015-09-16-132400_init_hmacauth
hmac-auth migrated up to: 2017-06-21-132400_init_hmacauth
migrating datadog for database kong
datadog migrated up to: 2017-06-09-160000_datadog_schema_changes
migrating tcp-log for database kong
tcp-log migrated up to: 2017-12-13-120000_tcp-log_tls
migrating acl for database kong
acl migrated up to: 2015-08-25-841841_init_acl
migrating response-ratelimiting for database kong
response-ratelimiting migrated up to: 2015-08-03-132400_init_response_ratelimiting
response-ratelimiting migrated up to: 2016-08-04-321512_response-rate-limiting_policies
response-ratelimiting migrated up to: 2017-12-19-120000_add_route_and_service_id_to_response_ratelimiting
migrating request-transformer for database kong
request-transformer migrated up to: 2016-05-04-160000_req_trans_schema_changes
migrating rate-limiting for database kong
rate-limiting migrated up to: 2015-08-03-132400_init_ratelimiting
rate-limiting migrated up to: 2016-07-25-471385_ratelimiting_policies
rate-limiting migrated up to: 2017-11-30-120000_add_route_and_service_id
migrating oauth2 for database kong
oauth2 migrated up to: 2015-08-03-132400_init_oauth2
oauth2 migrated up to: 2016-07-15-oauth2_code_credential_id
oauth2 migrated up to: 2016-12-22-283949_serialize_redirect_uri
oauth2 migrated up to: 2016-09-19-oauth2_api_id
oauth2 migrated up to: 2016-12-15-set_global_credentials
oauth2 migrated up to: 2017-04-24-oauth2_client_secret_not_unique
oauth2 migrated up to: 2017-10-19-set_auth_header_name_default
oauth2 migrated up to: 2017-10-11-oauth2_new_refresh_token_ttl_config_value
oauth2 migrated up to: 2018-01-09-oauth2_pg_add_service_id
62 migrations ran

su - admin

sudo cp /etc/kong/kong.conf.default /etc/kong/kong.conf

sudo chmod 777 /etc/kong/kong.conf


adduser kong

passwd kong


sudo mkdir /usr/local/kong

sudo chmod 777 -R /usr/local/kong/


[admin@localhost ~]$ kong start
2018/05/31 10:43:59 [warn] Currently using PostgreSQL 9.4 which is considered deprecated, please use 9.5 or greater
2018/05/31 10:44:00 [warn] ulimit is currently set to "1024". For better performance set it to at least "4096" using "ulimit -n"
Kong started
[admin@localhost ~]$ 


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

npm install -g kong-dashboard

nohup kong-dashboard start --kong-url &

也可以基于basic 认证,在登录是要求输入密码

nohup kong-dashboard start --kong-url --basic-auth admin=123456 &