...
The "deploy-mgmt-hub.sh" script has to downloaded downloaded README.md first and variable "HZN_LISTEN_IP" set to 0.0.0.0.
Code Block |
---|
curl -sSL https://raw.githubusercontent.com/open-horizon/devops/master/mgmt-hub/deploy-mgmt-hub.sh |
Then run the script.
Code Block | ||
---|---|---|
| ||
sudo ./deploy-mgmt-hub.sh [sudo] password for ubuntu: ------- Checking input and initializing... Management hub services will listen on http://0.0.0.0 Updating apt-get package index... Installing prerequisites, this could take a minute... ------- Downloading template files... Substituting environment variables into template files... ------- Downloading/starting Horizon management hub services... Downloading management hub docker images... Pulling openhorizon/amd64_agbot:latest ... Pulling openhorizon/amd64_exchange-api:latest ... Pulling openhorizon/amd64_cloud-sync-service:latest ... Pulling postgres:latest ... Pulling mongo:latest ... Pulling openhorizon/sdo-owner-services:latest ... Starting management hub containers... Creating network "hzn_horizonnet" with driver "bridge" Creating volume "hzn_postgresvol" with default driver Creating volume "hzn_mongovol" with default driver Creating volume "hzn_agbotmsgkeyvol" with default driver Creating volume "hzn_ocsdb" with default driver Pulling postgres (postgres:latest)... latest: Pulling from library/postgres 33847f680f63: Pull complete 1b09e96014b3: Pull complete eb49b6d9d1f3: Pull complete 4057ebf78d2d: Pull complete f92d870e2c4f: Pull complete b03847575a18: Pull complete 475945131fa9: Pull complete c042b5a6607d: Pull complete cfe883b776dc: Pull complete 61af04e5c3eb: Pull complete 4e9965ae9062: Pull complete 7b9708b81aa6: Pull complete 871877336770: Pull complete Digest: sha256:6647385dd9ae11aa2216bf55c54d126b0a85637b3cf4039ef24e3234113588e3 Status: Downloaded newer image for postgres:latest Creating postgres ... done Creating mongo ... done Creating exchange-api ... done Creating css-api ... done Creating sdo-owner-services ... done Creating agbot ... done Waiting for the exchange......... ------- Creating the user org, the admin user in both orgs, and an agbot in the exchange... Creating exchange hub admin user, and the admin user and agbot in the system org... Creating exchange user org and admin user... ------- Downloading/installing/configuring Horizon agent and CLI... Downloading the Horizon agent and CLI packages... Installing the Horizon agent and CLI packages... Configuring the Horizon agent and CLI... Warning: can not find a public IP on this host, so the agent-install.cfg file that will be added to CSS will not be usable outside of the this host. You can explicitly specify the public IP via HZN_LISTEN_PUBLIC_IP. Publishing /tmp/horizon-all-in-1/agent-install.cfg in CSS as public object agent-install.cfg in the IBM org... Digital sign with SHA1 will be performed for data integrity. It will delay the MMS object publish. Start hashing the file... Data hash is generated. Start digital signing with the data hash... Digital sign finished. Object agent-install.cfg added to org IBM in the Model Management Service ------- Installing Horizon example services, policies, and patterns... Using examples repo branch v2.29 derived from the hzn version Cloning https://github.com/open-horizon/examples.git to /tmp/open-horizon/examples ... Switching to branch v2.29 ... Warning: examples branch 'v2.29' does not exist, falling back to the master branch Publishing services and patterns of edge/services/cpu_percent to IBM org... Publishing services and patterns of edge/services/gps to IBM org... Publishing services and patterns of edge/services/helloworld to IBM org... Publishing deployment policy of edge/services/helloworld to myorg org... Publishing services and patterns of edge/services/helloMMS to IBM org... Publishing services and patterns of edge/services/nginx-operator to IBM org... Publishing deployment policy of edge/services/nginx-operator to myorg org... Publishing services and patterns of edge/evtstreams/cpu2evtstreams to IBM org... Publishing deployment policy of edge/evtstreams/cpu2evtstreams to myorg org... Successfully published all examples to the exchange. Removing /tmp/open-horizon/examples directory. ------- Creating and registering the edge node with policy to run the helloworld Horizon example... Waiting for the agent to be ready Horizon Exchange base URL: http://127.0.0.1:3090/v1 Node myorg/node1 does not exist in the Exchange with the specified token, creating/updating it... node added or updated Node node1 created. Will proceeed with the given node policy. Updating the node policy... Initializing the Horizon node with node type 'device'... Note: no input file was specified. This is only valid if none of the services need variables set. However, if there is 'userInput' specified in the node already in the Exchange, the userInput will be used. Changing Horizon state to configured to register this node with Horizon... Horizon node is registered. Workload services should begin executing shortly. Waiting for up to 180 seconds for following services to start: IBM/ibm.helloworld Status of the services you are watching: IBM/ibm.helloworld Progress so far: agreement proposal has been received Status of the services you are watching: IBM/ibm.helloworld Progress so far: agreement is accepted Status of the services you are watching: IBM/ibm.helloworld Progress so far: execution is started Status of the services you are watching: IBM/ibm.helloworld Success ----------- Summary of what was done: 1. Started Horizon management hub services: agbot, exchange, postgres DB, CSS, mongo DB 2. Created exchange resources: system org (IBM) admin user, user org (myorg) and admin user, and agbot Automatically generated these passwords/tokens: EXCHANGE_ROOT_PW=T2lICI9q5xvwtkeLPRrGZkcp5RUSwG EXCHANGE_HUB_ADMIN_PW=3G84oId3MEk4S5BjOF3m6KRNfph5BT EXCHANGE_SYSTEM_ADMIN_PW=khDHsRMe4Ca29gPZNp17dDirnbm1W0 AGBOT_TOKEN=aYGhdC7i6JPohkt4LXGkdq7NT99P1U EXCHANGE_USER_ADMIN_PW=1eAVOw1dWRKve5b5KIkRk2PcBjXLnO HZN_DEVICE_TOKEN=Zm4Y1wFgrUD2D1MTrtn1UmyBaOnn8u Important: save these generated passwords/tokens in a safe place. You will not be able to query them from Horizon. 3. Installed and configured the Horizon agent and CLI (hzn) 4. Created a Horizon developer key pair 5. Installed the Horizon examples 6. Created and registered an edge node to run the helloworld example edge service 7. Added the hzn auto-completion file to ~/.bashrc (but you need to source that again for it to take effect in this shell session) For what to do next, see: https://github.com/open-horizon/devops/blob/master/mgmt-hub/README.md#all-in-1-what-next Before running the commands in the What To Do Next section, copy/paste/run these commands in your terminal: export HZN_ORG_ID=myorg export HZN_EXCHANGE_USER_AUTH=admin:1eAVOw1dWRKve5b5KIkRk2PcBjXLnO ubuntu@ubun2:~$ |
...
Agent deb packages are available for different architectures under Agent releases. For more information check section "Agent installation and registration".
Configuration after installation Open Horizon Management Hub and Agent
...
Sample output
Code Block |
---|
2.78.0 |
Trying to configure agent
Firstly the problem seems to be that agent is not configured.
Code Block | ||
---|---|---|
| ||
ubuntu@ubuntu:~$ hzn node list
{
"id": "node1",
"organization": null,
"pattern": null,
"name": null,
"nodeType": null,
"token_last_valid_time": "",
"token_valid": null,
"ha": null,
"configstate": {
"state": "unconfigured",
"last_update_time": ""
},
"configuration": {
"exchange_api": "http://192.168.100.32:3090/v1/",
"exchange_version": "2.78.0",
"required_minimum_exchange_version": "2.44.0",
"preferred_exchange_version": "2.76.0",
"mms_api": "http://192.168.100.32:9443",
"architecture": "arm",
"horizon_version": "2.29.0-498"
}
}
ubuntu@ubuntu:~$ |
Agent configuration - it has to be investigated.
https://open-horizon.github.io/docs/installing/automated_install.html
ubuntu@ubuntu:/$ cd /usr/horizon/bin/
ubuntu@ubuntu:/usr/horizon/bin$ ls
agent-install.sh agent-uninstall.sh anax edgeNodeFiles.sh horizon-container hzn
ubuntu@ubuntu:/usr/horizon/bin$ sudo -s ./agent-install.sh -i 'css:' -p IBM/pattern-ibm.helloworld -w '*' -T 120
2021-08-03 19:44:04 AGENT_INSTALL_ZIP: (from default value)
2021-08-03 19:44:04 INPUT_FILE_PATH: css: (from command line flag)
2021-08-03 19:44:04 INPUT_FILE_PATH adjusted to: css:/api/v1/objects/IBM/agent_files
2021-08-03 19:44:04 AGENT_CFG_FILE: (from default value)
2021-08-03 19:44:04 AGENT_VERBOSITY: 3 (from environment variable)
2021-08-03 19:44:04 ERROR: A value for HZN_ORG_ID must be specified
ubuntu@ubuntu:/usr/horizon/bin$ env | grep HZN
HZN_DEVICE_TOKEN=Zm4Y1wFgrUD2D1MTrtn1UmyBaOnn8u
HZN_DEVICE_ID=node1
HZN_ORG_ID=myorg
HZN_EXCHANGE_USER_AUTH=admin:1eAVOw1dWRKve5b5KIkRk2PcBjXLnO
HZN_EXCHANGE_URL=http://192.168.100.32:3090/v1/
HZN_FSS_CSSURL=http://192.168.100.32:9443/
ubuntu@ubuntu:/usr/horizon/bin$ export HZN_ORG_ID=myorg
ubuntu@ubuntu:/usr/horizon/bin$ sudo -s ./agent-install.sh -i 'css:' -p IBM/pattern-ibm.helloworld -w '*' -T 120
2021-08-03 19:44:50 AGENT_INSTALL_ZIP: (from default value)
2021-08-03 19:44:50 INPUT_FILE_PATH: css: (from command line flag)
2021-08-03 19:44:50 INPUT_FILE_PATH adjusted to: css:/api/v1/objects/IBM/agent_files
2021-08-03 19:44:50 AGENT_CFG_FILE: (from default value)
2021-08-03 19:44:50 AGENT_VERBOSITY: 3 (from environment variable)
2021-08-03 19:44:50 ERROR: A value for HZN_ORG_ID must be specified
ubuntu@ubuntu:/usr/horizon/bin$ sudo export HZN_ORG_ID=myorg
sudo: export: command not found
ubuntu@ubuntu:/usr/horizon/bin$ sudo su
root@ubuntu:/usr/horizon/bin#
root@ubuntu:/usr/horizon/bin# HZN_ORG_ID=myorg
root@ubuntu:/usr/horizon/bin# export HZN_ORG_ID=myorg
root@ubuntu:/usr/horizon/bin# env | grep HZN
HZN_ORG_ID=myorg
root@ubuntu:/usr/horizon/bin# ./agent-install.sh -i 'css:' -p IBM/pattern-ibm.helloworld -w '*' -T 120
2021-08-03 19:46:08 AGENT_INSTALL_ZIP: (from default value)
2021-08-03 19:46:08 INPUT_FILE_PATH: css: (from command line flag)
2021-08-03 19:46:08 INPUT_FILE_PATH adjusted to: css:/api/v1/objects/IBM/agent_files
2021-08-03 19:46:08 AGENT_CFG_FILE: (from default value)
2021-08-03 19:46:08 AGENT_VERBOSITY: 3 (from environment variable)
2021-08-03 19:46:08 HZN_ORG_ID: myorg (from environment variable)
2021-08-03 19:46:08 HZN_MGMT_HUB_CERT_PATH: (from default value)
2021-08-03 19:46:08 AGENT_CERT_FILE: agent-install.crt (from default value)
2021-08-03 19:46:08 ERROR: A value for HZN_FSS_CSSURL must be specified
root@ubuntu:/usr/horizon/bin# export HZN_DEVICE_TOKEN=Zm4Y1wFgrUD2D1MTrtn1UmyBaOnn8u
root@ubuntu:/usr/horizon/bin# export HZN_DEVICE_ID=node1
root@ubuntu:/usr/horizon/bin# export HZN_ORG_ID=myorg
root@ubuntu:/usr/horizon/bin# export HZN_EXCHANGE_USER_AUTH=admin:1eAVOw1dWRKve5b5KIkRk2PcBjXLnO
root@ubuntu:/usr/horizon/bin# export HZN_EXCHANGE_URL=http://192.168.100.32:3090/v1/
root@ubuntu:/usr/horizon/bin# export HZN_FSS_CSSURL=http://192.168.100.32:9443/
root@ubuntu:/usr/horizon/bin# ./agent-install.sh -i 'css:' -p IBM/pattern-ibm.helloworld -w '*' -T 120
2021-08-03 19:47:57 AGENT_INSTALL_ZIP: (from default value)
2021-08-03 19:47:57 INPUT_FILE_PATH: css: (from command line flag)
2021-08-03 19:47:57 INPUT_FILE_PATH adjusted to: css:/api/v1/objects/IBM/agent_files
2021-08-03 19:47:57 AGENT_CFG_FILE: (from default value)
2021-08-03 19:47:57 AGENT_VERBOSITY: 3 (from environment variable)
2021-08-03 19:47:57 HZN_ORG_ID: myorg (from environment variable)
2021-08-03 19:47:57 HZN_MGMT_HUB_CERT_PATH: (from default value)
2021-08-03 19:47:57 AGENT_CERT_FILE: agent-install.crt (from default value)
2021-08-03 19:47:57 HZN_FSS_CSSURL: http://192.168.100.32:9443/ (from environment variable)
2021-08-03 19:47:57 HZN_EXCHANGE_USER_AUTH: ****** (from environment variable)
2021-08-03 19:47:57 HZN_EXCHANGE_NODE_AUTH: (from default value)
2021-08-03 19:47:57 Downloading file http://192.168.100.32:9443/api/v1/objects/IBM/agent_files/agent-install.cfg/data ...
2021-08-03 19:47:58 AGENT_SKIP_REGISTRATION: false (from default value)
2021-08-03 19:47:58 HZN_EXCHANGE_URL: http://192.168.100.32:3090/v1/ (from environment variable)
2021-08-03 19:47:58 HZN_AGBOT_URL: http://127.0.0.1:3111 (from configuration file)
2021-08-03 19:47:58 HZN_SDO_SVC_URL: http://127.0.0.1:9008/api (from configuration file)
2021-08-03 19:47:58 NODE_ID: (from default value)
2021-08-03 19:47:58 HZN_DEVICE_ID: node1 (from environment variable)
2021-08-03 19:47:58 HZN_NODE_ID: (from default value)
2021-08-03 19:47:58 HZN_EXCHANGE_PATTERN: IBM/pattern-ibm.helloworld (from command line flag)
2021-08-03 19:47:58 HZN_NODE_POLICY: (from default value)
2021-08-03 19:47:58 AGENT_WAIT_FOR_SERVICE: * (from command line flag)
2021-08-03 19:47:58 AGENT_WAIT_FOR_SERVICE_ORG: (from default value)
2021-08-03 19:47:58 AGENT_REGISTRATION_TIMEOUT: 120 (from command line flag)
2021-08-03 19:47:58 AGENT_OVERWRITE: false (from default value)
2021-08-03 19:47:58 AGENT_SKIP_PROMPT: false (from default value)
2021-08-03 19:47:58 AGENT_ONLY_CLI: false (from default value)
2021-08-03 19:47:58 AGENT_INSTALL_ZIP: agent-install-files.tar.gz (from default value)
2021-08-03 19:47:58 AGENT_DEPLOY_TYPE: device (from default value)
2021-08-03 19:47:58 AGENT_WAIT_MAX_SECONDS: 30 (from default value)
2021-08-03 19:47:58 OS: linux, Distro: ubuntu, Distro Release: 20.04, Distro Code Name: focal, Architecture: armhf
2021-08-03 19:47:58 NODE_ID_MAPPING_FILE: node-id-mapping.csv (from default value)
2021-08-03 19:47:58 PKG_APT_KEY: (from default value)
2021-08-03 19:47:58 APT_REPO_BRANCH: updates (from default value)
2021-08-03 19:47:58 AGENT_IMAGE_TAR_FILE: amd64_anax.tar.gz (from default value)
2021-08-03 19:47:58 WARNING: Using node id from HZN_DEVICE_ID
2021-08-03 19:47:58 Node type: device
2021-08-03 19:47:58 Updating apt package index...
2021-08-03 19:48:51 Installing prerequisites, this could take a minute...
./agent-install.sh: line 1169: netstat: command not found
2021-08-03 19:49:04 Verifying that node node1 in the exchange is type device (if it exists)...
2021-08-03 19:49:05 Updating /etc/default/horizon ...
2021-08-03 19:49:06 Downloading file http://192.168.100.32:9443/api/v1/objects/IBM/agent_files/horizon-agent-linux-deb-armhf.tar.gz/data ...
2021-08-03 19:49:06 ERROR: HTTP code 403 from: downloading http://192.168.100.32:9443/api/v1/objects/IBM/agent_files/horizon-agent-linux-deb-armhf.tar.gz/data, stdout: Unauthorized. The object may not exist or be public.
root@ubuntu:/usr/horizon/bin#Investigate:
https://github.com/open-horizon/anax/blob/master/docs/api.md
Agent installation and registration
Install docker
follow
https://docs.docker.com/engine/install/ubuntu/
Install required dependencies by Agent.
Code Block |
---|
sudo apt-get install jq |
then download and install agent package from
https://github.com/open-horizon/anax/releases
Follow
https://open-horizon.github.io/docs/installing/advanced_man_install.html
to change
Code Block |
---|
/etc/default/horizon |
like following
Code Block |
---|
ubuntu@ubuntu:~$ cat /etc/default/horizon
HZN_EXCHANGE_URL=http://192.168.100.32:3090/v1
HZN_FSS_CSSURL=http://192.168.100.32:9443/
HZN_AGBOT_URL=http://127.0.0.1:3111
HZN_MGMT_HUB_CERT_PATH=
HZN_DEVICE_ID=node1
HZN_AGENT_PORT=8510
ubuntu@ubuntu:~$ |
Next restart horizon service to apply changed settings.
Code Block |
---|
sudo systemctl restart horizon.service |
Check configuration
Code Block |
---|
ubuntu@ubuntu:~$ hzn version
Horizon CLI version: 2.29.0-537
Horizon Agent version: 2.29.0-537
ubuntu@ubuntu:~$ |
Code Block |
---|
ubuntu@ubuntu:~$ hzn exchange version
2.78.0
ubuntu@ubuntu:~$ |
Code Block |
---|
ubuntu@ubuntu:~$ hzn node list
{
"id": "node1",
"organization": "myorg",
"pattern": "IBM/pattern-ibm.helloworld",
"name": "node1",
"nodeType": "device",
"token_last_valid_time": "2021-08-10 00:15:28 +0000 UTC",
"token_valid": true,
"ha": false,
"configstate": {
"state": "configured",
"last_update_time": "2021-08-10 00:15:29 +0000 UTC"
},
"configuration": {
"exchange_api": "http://192.168.100.32:3090/v1/",
"exchange_version": "2.78.0",
"required_minimum_exchange_version": "2.44.0",
"preferred_exchange_version": "2.81.0",
"mms_api": "http://192.168.100.32:9443",
"architecture": "arm64",
"horizon_version": "2.29.0-537"
}
}
ubuntu@ubuntu:~$ |
Check available patterns
Code Block |
---|
ubuntu@ubuntu:~$ hzn exchange pattern list IBM/
[
"IBM/pattern-ibm.cpu2evtstreams",
"IBM/pattern-ibm.hello-mms-arm",
"IBM/pattern-ibm.hello-mms",
"IBM/pattern-nginx-operator-amd64",
"IBM/pattern-ibm.helloworld",
"IBM/pattern-ibm.hello-mms-amd64",
"IBM/pattern-ibm.hello-mms-arm64"
]
ubuntu@ubuntu:~$ |
Register agent. Instead of
Code Block |
---|
hzn register -p IBM/pattern-ibm.helloworld |
run
Code Block |
---|
hzn register -p IBM/pattern-ibm.helloworld -s ibm.helloworld --serviceorg IBM |
from
https://github.com/open-horizon/examples/blob/master/edge/services/helloworld/README.md#preconditions
Code Block |
---|
ubuntu@ubuntu:~$ hzn register -p IBM/pattern-ibm.helloworld -s ibm.helloworld --serviceorg IBM
Horizon Exchange base URL: http://192.168.100.32:3090/v1
Using node ID 'node1' from the Horizon agent
Generated random node token
Updating node token...
Will proceeed with the given pattern IBM/pattern-ibm.helloworld.
Initializing the Horizon node with node type 'device'...
Note: no input file was specified. This is only valid if none of the services need variables set.
However, if there is 'userInput' specified in the node already in the Exchange, the userInput will be used.
Changing Horizon state to configured to register this node with Horizon...
Horizon node is registered. Workload services should begin executing shortly.
Waiting for up to 60 seconds for following services to start:
IBM/ibm.helloworld
Status of the services you are watching:
IBM/ibm.helloworld Progress so far: agreement proposal has been received
Status of the services you are watching:
IBM/ibm.helloworld Progress so far: agreement is accepted
Status of the services you are watching:
IBM/ibm.helloworld Progress so far: service is created
Status of the services you are watching:
IBM/ibm.helloworld Progress so far: execution is started
Status of the services you are watching:
IBM/ibm.helloworld Success
ubuntu@ubuntu:~$ |
Code Block |
---|
ubuntu@ubuntu:~$ hzn agreement list
[
{
"name": "pattern-ibm.helloworld_ibm.helloworld_IBM_arm64 merged with pattern-ibm.helloworld_ibm.helloworld_IBM_arm64",
"current_agreement_id": "8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6",
"consumer_id": "IBM/agbot",
"agreement_creation_time": "2021-08-10 00:15:37 +0000 UTC",
"agreement_accepted_time": "2021-08-10 00:15:40 +0000 UTC",
"agreement_finalized_time": "2021-08-10 00:15:48 +0000 UTC",
"agreement_execution_start_time": "2021-08-10 00:15:48 +0000 UTC",
"agreement_data_received_time": "",
"agreement_protocol": "Basic",
"workload_to_run": {
"url": "ibm.helloworld",
"org": "IBM",
"version": "1.0.0",
"arch": "arm64"
}
}
]
ubuntu@ubuntu:~$ |
Check whether docker container is running.
Code Block |
---|
ubuntu@ubuntu:~$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
6a8c986c5955 openhorizon/ibm.helloworld_arm64 "/bin/sh -c /service…" 4 minutes ago Up 4 minutes 8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6-ibm.helloworld |
Check logs from running container.
Code Block |
---|
ubuntu@ubuntu:~$ hzn service log -f ibm.helloworld
Found service ibm.helloworld with service id 8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6.
Displaying log messages of container ibm.helloworld for service ibm.helloworld with service id 8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6.
Use ctrl-C to terminate this command.
Aug 10 00:15:48 ubuntu workload-8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6_ibm.helloworld[1934]: node1 says: Hello World!!
Aug 10 00:15:51 ubuntu workload-8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6_ibm.helloworld[1934]: node1 says: Hello World!!
Aug 10 00:15:54 ubuntu workload-8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6_ibm.helloworld[1934]: node1 says: Hello World!!
Aug 10 00:15:57 ubuntu workload-8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6_ibm.helloworld[1934]: node1 says: Hello World!!
Aug 10 00:16:00 ubuntu workload-8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6_ibm.helloworld[1934]: node1 says: Hello World!!
Aug 10 00:16:03 ubuntu workload-8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6_ibm.helloworld[1934]: node1 says: Hello World!!
Aug 10 00:16:06 ubuntu workload-8c61ebcabbafcf380758739116cb5603bed33d64984862a910c20c56a6b003b6_ibm.helloworld[1934]: node1 says: Hello World!! |