下载 qdoractl,移动到环境变量下
mv qdoractl /usr/local/bin
https://elrepo.org/linux/kernel/el6/x86_64/RPMS/
安装成功
[root@iZuf62yr7w4vds2g31s5tlZ pack]# # Received /Users/jingliu/Downloads/kernel-lt-4.4.177-1.el6.elrepo.x86_64.rpm
[root@iZuf62yr7w4vds2g31s5tlZ pack]# ls
kernel-lt-4.4.177-1.el6.elrepo.x86_64.rpm repos.tgz ssl.tgz vhosts.tgz
[root@iZuf62yr7w4vds2g31s5tlZ pack]# rpm -ivh kernel-lt-4.4.177-1.el6.elrepo.x86_64.rpm
Preparing... ########################################### [100%]
package kernel-lt-4.4.177-1.el6.elrepo.x86_64 is already installed
安装成功
qdoractl 操作
自定义数据处理程序需要是一个基于Linux构建的,可运行的Docker镜像。镜像的构建和验证可以参考Demo。
可运行的Docker镜像在构建时需要在Dockerfile中指定入口程序(ENTRYPOINT 或 CMD),同时该入口程序需要满足:
- 启动后监听 9100 端口
- 接受 HTTP POST /handler?cmd=XXX&url=XXX 的请求,并返回数据处理结果
- 在一个自定义的路径上接收HTTP GET 请求,并返回该程序当前的健康状态(可选)
METHOD | PATH | NOTE |
---|---|---|
POST | /handler?cmd=XXX&url=XXX | [cmd的值为该自定义数据处理名称,url为待处理资源的地址 |
登录
创建一个自定义数据处理
» qdoractl register lj-ufop -d good -m private
Registering ufop lj-ufop...
Ufop name: lj-ufop
Access mode: PRIVATE
Description: good
最小 demo 实践,测试数据处理接口
https://github.com/shliujing/ufop-golang-demo
测试处理资源通过url参数来指定:
运行命令
curl -v "http://127.0.0.1:9100/handler?cmd=doraufoptest&url=http://www.qiniu.com"
来自 http://www.qiniu.com 的网页内容会被打印
测试处理资源通过请求body来指定:
运行命令
curl -d "this should be printed" "http://127.0.0.1:9100/handler?cmd=doraufoptest"
this should be printed将会被打印
健康检查
运行命令
curl -v "http://127.0.0.1:9100/health"
应返回status code为200的报文
部署自定义数据处理
» qdoractl push ufopdemo:v1 1 ↵
The push refers to repository [hub2.qiniu.com/1381458772/ufopdemo]
325e721c978e: Pushed
ed70bd9a74e3: Pushed
bceb77d37525: Pushed
c3e18164144a: Pushed
da78838b161e: Pushed
f4d2be23d596: Pushed
30339f20ced0: Pushed
0eb22bfb707d: Pushed
a2ae92ffcd29: Pushed
v1: digest: sha256:499c21439d2f4d3b6a5d1046ec1dc9df4eaa17c478ce927ce47a3435fa113f58 size: 2212
Push image succeed, total time elapsed 59.693038s, run `qdoractl image` to view the image.
查看镜像
» qdoractl image
Name Ctime
ufopdemo:v1 2019-04-04 15:22:24
创建发布版本
首先,需要准备发布版本的配置文件。运行以下命令,得到 dora.yaml 文件:
qdoractl release --mkconfig .
发布成功
查看该自定义数据处理所有发布版本的详细信息
» qdoractl release lj-ufop -d
Mode: PRIVATE
Releases:
Version Image Flavor Desc Health Check Path Health Check Timeout LogFilePaths Ctime Env
v1 ufopdemo:v1 C1M1 this is my first ufop demo /health 3 [] 2019-04-04 15:46:20
Deploys:
Version Region Expect Actual
调整实例数
» qdoractl deploy lj-ufop v1 --region z0 --expect 2
Deploy success
Please run `qdoractl deploy lj-ufop --id deploy-2e422863-56ae-11e9-975c-00e0ed50e991-1554364171275454236` to view you deploy
Please run `qdoractl release lj-ufop v1 -d` to view you release
查看这次实例调整的最终执行状况
» qdoractl deploy lj-ufop --id deploy-2e422863-56ae-11e9-975c-00e0ed50e991-1554364171275454236
Version Expect Region Created Id Status Message
v1 2 z0 2019-04-04 15:49:31 deploy-2e422863-56ae-11e9-975c-00e0ed50e991-1554364171275454236 DONE