我想为通知启用https。 Orion Context Broker版本1.7.0安装在Ubuntu 16.04中。首先,使用以下命令:
sudo /etc/init.d/contextBroker start -logAppend -https -key /path/to/orion.key -cert /path/to/orion.crt
答案是:
[ ok ] Starting contextBroker (via systemctl): contextBroker.service.
状态是:
sudo systemctl status contextBroker.service
contextBroker.service - LSB: Example initscript
Loaded: loaded (/etc/init.d/contextBroker; bad; vendor preset: enabled)
Active: active (exited) since Tue 2017-04-04 12:56:13 BRT; 14s ago
Docs: man:systemd-sysv-generator(8)
Process: 8312 ExecStart=/etc/init.d/contextBroker start (code=exited, status=0/SUCCESS)
Apr 04 12:56:13 fiware-ubuntu systemd[1]: Starting LSB: Example initscript...
Apr 04 12:56:13 fiware-ubuntu contextBroker[8312]: contextBroker
Apr 04 12:56:13 fiware-ubuntu contextBroker[8312]: /path/bin/contextBroker
Apr 04 12:56:13 fiware-ubuntu systemd[1]: Started LSB: Example initscript.
另一种方法是运行猎户座:
sudo /path/bin/contextBroker -logLevel DEBUG -localIp x.y.z.t -https -key /path/to/orion.key -cert /path/to/orion.crt
日志如下:
time=2017-04-04T18:37:58.881Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=contextBroker.cpp[1705]:main | msg=Orion Context Broker is running
time=2017-04-04T18:37:58.887Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=mongoConnectionPool.cpp[205]:mongoConnect | msg=Successful connection to database
time=2017-04-04T18:37:58.887Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=connectionOperations.cpp[681]:setWriteConcern | msg=Database Operation Successful (setWriteConcern: 1)
time=2017-04-04T18:37:58.887Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=connectionOperations.cpp[724]:getWriteConcern | msg=Database Operation Successful (getWriteConcern)
time=2017-04-04T18:37:58.888Z | lvl=INFO | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=connectionOperations.cpp[626]:runCollectionCommand | msg=Database Operation Successful (command: { buildinfo: 1 })
...
time=2017-04-04T18:37:58.897Z | lvl=FATAL | corr=N/A | trans=N/A | from=N/A | srv=N/A | subsrv=N/A | comp=Orion | op=rest.cpp[1720]:restStart | msg=Fatal Error (error starting REST interface)
它不起作用......
如果您将Orion作为服务运行(如建议的那样),则必须在/etc/sysconfig/contexBroker
文件中配置命令行参数。该文件在this piece of documentation中解释。
请注意文件末尾的BROKER_EXTRA_OPS
变量。这用于包括未使用任何其他选项设置的CLI参数,与您正在使用的HTTPS相关的参数。因此,应该以这种方式设置BROKER_EXTRA_OPS
:
BROKER_EXTRA_OPS="-logAppend -https -key /path/to/orion.key -cert /path/to/orion.crt"
然后使用以下命令启动服务
sudo /etc/init.d/contextBroker start
(注意'start'后没有添加参数)
您可以使用ps ax | grep contextBroker
检查Orion是否使用正确的参数运行。
最后,关于错误Fatal Error (error starting REST interface)
,当Orion由于某种原因无法启动REST API的侦听服务器时会出现错误。通常这是由于某些其他进程(可能是一个被遗忘的Orion实例)在同一端口上运行。使用sudo netstat -ntpld | grep 1026
知道哪个其他进程可以在该部分进行侦听(假设1026是您尝试运行Orion的端口,当然)。