Ubuntu 14.04系统上安装部署OpenWhisk(本地CouchDB版本)

1.安装配置CouchDB

$ sudo apt-get install -V couchdb

校验CouchDB是否工作正常

$ curl –k http://127.0.0.1:5984

看到如下输出即可

{"couchdb":"Welcome","uuid":"87586fee02b1149fa06dda7148450d4a","version":"1.5.0","vendor":{"name":"Ubuntu","version":"14.04"}}

2.编译配置OpenWhisk

下载OpenWhisk的源代码

$ sudo apt-get install git

$ cd  ~

$ git clone https://github.com/apache/incubator-openwhisk.git

配置OpenWhisk编译需要的环境

$ cd incubator-openwhisk

# Install all required software
$ cd tools/ubuntu-setup

$ sudo ./all.sh

执行编译

#返会代码根目录
$ cd ../..

$ sudo ./gradlew distDocker

3.发布并运行OpenWhisk服务

配置运行环境

$ cd ~

$ cd incubator-openwhisk

$ cd ansible

#只在第一次初始化数据库的时候执行这句话
$ sudo ansible-playbook -i environments/local/ setup.yml

$ sudo ansible-playbook -i environments/local/ openwhisk.yml

安装必备软件

#系统自带的版本太低,但是还是需要安装一下,用来解决依赖问题
$ cd ~
$ sudo apt-get install vagrant

$ wget https://releases.hashicorp.com/vagrant/1.9.7/vagrant_1.9.7_x86_64.deb

$ sudo dpkg -i vagrant*.deb

$ sudo apt-get install virtualbox

运行测试Demo

$ cd ~/incubator-openwhisk/tools/vagrant

$ ./hello

如过想查看刚刚通过vagrant部署完成的镜像系统里面的内容,则执行如下命令:

$ cd ~/incubator-openwhisk/tools/vagrant

$ sudo vagrant ssh

如果成功部署了OpenWhisk,那么可以在Docker机器中执行如下代码验证是否可以正常调用

$ cd ~/incubator-openwhisk/tools/vagrant

$ sudo vagrant ssh

$ wsk action invoke /whisk.system/utils/echo -p message hello --result
#输出结果
{
    "message": "hello"
}

$ wsk package list /whisk.system
#输出结果
packages
/whisk.system/watson-textToSpeech                                      shared
/whisk.system/weather                                                  shared
/whisk.system/watson-translator                                        shared
/whisk.system/combinators                                              shared
/whisk.system/samples                                                  shared
/whisk.system/github                                                   shared
/whisk.system/utils                                                    shared
/whisk.system/websocket                                                shared
/whisk.system/slack                                                    shared
/whisk.system/watson-speechToText                                      shared

外部的机器访问则执行如下命令来验证

$ cd ~/incubator-openwhisk/bin/

#注意参数 -i  --apihost 里指定的地址在部署镜像的时候vagrant脚本中指定的
$ ./wsk -i property set --apihost 192.168.33.13 --namespace guest --auth `cat ~/incubator-openwhisk/ansible/files/auth.guest`

$ ./wsk -i action invoke /whisk.system/utils/echo -p message hello --result
#输出结果 
{ 
"message": "hello" 
}

4.遇到的问题

最大的问题是在编译发布的过程中系统分区被消耗干净,导致编译发布失败。
解决方法如下
1.参照Ubuntu 16.04系统上修改Docker镜像的存储路径介绍的方法调整Docker镜像的存储路径到合适的分区
2.如果使用sudo的方式执行,那么可能会在/root目录下生成虚拟机的镜像文件,同样导致系统分区被消耗,解决方法也是通过软链接的方式把/root目录链接到合适的分区目录

如过执行中遇到如下错误,则增加-i参数即可

$ ./wsk action invoke /whisk.system/utils/echo -p message hello --result
error: Unable to invoke action 'utils/echo': Post https://192.168.33.13/api/v1/namespaces/whisk.system/actions/utils/echo?blocking=true&result=true: x509: cannot validate certificate for 192.168.33.13 because it doesn't contain any IP SANs
Run 'wsk --help' for usage.

参考链接


发布者

《Ubuntu 14.04系统上安装部署OpenWhisk(本地CouchDB版本)》上有2条评论

  1. 你好,我在./hello这步遇到了
    `The VirtualBox VM was created with a user that doesn't match the
    current user running Vagrant. VirtualBox requires that the same user
    be used to manage the VM that was created. Please re-run Vagrant with
    that user. This is not a Vagrant issue.

    The UID used to create the VM was: 20001
    Your UID is: 0`
    这个问题 请问您遇到过吗如何解决

回复 默默 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注