From 8412b61812d947751b048aeaa0a2e7146d73c2d8 Mon Sep 17 00:00:00 2001 From: Andrii Landiak Date: Tue, 12 Sep 2023 16:33:30 +0300 Subject: [PATCH] Improve centos and ubuntu instruction for edge --- .../centos/instructions.md | 64 ++++++++++++++++--- .../docker/instructions.md | 2 +- .../ubuntu/instructions.md | 55 +++++++++++++++- .../server/controller/EdgeController.java | 2 +- 4 files changed, 108 insertions(+), 15 deletions(-) diff --git a/application/src/main/data/json/edge/install_instructions/centos/instructions.md b/application/src/main/data/json/edge/install_instructions/centos/instructions.md index d42ce4499e..3b0b823777 100644 --- a/application/src/main/data/json/edge/install_instructions/centos/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/centos/instructions.md @@ -158,21 +158,65 @@ sudo rpm -Uvh tb-edge-${TB_EDGE_VERSION}.rpm {: .copy-code} ### Configure ThingsBoard Edge +To configure ThingsBoard Edge, you can either manually edit the configuration file or use a command to automate the process. - -#### [Optional] Update bind ports -If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update docker compose port mapping to avoid port collision between ThingsBoard server and ThingsBoard Edge. - -Please update next lines of `docker-compose.yml` file: +#### Automated Configuration +You can use the following command to automatically update the configuration file with specific values: ```bash -ports: - - "18080:8080" - - "11883:1883" - - "15683-15688:5683-5688/udp" +sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export CLOUD_RPC_SSL_ENABLED=${CLOUD_RPC_SSL_ENABLED} +EOL' ``` -Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. +{: .copy-code} +#### Manual Configuration + +```bash +sudo nano /etc/tb-edge/conf/tb-edge.conf +``` +{: .copy-code} + +Please update the following lines in your configuration file. Make sure to replace: + +```text +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE + +``` + +#### [Optional] Update bind ports +If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. + +Please uncomment the following parameters in the ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): + +```text +export HTTP_BIND_PORT=18080 +export MQTT_BIND_PORT=11883 +export COAP_BIND_PORT=15683 +export LWM2M_ENABLED=false +``` + +Or update using command: + +```bash +sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf +export HTTP_BIND_PORT=18080 +export MQTT_BIND_PORT=11883 +export COAP_BIND_PORT=15683 +export LWM2M_ENABLED=false +EOL' +``` +{: .copy-code} + +Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. #### Run installation script Once ThingsBoard Edge is installed and configured please execute the following install script: diff --git a/application/src/main/data/json/edge/install_instructions/docker/instructions.md b/application/src/main/data/json/edge/install_instructions/docker/instructions.md index 14307dbea7..d01986a831 100644 --- a/application/src/main/data/json/edge/install_instructions/docker/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/docker/instructions.md @@ -69,7 +69,7 @@ If ThingsBoard Edge is going to be running on the same machine where ThingsBoard Please update next lines of `docker-compose.yml` file: -```bash +```text ports: - "18080:8080" - "11883:1883" diff --git a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md index 58df993bfa..ab2bf6f8b4 100644 --- a/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md +++ b/application/src/main/data/json/edge/install_instructions/ubuntu/instructions.md @@ -86,10 +86,57 @@ Go to the download repository and install ThingsBoard Edge service ```bash sudo dpkg -i tb-edge-{TB_EDGE_VERSION}.deb -{:copy-code} +``` +{: .copy-code} + +### Configure ThingsBoard Edge +To configure ThingsBoard Edge, you can either manually edit the configuration file or use a command to automate the process. + +#### Automated Configuration +You can use the following command to automatically update the configuration file with specific values: + +```bash +sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export CLOUD_RPC_SSL_ENABLED=${CLOUD_RPC_SSL_ENABLED} +EOL' +``` +{: .copy-code} + +#### Manual Configuration + +```bash +sudo nano /etc/tb-edge/conf/tb-edge.conf +``` +{: .copy-code} + +Please update the following lines in your configuration file. Make sure to replace: + +```text +export CLOUD_ROUTING_KEY=${CLOUD_ROUTING_KEY} +export CLOUD_ROUTING_SECRET=${CLOUD_ROUTING_SECRET} +export CLOUD_RPC_HOST=${BASE_URL} +export CLOUD_RPC_PORT=${CLOUD_RPC_PORT} +export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE + ``` -Edit ThingsBoard Edge configuration file +#### [Optional] Update bind ports +If ThingsBoard Edge is going to be running on the same machine where ThingsBoard server (cloud) is running, you'll need to update configuration parameters to avoid port collision between ThingsBoard server and ThingsBoard Edge. + +Please uncomment the following parameters in the ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): + +```text +export HTTP_BIND_PORT=18080 +export MQTT_BIND_PORT=11883 +export COAP_BIND_PORT=15683 +export LWM2M_ENABLED=false +``` + +Or update using command: ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -98,8 +145,10 @@ export MQTT_BIND_PORT=11883 export COAP_BIND_PORT=15683 export LWM2M_ENABLED=false EOL' -{:copy-code} ``` +{: .copy-code} + +Make sure that ports above (18080, 11883, 15683-15688) are not used by any other application. #### Run installation script diff --git a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java index 2bc9c0e128..fa16fbff81 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java @@ -562,7 +562,7 @@ public class EdgeController extends BaseController { public EdgeInstallInstructions getEdgeDockerInstallInstructions( @ApiParam(value = EDGE_ID_PARAM_DESCRIPTION, required = true) @PathVariable("edgeId") String strEdgeId, - @ApiParam(value = "Installation method (e.g., 'docker', 'ubuntu', 'centos')") + @ApiParam(value = "Installation method ('docker', 'ubuntu' or 'centos')") @PathVariable("method") String installationMethod, HttpServletRequest request) throws ThingsboardException { if (isEdgesEnabled() && edgeInstallServiceOpt.isPresent()) {