yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm -y
yum list | grep posgreesql
3.安装
yum install -y postgresql10-contrib.x86_64 postgresql10-server.x86_64
/usr/pgsql-10/bin/postgresql-10-setup initdb
systemctl start postgresql-10
systemctl enable postgresql-10.service
su - postgres
psql
ALTER USER postgres WITH PASSWORD '密码';
6.创建数据库
CREATE DATABASE konga;
7.创建用户
CREATE USER konga CREATEDB LOGIN PASSWORD 'Admin1233';
8.将kong数据库所有权限赋予kong用户
GRANT ALL ON DATABASE konga TO konga;
GRANT ALL ON DATABASE kongDB TO kongUSER;
9.默认情况下postgresql是不用密码不支持远程登录的,我们需要修改配置文件。
vim /var/lib/pgsql/10/data/pg_hba.conf
vim /var/lib/pgsql/10/data/postgresql.conf
systemctl restart postgresql-10
wget https://bintray.com/kong/kong-rpm/download_file?file_path=centos/7/kong-1.4.0.el7.amd64.rpm
2.安装
yum install *.rpm -y
cp -r /etc/kong/kong.conf.default kong.conf
vim /etc/kong/kong.conf
4.初始化数据库
kong migrations bootstrap -c /etc/kong/kong.conf
5.启动kong网关
kong start -c /etc/kong/kong.conf
6.本地访问
curl -i http://127.0.0.1:8001
7.如果需要外地访问,需要更改配置文件
vim /etc/kong/kong.conf
kong restart -c /etc/kong/kong.conf
个人推荐docker安装,比较简便快捷。下包安装需要解决各种环境问题,这里没有使用官方的dashboard,使用了第三方的konga比较好用
1.先安装node
node官网(https://nodejs.org/en/download/)
根据自己的需求下载可以下载不同的版本
wget https://nodejs.org/dist/v12.13.0/node-v12.13.0-linux-x64.tar.xz
解压
xz -d node-v12.13.0-linux-x64.tar.xz
再解压
tar xvf node-v12.13.0-linux-x64.tar.xz
移动到/opt
mv node-v12.13.0-linux-x64 /opt/
设置软连接
ln -s /opt/node-v12.13.0-linux-x64/bin/npm /usr/bin/npm
ln -s /opt/node-v12.13.0-linux-x64/bin/node /usr/bin/node
配置淘宝镜像
npm install -g cnpm --registry=https://registry.npm.taobao.org
2.安装Git
yum install -y git
yum install -y gcc-c++
3.下载konga包并安装
git clone https://github.com/pantsel/konga.git
cd konga
npm i
1.下载konga镜像(我这里因为下载特别慢所以我是在阿里下载的)
docker pull konga
docker pull registry.cn-hangzhou.aliyuncs.com/zhanghongzhuang-k8s/konga:latest
2.创建konga数据库,并且进行初始化
docker run --rm registry.cn-hangzhou.aliyuncs.com/zhanghongzhuang-k8s/konga -c prepare -a postgres -u postgresql://用户名:密码@ip:(prot默认是5432)5432/数据库名字
举个栗子:
docker run --rm registry.cn-hangzhou.aliyuncs.com/zhanghongzhuang-k8s/konga -c prepare -a postgres -u postgresql://konga:[email protected]:5432/konga
3.编辑docker-compose.
vim docker-compose.yml
version: '2.1'
services:
kong:
image: "registry.cn-hangzhou.aliyuncs.com/zhanghongzhuang-k8s/konga:latest"
environment:
DB_ADAPTER: postgres
DB_HOST: 10.100.24.64
DB_PORT: 5432
DB_USER: konga
DB_PASSWORD: Admin1233
DB_DATABASE: konga
NODE_ENV: production
ports:
- "1337:1337/tcp"
restart: on-failure
4.启动
docker-compose up -d