kong-postgresql-konga配置安装
kong
wget https://bintray.com/kong/kong-rpm/rpm -O bintray-kong-kong-rpm.repo
export major_version=`grep -oE '[0-9]+\.[0-9]+' /etc/redhat-release | cut -d "." -f1`
sed -i -e 's/baseurl.*/&\/centos\/'$major_version''/ bintray-kong-kong-rpm.repo
mv bintray-kong-kong-rpm.repo /etc/yum.repos.d/
yum -y install kong
vim /etc/kong/kong.conf
database = postgres
pg_host = 127.0.0.1
pg_port = 5432
#pg_timeout = 5000
pg_user = kong
pg_password = kong
pg_database = kong
kong start
postgresql
yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
yum install -y postgresql95-server
/usr/pgsql-9.5/bin/postgresql95-setup initdb
systemctl enable postgresql-9.5
systemctl start postgresql-9.5
vim /usr/pgsql-9.5/share/pg_hba.conf.sample
host all all 0.0.0.0/0 md5
vim /var/lib/pgsql/9.5/data/postgresql.conf
listen_addresses = '*'
su postgres
CREATE USER kong; CREATE DATABASE kong OWNER kong;
kong数据库迁移
kong migrations bootstrap [-c /path/to/kong.conf]
node8
yum -y remove nodejs
curl --silent --location https://github.com/nodesource/distributions/tree/master/rpm/setup_8.x| bash -
太慢就先下包
wget https://github.com/nodesource/distributions/tree/master/rpm/setup_8.x
sh setup_8.x
konga
cd /etc/kong/
git clone https://github.com/pantsel/konga.git
cd konga
cp -r env_example .env
vim /etc/kong/konga/.env
PORT=1337
#NODE_ENV=development
NODE_ENV=production
KONGA_HOOK_TIMEOUT=120000
DB_ADAPTER=postgres
DB_URI=postgresql://konga:konga@localhost:5432/konga
KONGA_LOG_LEVEL=warn
TOKEN_SECRET=some_secret_token
DB_USER=konga
DB_PASSWORD=konga
DB_DATABASE=konga
npm i
修改配置 /etc/kong/konga/config 这加什么数据库后面就配置那个数据库配置段
cp local_example.js local.js
vim local.js
module.exports = {
connections: {
},
models: {
// 这里可以用‘mysql’,‘mongo’,‘sqlserver’,‘postgres’
connection: process.env.DB_ADAPTER || 'postgres'
},
session: {
secret: '' // Add your own SECRET string here
},
port: process.env.PORT || 1338,
environment: process.env.NODE_ENV || 'development',
log: {
level: 'info'
}
};
修改配置 /etc/kong/konga/config/connections.js postgres的配置
postgres: {
adapter: 'sails-postgresql',
url: process.env.DB_URI,
host: process.env.DB_HOST || 'localhost',
user: process.env.DB_USER || 'kong',
password: process.env.DB_PASSWORD || 'kong',
port: process.env.DB_PORT || 5432,
database: process.env.DB_DATABASE ||'kong',
// schema: process.env.DB_PG_SCHEMA ||'public',
poolSize: process.env.DB_POOLSIZE || 10,
ssl: process.env.DB_SSL ? true : false // If set, assume it's true
},
测试启动
npm start
正式环境:需要有postgresql数据库
node ./bin/konga.js prepare --adapter postgres --uri postgresql://localhost:5432/konga
npm run production