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 3b0b823777..486249e320 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 @@ -1,8 +1,6 @@ -## Install ThingsBoard Edge on CentOS/RHEL Server - Here is the list of commands, that can be used to quickly install ThingsBoard Edge on RHEL/CentOS 7/8 and connect to the cloud. -### Prerequisites +#### Prerequisites Before continue to installation execute the following commands in order to install necessary tools: ```bash @@ -10,28 +8,28 @@ sudo yum install -y nano wget sudo yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm ``` -### Install Java 11 (OpenJDK) -ThingsBoard service is running on Java 11. Follow this instructions to install OpenJDK 11: +#### Install Java 11 (OpenJDK) +ThingsBoard service is running on Java 11. Follow these instructions to install OpenJDK 11: ```bash sudo yum install java-11-openjdk +{:copy-code} ``` -{: .copy-code} Please don't forget to configure your operating system to use OpenJDK 11 by default. You can configure which version is the default using the following command: ```bash sudo update-alternatives --config java +{:copy-code} ``` -{: .copy-code} You can check the installation using the following command: ```bash java -version +{:copy-code} ``` -{: .copy-code} Expected command output is: @@ -41,15 +39,15 @@ OpenJDK Runtime Environment (...) OpenJDK 64-Bit Server VM (build ...) ``` -### Configure PostgreSQL +#### Configure PostgreSQL ThingsBoard Edge uses PostgreSQL database as a local storage. Instructions listed below will help you to install PostgreSQL. ```bash # Update your system sudo yum update +{:copy-code} ``` -{: .copy-code} **For CentOS 7:** @@ -66,8 +64,8 @@ sudo systemctl start postgresql-12 # Optional: Configure PostgreSQL to start on boot sudo systemctl enable --now postgresql-12 +{:copy-code} ``` -{: .copy-code} **For CentOS 8:** @@ -83,8 +81,8 @@ sudo systemctl start postgresql-12 # Optional: Configure PostgreSQL to start on boot sudo systemctl enable --now postgresql-12 +{:copy-code} ``` -{: .copy-code} Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. The instructions below will help to set the password for main postgresql user @@ -104,8 +102,8 @@ Edit pg_hba.conf file: ```bash sudo nano /var/lib/pgsql/12/data/pg_hba.conf +{:copy-code} ``` -{: .copy-code} Locate the following lines: @@ -124,44 +122,41 @@ Finally, you should restart the PostgreSQL service to initialize the new configu ```bash sudo systemctl restart postgresql-12.service +{:copy-code} ``` -{: .copy-code} Connect to the database to create ThingsBoard Edge DB: ```bash psql -U postgres -d postgres -h 127.0.0.1 -W +{:copy-code} ``` -{: .copy-code} Execute create database statement ```bash CREATE DATABASE tb_edge; \q +{:copy-code} ``` -{: .copy-code} -### ThingsBoard Edge service installation -Download installation package. +#### ThingsBoard Edge service installation +Download installation package: ```bash -wget https://github.com/thingsboard/thingsboard-edge/releases/download/{{ site.release.edge_tag }}/tb-edge-{{ site.release.edge_ver }}.rpm +wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_VERSION}/tb-edge-${TB_EDGE_VERSION}.rpm +{:copy-code} ``` -{: .copy-code} Go to the download repository and install ThingsBoard Edge service ```bash sudo rpm -Uvh tb-edge-${TB_EDGE_VERSION}.rpm +{: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: +#### Configure ThingsBoard Edge +To configure ThingsBoard Edge, 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 @@ -171,40 +166,33 @@ 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} ``` -{: .copy-code} -#### Manual Configuration +##### [Optional] Database Configuration +In case you changed default PostgreSQL datasource settings please update the configuration file with your actual values (**/etc/tb-edge/conf/tb-edge.conf**). +Edit ThingsBoard Edge configuration file: ```bash sudo nano /etc/tb-edge/conf/tb-edge.conf +{:copy-code} ``` -{: .copy-code} -Please update the following lines in your configuration file. Make sure to replace: +Please update the following lines in your configuration file. Make sure **to replace**: +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource username +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource password. -```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} +```bash +export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/tb_edge +export SPRING_DATASOURCE_USERNAME=PUT_YOUR_POSTGRESQL_USERNAME_HERE export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE - +{:copy-code} ``` -#### [Optional] Update bind ports +##### [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: +Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -213,22 +201,24 @@ 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 Once ThingsBoard Edge is installed and configured please execute the following install script: ```bash sudo /usr/share/tb-edge/bin/install/install.sh +{:copy-code} ``` -{: .copy-code} -### Restart ThingsBoard Edge service +#### Restart ThingsBoard Edge service ```bash sudo service tb-edge restart +{:copy-code} ``` #### Open ThingsBoard Edge UI 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 d01986a831..e308a38076 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 @@ -1,12 +1,10 @@ -## Install ThingsBoard Edge using Docker - Here is the list of commands, that can be used to quickly install ThingsBoard Edge using docker compose and connect to the cloud. -### Prerequisites +#### Prerequisites Install Docker CE and Docker Compose. -### Create data and logs folders +#### Create data and logs folders Run following commands, before starting docker container(s), to create folders for storing data and logs. These commands additionally will change owner of newly created folders to docker container user. @@ -18,7 +16,7 @@ mkdir -p ~/.mytb-edge-logs && sudo chown -R 799:799 ~/.mytb-edge-logs {:copy-code} ``` -### Running ThingsBoard Edge as docker service +#### Running ThingsBoard Edge as docker service ${LOCALHOST_WARNING} @@ -64,7 +62,7 @@ services: {:copy-code} ``` -#### [Optional] Update bind ports +##### [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: 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 ab2bf6f8b4..21eb01654a 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 @@ -1,30 +1,28 @@ -## Install ThingsBoard Edge on Ubuntu Server - Here is the list of commands, that can be used to quickly install ThingsBoard Edge on Ubuntu Server and connect to the cloud. -### Install Java 11 (OpenJDK) -ThingsBoard service is running on Java 11. Follow this instructions to install OpenJDK 11: +#### Install Java 11 (OpenJDK) +ThingsBoard service is running on Java 11. Follow these instructions to install OpenJDK 11: ```bash sudo apt update sudo apt install openjdk-11-jdk +{:copy-code} ``` -{: .copy-code} Please don't forget to configure your operating system to use OpenJDK 11 by default. You can configure which version is the default using the following command: ```bash sudo update-alternatives --config java +{:copy-code} ``` -{: .copy-code} You can check the installation using the following command: ```bash java -version +{:copy-code} ``` -{: .copy-code} Expected command output is: @@ -34,7 +32,7 @@ OpenJDK Runtime Environment (...) OpenJDK 64-Bit Server VM (build ...) ``` -### Configure PostgreSQL +#### Configure PostgreSQL ThingsBoard Edge uses PostgreSQL database as a local storage. Instructions listed below will help you to install PostgreSQL. @@ -53,10 +51,10 @@ echo "deb http://apt.postgresql.org/pub/repos/apt/ ${RELEASE}"-pgdg main | sudo sudo apt update sudo apt -y install postgresql-12 sudo service postgresql start +{:copy-code} ``` -{: .copy-code} -Once PostgreSQL is installed you may want to create a new user or set the password for the the main user. +Once PostgreSQL is installed you may want to create a new user or set the password for the main user. The instructions below will help to set the password for main postgresql user ```text @@ -74,26 +72,23 @@ CREATE DATABASE tb_edge; \q ``` -### Thingsboard Edge service installation +#### Thingsboard Edge service installation Download installation package. ```bash wget https://github.com/thingsboard/thingsboard-edge/releases/download/v${TB_EDGE_VERSION}/tb-edge-${TB_EDGE_VERSION}.deb +{:copy-code} ``` -{: .copy-code} Go to the download repository and install ThingsBoard Edge service ```bash -sudo dpkg -i tb-edge-{TB_EDGE_VERSION}.deb +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: +#### Configure ThingsBoard Edge +To configure ThingsBoard Edge, 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 @@ -103,40 +98,33 @@ 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} ``` -{: .copy-code} -#### Manual Configuration +##### [Optional] Database Configuration +In case you changed default PostgreSQL datasource settings please update the configuration file with your actual values (**/etc/tb-edge/conf/tb-edge.conf**). +Edit ThingsBoard Edge configuration file: ```bash sudo nano /etc/tb-edge/conf/tb-edge.conf +{:copy-code} ``` -{: .copy-code} -Please update the following lines in your configuration file. Make sure to replace: +Please update the following lines in your configuration file. Make sure **to replace**: +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource username +- PUT_YOUR_POSTGRESQL_PASSWORD_HERE with your actual postgres datasource password. -```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} +```bash +export SPRING_DATASOURCE_URL=jdbc:postgresql://localhost:5432/tb_edge +export SPRING_DATASOURCE_USERNAME=PUT_YOUR_POSTGRESQL_USERNAME_HERE export SPRING_DATASOURCE_PASSWORD=PUT_YOUR_POSTGRESQL_PASSWORD_HERE - +{:copy-code} ``` -#### [Optional] Update bind ports +##### [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: +Please execute the following command to update ThingsBoard Edge configuration file (**/etc/tb-edge/conf/tb-edge.conf**): ```bash sudo sh -c 'cat <> /etc/tb-edge/conf/tb-edge.conf @@ -145,8 +133,8 @@ 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. @@ -156,12 +144,14 @@ Once ThingsBoard Edge is installed and configured please execute the following i ```bash sudo /usr/share/tb-edge/bin/install/install.sh +{:copy-code} ``` #### Restart ThingsBoard Edge service ```bash sudo service tb-edge restart +{:copy-code} ``` #### Open ThingsBoard Edge UI diff --git a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java index 455b3e657a..dd17f83317 100644 --- a/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java +++ b/application/src/main/java/org/thingsboard/server/service/edge/instructions/DefaultEdgeInstallService.java @@ -79,6 +79,9 @@ public class DefaultEdgeInstallService implements EdgeInstallService { dockerInstallInstructions = dockerInstallInstructions.replace("${LOCALHOST_WARNING}", ""); dockerInstallInstructions = dockerInstallInstructions.replace("${BASE_URL}", baseUrl); } + String edgeVersion = appVersion + "EDGE"; + edgeVersion = edgeVersion.replace("-SNAPSHOT", ""); + dockerInstallInstructions = dockerInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); dockerInstallInstructions = replacePlaceholders(dockerInstallInstructions, edge); return new EdgeInstallInstructions(dockerInstallInstructions); } @@ -87,6 +90,8 @@ public class DefaultEdgeInstallService implements EdgeInstallService { String ubuntuInstallInstructions = readFile(resolveFile("ubuntu", "instructions.md")); ubuntuInstallInstructions = replacePlaceholders(ubuntuInstallInstructions, edge); ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${BASE_URL}", request.getServerName()); + String edgeVersion = appVersion.replace("-SNAPSHOT", ""); + ubuntuInstallInstructions = ubuntuInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); return new EdgeInstallInstructions(ubuntuInstallInstructions); } @@ -95,13 +100,12 @@ public class DefaultEdgeInstallService implements EdgeInstallService { String centosInstallInstructions = readFile(resolveFile("centos", "instructions.md")); centosInstallInstructions = replacePlaceholders(centosInstallInstructions, edge); centosInstallInstructions = centosInstallInstructions.replace("${BASE_URL}", request.getServerName()); + String edgeVersion = appVersion.replace("-SNAPSHOT", ""); + centosInstallInstructions = centosInstallInstructions.replace("${TB_EDGE_VERSION}", edgeVersion); return new EdgeInstallInstructions(centosInstallInstructions); } private String replacePlaceholders(String instructions, Edge edge) { - String edgeVersion = appVersion + "EDGE"; - edgeVersion = edgeVersion.replace("-SNAPSHOT", ""); - instructions = instructions.replace("${TB_EDGE_VERSION}", edgeVersion); instructions = instructions.replace("${CLOUD_ROUTING_KEY}", edge.getRoutingKey()); instructions = instructions.replace("${CLOUD_ROUTING_SECRET}", edge.getSecret()); instructions = instructions.replace("${CLOUD_RPC_PORT}", Integer.toString(rpcPort)); diff --git a/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java b/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java index 081ce09ae7..1afeaff0cb 100644 --- a/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java +++ b/application/src/test/java/org/thingsboard/server/controller/EdgeControllerTest.java @@ -1107,7 +1107,7 @@ public class EdgeControllerTest extends AbstractControllerTest { public void testGetEdgeInstallInstructions() throws Exception { Edge edge = constructEdge(tenantId, "Edge for Test Docker Install Instructions", "default", "7390c3a6-69b0-9910-d155-b90aca4b772e", "l7q4zsjplzwhk16geqxy"); Edge savedEdge = doPost("/api/edge", edge, Edge.class); - String installInstructions = doGet("/api/edge/instructions/" + savedEdge.getId().getId().toString(), String.class); + String installInstructions = doGet("/api/edge/instructions/" + savedEdge.getId().getId().toString() + "/docker", String.class); Assert.assertTrue(installInstructions.contains("l7q4zsjplzwhk16geqxy")); Assert.assertTrue(installInstructions.contains("7390c3a6-69b0-9910-d155-b90aca4b772e")); } diff --git a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss index 1524150330..9b4339a66c 100644 --- a/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss +++ b/ui-ngx/src/app/modules/home/pages/edge/edge-instructions-dialog.component.scss @@ -69,6 +69,7 @@ :host ::ng-deep { .tb-markdown-view { + padding-top: 16px; .tb-command-code { .code-wrapper { padding: 0;