KrakenD--Ubuntu--安装运行KrakenD(Lura网关)

官网下载教程

The current KrakenD version will run at least in Debian 8, Debian 9 and Ubuntu 16.x

安装环境

WSL2–ubuntu

rookie@DESKTOP-N41VUO8:/$ uname -r
5.10.16.3-microsoft-standard-WSL2
rookie@DESKTOP-N41VUO8:/$ cat /etc/os-release
NAME="Ubuntu"
VERSION="20.04 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
  1. Add the key
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv 5DE6FD698AD6FDD2 
  1. Add the repo to the sources.list
#错误命令
roy@LAPTOP-BGHML2CG:/$ sudo echo "deb https://repo.krakend.io/apt stable main" | tee /etc/apt/sources.list.d/krakend.list #这里相当用于两个操作,echo指令和tee指令,这里都需要超级用户权限来执行,这里只在echo前面加了sudo,tee前面也需要
tee: /etc/apt/sources.list.d/krakend.list: Permission denied #这里就提示错误了,权限拒绝了操作
deb https://repo.krakend.io/apt stable main
#正确命令
roy@LAPTOP-BGHML2CG:/$ sudo echo "deb https://repo.krakend.io/apt stable main" | sudo tee /etc/apt/sources.list.d/krakend.list
deb https://repo.krakend.io/apt stable main
  1. Update your package list
roy@LAPTOP-BGHML2CG:/$ sudo apt-get update
Hit:1 http://archive.ubuntu.com/ubuntu focal InRelease
Get:2 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:3 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:5 https://repo.krakend.io/apt stable InRelease [4314 B]
Get:6 https://repo.krakend.io/apt stable/main amd64 Packages [3912 B]
Get:7 https://repo.krakend.io/apt stable/main amd64 Contents (deb) [157 B]
Fetched 344 kB in 7s (50.1 kB/s)
Reading package lists... Done
  1. Install the KrakenD service
    下载可能会比较慢,等等就好
roy@LAPTOP-BGHML2CG:/$ sudo apt-get install -y krakend
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  krakend
0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded.
Need to get 30.3 MB of archives.
After this operation, 79.3 MB of additional disk space will be used.
Get:1 https://repo.krakend.io/apt stable/main amd64 krakend amd64 1.4.1-0 [30.3 MB]
19% [1 krakend 7279 kB/30.3 MB 24%]                                                                 13.6 kB/s 28min 10s
19% [1 krakend 7311 kB/30.3 MB 24%]                                                                  13.6 kB/s 28min 8s
33% [1 krakend 12.3 MB/30.3 MB 41%]                                                                  8177 B/s 36min 38s
33% [1 krakend 12.3 MB/30.3 MB 41%]                                                                  5451 B/s 54min 58s
33% [1 krakend 12.3 MB/30.3 MB 41%]                                                                  5451 B/s 54min 58s

33% [1 krakend 12.3 MB/30.3 MB 41%]                                                                  5451 B/s 54min 58s

33% [1 krakend 12.3 MB/30.3 MB 41%]                                                                  5451 B/s 54min 58s

33% [1 krakend 12.3 MB/30.3 MB 41%]                                                                  5451 B/s 54min 58s


33% [1 krakend 12.3 MB/30.3 MB 41%]                                                                  5451 B/s 54min 58s


40% [1 krakend 15.2 MB/30.3 MB 50%]                                                                 13.6 kB/s 18min 27s
40% [1 krakend 15.2 MB/30.3 MB 50%]                                                                 13.6 kB/s 18min 27s
Fetched 30.3 MB in 36min 43s (13.8 kB/s)
Selecting previously unselected package krakend.
(Reading database ... 32964 files and directories currently installed.)
Preparing to unpack .../krakend_1.4.1-0_amd64.deb ...
Unpacking krakend (1.4.1-0) ...
Setting up krakend (1.4.1-0) ...
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down
Created symlink /etc/systemd/system/multi-user.target.wants/krakend.service → /lib/systemd/system/krakend.service.
System has not been booted with systemd as init system (PID 1). Can't operate.
Failed to connect to bus: Host is down #这里看见有失败的打印信息,不确定是否安装成功,可以试试再执行一遍下载命令,如下

显示已经安装好了

roy@LAPTOP-BGHML2CG:/$ sudo apt-get install -y krakend
Reading package lists... Done
Building dependency tree
Reading state information... Done
krakend is already the newest version (1.4.1-0).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

生成配置文件或者是运行服务

安装成功后krakenD有一个自带的配置文件,一般就在/etc/krakend下,就叫krakend.json
在这里插入图片描述
根据文档的步骤我们开始使用krakenD

生成配置文件,也就是krakend.json这样的文件

通过官方提供的设计面板来进行,具体怎么使用后面再研究,因为本来就有,我们可以直接使用,然后进行之后步骤

检查你的krakend.json的语法是否良好(内容是否正确)

这里命令里面涉及配置文件,也就是要选择一个配置文件,所以要指明文件的路径,或者进入文件所在路径去执行命令

#错误执行
roy@LAPTOP-BGHML2CG:/etc$ sudo krakend check --config krakend.json --debug
[sudo] password for roy:
Parsing configuration file: krakend.json
Parsed configuration: CacheTTL: 0s, Port: 0
Hosts: []
Extra (0):
Endpoints (0):
ERROR parsing the configuration file.
 'krakend.json' (open): no such file or directory
#正确执行
roy@LAPTOP-BGHML2CG:/etc/krakend$ sudo krakend check --config krakend.json --debug

在这里插入图片描述
在这里插入图片描述
出现Syntax ok!就说明这个配置文件至少语法上是正确的

运行 KrakenD

这里我换了自己修改的配置文件mykrakend.json

roy@LAPTOP-BGHML2CG:/etc/krakend$ sudo krakend run -c mykrakend.json -d

在这里插入图片描述
如图就是运行成功了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值