安装KONG + postgresql 10

查看linux版本信息:cat /proc/version

查看linux的ip地址:ip addr show

跟随kong官网,找到对应版本安装:https://konghq.com/install/

 

依赖:

  1. gcc   sudo yum install -y pcre pcre-devel
  2. pcre   sudo yum install -y pcre pcre-devel
  3. zlib   sudo yum install -y zlib zlib-devel
  4. openssl   sudo yum install -y openssl openssl-devel
  5. postgresql10
  6. epel-release  yum -y install epel-release

1. 安装Kong

官网下载解压

下载:

https://konghq.com/install/,选择操作系统

sudo yum install epel-release
sudo yum install kong-0.10.3.*.noarch.rpm(下载的包所在路径及包名) --nogpgcheck

 

2. 安装PostgreSQL 9.5

切换到root用户: su -

2.1 添加RPM

可以试试在浏览器输入 https://download.postgresql.org/pub 看会发现什么.

rpm -Uvh https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm

2.2 安装PostgreSQL   

yum install -y postgresql10-server postgresql10

2.3 初始化数据库   

/usr/pgsql-10/bin/postgresql-10-setup initdb

2.4 设置开机启动   systemctl enable postgresql-10.service

2.5 启动服务   systemctl start postgresql-10.service

2.6 查看版本   psql --version

2.7 修改用户名和密码

su -postgres

psql -U postgres

alter user postgres with password 'xxx' (插入用户名为postgres的用户密码xxx)

\q

2.8 开启远程访问

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

添加(或修改)listen_addresses = 'localhost'  为  listen_addresses='*'

2.9 信任远程连接

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

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/0            trust
host         all                             all                            0.0.0.0/0                                  md5

# IPv6 local connections:
host    all             all             ::1/128                 trust
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            trust
host    replication     all             ::1/128                 trust

2.10 重启服务   systemctl restart postgresql-10.service  (退出exit)

启动命令:

systemctl start postgresql-10

3. 授权Kong数据库(增加role和database)

//grant all privileges on database kong to kong;

su - postgres << EOF

psql << XOF

CREATE USER kong; CREATE DATABASE kong OWNER kong;

XOF

EOF

//

登录命令为:
psql -U kong -d kong -h 127.0.0.1 -p 5432  (退出为\q)

 

4. 导入Kong数据

kong migrations up

 

5. 启动kong

告诉你的Linux允许进程绑定到非本地地址。只需添加以下行的/etc/sysctl.conf 文件:

net.ipv4.ip_nonlocal_bind=1

重新加载sysctl.conf的: sysctl -p /etc/sysctl.conf

kongstart

 

 

 

-----------------------------------------------------

linux防火墙报错:Unit iptables.service failed to load: No such file or directory.

CentOS7中执行
service iptables start/stop
会报错Failed to start iptables.service: Unit iptables.service failed to load: No such file or directory.

在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理,

如果要添加范围例外端口 如 1000-2000
语法命令如下:启用区域端口和协议组合
firewall-cmd [--zone=<zone>] --add-port=<port>[-<port>]/<protocol> [--timeout=<seconds>]
此举将启用端口和协议的组合。端口可以是一个单独的端口 <port> 或者是一个端口范围 <port>-<port> 。协议可以是 tcp 或 udp。
实际命令如下:

添加
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)

firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent 

重新载入
firewall-cmd --reload
查看
firewall-cmd --zone=public --query-port=80/tcp
删除
firewall-cmd --zone=public --remove-port=80/tcp --permanent


当然你可以还原传统的管理方式。

执行一下命令:

systemctl stop firewalld
systemctl mask firewalld

并且安装iptables-services:
yum install iptables-services

设置开机启动:
systemctl enable iptables

systemctl stop iptables
systemctl start iptables
systemctl restart iptables
systemctl reload iptables

保存设置:
service iptables save

OK,再试一下应该就好使了

开放某个端口 在/etc/sysconfig/iptables里添加

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

--------------------- 

 

转载于:https://my.oschina.net/u/4050414/blog/3020119

CentOS 7是一种流行的Linux操作系统,而Kong是一个开源的云原生API网关和微服务管理平台。下面是在CentOS 7上安装Kong的步骤: 1. 首先,确保你的CentOS 7系统已经安装了必要的依赖软件包。可以使用以下命令来安装这些软件包: ``` sudo yum install -y epel-release sudo yum install -y wget openssl-devel pcre-devel zlib-devel ``` 2. 接下来,你需要添加Kong的官方Yum存储库。运行以下命令来添加存储库: ``` sudo wget https://bintray.com/kong/kong-rpm/rpm -O /etc/yum.repos.d/bintray-kong-kong-rpm.repo ``` 3. 安装Kong。运行以下命令来安装Kong: ``` sudo yum install -y kong ``` 4. 配置数据库Kong需要一个数据库来存储配置和元数据。你可以选择使用PostgreSQL或Cassandra作为数据库。以下是使用PostgreSQL的配置步骤: - 安装PostgreSQL: ``` sudo yum install -y postgresql postgresql-server ``` - 初始化数据库: ``` sudo postgresql-setup initdb ``` - 启动PostgreSQL服务: ``` sudo systemctl start postgresql ``` - 创建Kong使用的数据库和用户: ``` sudo -u postgres psql -c "CREATE USER kong;" sudo -u postgres psql -c "CREATE DATABASE kong OWNER kong;" sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE kong TO kong;" ``` 5. 配置Kong。编辑Kong的配置文件`/etc/kong/kong.conf`,根据你的需求进行配置。至少需要配置数据库连接信息。 6. 初始化Kong数据库。运行以下命令来初始化Kong数据库: ``` sudo kong migrations bootstrap [-c /etc/kong/kong.conf] ``` 7. 启动Kong服务。运行以下命令来启动Kong服务: ``` sudo systemctl start kong ``` 现在,你已经成功在CentOS 7上安装Kong。你可以通过访问Kong的管理界面或使用Kong的API来配置和管理API网关。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值