Merge branch 'master' of github.com:thingsboard/thingsboard

This commit is contained in:
Andrew Shvayka 2018-10-26 12:09:32 +03:00
commit f45ba17f87
23 changed files with 165 additions and 81 deletions

View File

@ -322,8 +322,8 @@ audit_log:
password: "${AUDIT_LOG_SINK_PASSWORD:}"
state:
defaultInactivityTimeoutInSec: 10
defaultStateCheckIntervalInSec: 10
defaultInactivityTimeoutInSec: "${DEFAULT_INACTIVITY_TIMEOUT:10}"
defaultStateCheckIntervalInSec: "${DEFAULT_STATE_CHECK_INTERVAL:10}"
kafka:
enabled: true

View File

@ -10,9 +10,9 @@ COAP_TRANSPORT_DOCKER_NAME=tb-coap-transport
TB_VERSION=latest
# Database used by ThingsBoard, can be either local (local HSQLDB), postgres (PostgreSQL), cassandra (Cassandra).
# In case of postgres or cassandra corresponding docker service will be deployed (see docker-compose.postgres.yml, docker-compose.cassandra.yml for details).
# Database used by ThingsBoard, can be either postgres (PostgreSQL) or cassandra (Cassandra).
# According to the database type corresponding docker service will be deployed (see docker-compose.postgres.yml, docker-compose.cassandra.yml for details).
DATABASE=cassandra
DATABASE=postgres
KAFKA_TOPICS="js.eval.requests:100:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb.transport.api.requests:30:1:delete --config=retention.ms=60000 --config=segment.bytes=26214400 --config=retention.bytes=104857600,tb.rule-engine:30:1"

View File

@ -2,24 +2,62 @@
This folder containing scripts and Docker Compose configurations to run ThingsBoard in Microservices mode.
## Prerequisites
ThingsBoard Microservices are running in dockerized environment.
Before starting please make sure [Docker CE](https://docs.docker.com/install/) and [Docker Compose](https://docs.docker.com/compose/install/) are installed in your system.
## Installation
Execute the following command to run DataBase installation:
Before performing initial installation you can configure the type of database to be used with ThinsBoard.
In order to set database type change the value of `DATABASE` variable in `.env` file to one of the following:
- `postgres` - use PostgreSQL database;
- `cassandra` - use Cassandra database;
**NOTE**: According to the database type corresponding docker service will be deployed (see `docker-compose.postgres.yml`, `docker-compose.cassandra.yml` for details).
Execute the following command to run installation:
`
$ ./docker-install-tb.sh --loadDemo
`
Where:
- `--loadDemo` - optional argument. Whether to load additional demo data.
## Running
Execute the following command to run services:
Execute the following command to start services:
`
$ ./docker-start-services.sh
`
After a while when all services will be successfully started you can open `http://{your-host-ip}` in you browser (for ex. `http://localhost`).
You should see ThingsBoard login page.
Use the following default credentials:
- **Systen Administrator**: sysadmin@thingsboard.org / sysadmin
If you installed DataBase with demo data (using `--loadDemo` flag) you can also use the following credentials:
- **Tenant Administrator**: tenant@thingsboard.org / tenant
- **Customer User**: customer@thingsboard.org / customer
In case of any issues you can examine service logs for errors.
For example to see ThingsBoard node logs execute the following command:
`
$ docker-compose logs -f tb1
`
Or use `docker-compose ps` to see the state of all the containers.
Use `docker-compose logs --f` to inspect the logs of all running services.
See [docker-compose logs](https://docs.docker.com/compose/reference/logs/) command reference for details.
Execute the following command to stop services:
`
@ -32,12 +70,16 @@ Execute the following command to stop and completely remove deployed docker cont
$ ./docker-remove-services.sh
`
Execute the following command to update particular services (pull newer docker image and rebuild container):
Execute the following command to update particular or all services (pull newer docker image and rebuild container):
`
$ ./docker-update-service.sh [SERVICE...]
`
Where:
- `[SERVICE...]` - list of services to update (defined in docker-compose configurations). If not specified all services will be updated.
## Upgrading
In case when database upgrade is needed, execute the following commands:
@ -48,4 +90,6 @@ $ ./docker-upgrade-tb.sh --fromVersion=[FROM_VERSION]
$ ./docker-start-services.sh
```
- `FROM_VERSION` - from which version upgrade should be started.
Where:
- `FROM_VERSION` - from which version upgrade should be started. See [Upgrade Instructions](https://thingsboard.io/docs/user-guide/install/upgrade-instructions) for valid `fromVersion` values.

View File

@ -15,7 +15,7 @@
# limitations under the License.
#
dirsArray=("./haproxy/certs.d" "./haproxy/letsencrypt" "./tb-node/db" "./tb-node/postgres" "./tb-node/cassandra" "./tb-node/log")
dirsArray=("./haproxy/certs.d" "./haproxy/letsencrypt" "./tb-node/postgres" "./tb-node/cassandra" "./tb-node/log/tb1" "./tb-node/log/tb2")
for dir in ${dirsArray[@]}
do

View File

@ -19,8 +19,6 @@ function additionalComposeArgs() {
source .env
ADDITIONAL_COMPOSE_ARGS=""
case $DATABASE in
local)
;;
postgres)
ADDITIONAL_COMPOSE_ARGS="-f docker-compose.postgres.yml"
;;
@ -28,7 +26,7 @@ function additionalComposeArgs() {
ADDITIONAL_COMPOSE_ARGS="-f docker-compose.cassandra.yml"
;;
*)
echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either local, postgres or cassandra." >&2
echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either postgres or cassandra." >&2
exit 1
esac
echo $ADDITIONAL_COMPOSE_ARGS
@ -38,8 +36,6 @@ function additionalStartupServices() {
source .env
ADDITIONAL_STARTUP_SERVICES=""
case $DATABASE in
local)
;;
postgres)
ADDITIONAL_STARTUP_SERVICES=postgres
;;
@ -47,7 +43,7 @@ function additionalStartupServices() {
ADDITIONAL_STARTUP_SERVICES=cassandra
;;
*)
echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either local, postgres or cassandra." >&2
echo "Unknown DATABASE value specified: '${DATABASE}'. Should be either postgres or cassandra." >&2
exit 1
esac
echo $ADDITIONAL_STARTUP_SERVICES

View File

@ -24,11 +24,17 @@ services:
- "9042"
volumes:
- ./tb-node/cassandra:/var/lib/cassandra
tb:
environment:
DATABASE_TS_TYPE: cassandra
DATABASE_ENTITIES_TYPE: cassandra
CASSANDRA_URL: cassandra:9042
tb1:
env_file:
- tb-node.cassandra.env
depends_on:
- kafka
- redis
- cassandra
tb2:
env_file:
- tb-node.cassandra.env
depends_on:
- kafka
- redis
- cassandra

View File

@ -26,15 +26,17 @@ services:
POSTGRES_DB: thingsboard
volumes:
- ./tb-node/postgres:/var/lib/postgresql/data
tb:
environment:
DATABASE_TS_TYPE: sql
DATABASE_ENTITIES_TYPE: sql
SPRING_JPA_DATABASE_PLATFORM: org.hibernate.dialect.PostgreSQLDialect
SPRING_DRIVER_CLASS_NAME: org.postgresql.Driver
SPRING_DATASOURCE_URL: jdbc:postgresql://postgres:5432/thingsboard
SPRING_DATASOURCE_USERNAME: postgres
SPRING_DATASOURCE_PASSWORD: postgres
tb1:
env_file:
- tb-node.postgres.env
depends_on:
- kafka
- redis
- postgres
tb2:
env_file:
- tb-node.postgres.env
depends_on:
- kafka
- redis
- postgres

View File

@ -20,7 +20,7 @@ version: '2.2'
services:
zookeeper:
restart: always
image: "wurstmeister/zookeeper"
image: "zookeeper:3.5"
ports:
- "2181"
kafka:
@ -28,31 +28,23 @@ services:
image: "wurstmeister/kafka"
ports:
- "9092:9092"
environment:
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
KAFKA_LISTENERS: INSIDE://:9093,OUTSIDE://:9092
KAFKA_ADVERTISED_LISTENERS: INSIDE://:9093,OUTSIDE://kafka:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME: INSIDE
KAFKA_CREATE_TOPICS: "${KAFKA_TOPICS}"
KAFKA_AUTO_CREATE_TOPICS_ENABLE: 'false'
KAFKA_LOG_RETENTION_BYTES: 1073741824
KAFKA_LOG_SEGMENT_BYTES: 268435456
KAFKA_LOG_RETENTION_MS: 300000
KAFKA_LOG_CLEANUP_POLICY: delete
env_file:
- kafka.env
depends_on:
- zookeeper
redis:
image: redis:4.0
ports:
- "6379"
tb-js-executor:
restart: always
image: "${DOCKER_REPO}/${JS_EXECUTOR_DOCKER_NAME}:${TB_VERSION}"
scale: 20
environment:
TB_KAFKA_SERVERS: kafka:9092
env_file:
- tb-js-executor.env
depends_on:
- kafka
tb:
tb1:
restart: always
image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
ports:
@ -62,28 +54,41 @@ services:
options:
max-size: "200m"
max-file: "30"
environment:
TB_HOST: tb1
env_file:
- tb-node.env
environment:
ZOOKEEPER_URL: zk:2181
TB_KAFKA_SERVERS: kafka:9092
JS_EVALUATOR: remote
DATABASE_TS_TYPE: sql
DATABASE_ENTITIES_TYPE: sql
SQL_DATA_FOLDER: /usr/share/thingsboard/data/db
volumes:
- ./tb-node/db:/usr/share/thingsboard/data/db
- ./tb-node/conf:/config
- ./tb-node/log:/var/log/thingsboard
depends_on:
- kafka
- redis
tb2:
restart: always
image: "${DOCKER_REPO}/${TB_NODE_DOCKER_NAME}:${TB_VERSION}"
ports:
- "8080"
logging:
driver: "json-file"
options:
max-size: "200m"
max-file: "30"
environment:
TB_HOST: tb2
env_file:
- tb-node.env
volumes:
- ./tb-node/conf:/config
- ./tb-node/log:/var/log/thingsboard
depends_on:
- kafka
- redis
tb-mqtt-transport1:
restart: always
image: "${DOCKER_REPO}/${MQTT_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
ports:
- "1883"
environment:
TB_KAFKA_SERVERS: kafka:9092
env_file:
- tb-mqtt-transport.env
depends_on:
@ -93,8 +98,6 @@ services:
image: "${DOCKER_REPO}/${MQTT_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
ports:
- "1883"
environment:
TB_KAFKA_SERVERS: kafka:9092
env_file:
- tb-mqtt-transport.env
depends_on:
@ -104,8 +107,6 @@ services:
image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
ports:
- "8081"
environment:
TB_KAFKA_SERVERS: kafka:9092
env_file:
- tb-http-transport.env
depends_on:
@ -115,8 +116,6 @@ services:
image: "${DOCKER_REPO}/${HTTP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
ports:
- "8081"
environment:
TB_KAFKA_SERVERS: kafka:9092
env_file:
- tb-http-transport.env
depends_on:
@ -126,8 +125,6 @@ services:
image: "${DOCKER_REPO}/${COAP_TRANSPORT_DOCKER_NAME}:${TB_VERSION}"
ports:
- "5683:5683/udp"
environment:
TB_KAFKA_SERVERS: kafka:9092
env_file:
- tb-coap-transport.env
depends_on:
@ -138,7 +135,7 @@ services:
ports:
- "8080"
environment:
TB_HOST: tb
TB_HOST: tb1
TB_PORT: 8080
env_file:
- tb-web-ui.env
@ -148,7 +145,7 @@ services:
ports:
- "8080"
environment:
TB_HOST: tb
TB_HOST: tb2
TB_PORT: 8080
env_file:
- tb-web-ui.env
@ -171,6 +168,7 @@ services:
HTTP_PORT: 80
HTTPS_PORT: 443
MQTT_PORT: 1883
FORCE_HTTPS_REDIRECT: "false"
links:
- tb-web-ui1
- tb-web-ui2

View File

@ -48,9 +48,9 @@ ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
ADDITIONAL_STARTUP_SERVICES=$(additionalStartupServices) || exit $?
if [ ! -z "${ADDITIONAL_STARTUP_SERVICES// }" ]; then
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d $ADDITIONAL_STARTUP_SERVICES
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
fi
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e INSTALL_TB=true -e LOAD_DEMO=${loadDemo} tb1

View File

@ -46,8 +46,10 @@ ADDITIONAL_COMPOSE_ARGS=$(additionalComposeArgs) || exit $?
ADDITIONAL_STARTUP_SERVICES=$(additionalStartupServices) || exit $?
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS pull tb1
if [ ! -z "${ADDITIONAL_STARTUP_SERVICES// }" ]; then
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d $ADDITIONAL_STARTUP_SERVICES
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS up -d redis $ADDITIONAL_STARTUP_SERVICES
fi
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb
docker-compose -f docker-compose.yml $ADDITIONAL_COMPOSE_ARGS run --no-deps --rm -e UPGRADE_TB=true -e FROM_VERSION=${fromVersion} tb1

View File

@ -51,7 +51,7 @@ frontend http-in
acl transport_http_acl path_beg /api/v1/
acl letsencrypt_http_acl path_beg /.well-known/acme-challenge/
redirect scheme https if !letsencrypt_http_acl !transport_http_acl
redirect scheme https if !letsencrypt_http_acl !transport_http_acl { env(FORCE_HTTPS_REDIRECT) -m str true }
use_backend letsencrypt_http if letsencrypt_http_acl
use_backend tb-http-backend if transport_http_acl

12
docker/kafka.env Normal file
View File

@ -0,0 +1,12 @@
KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
KAFKA_LISTENERS=INSIDE://:9093,OUTSIDE://:9092
KAFKA_ADVERTISED_LISTENERS=INSIDE://:9093,OUTSIDE://kafka:9092
KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INSIDE:PLAINTEXT,OUTSIDE:PLAINTEXT
KAFKA_INTER_BROKER_LISTENER_NAME=INSIDE
KAFKA_CREATE_TOPICS=${KAFKA_TOPICS}
KAFKA_AUTO_CREATE_TOPICS_ENABLE=false
KAFKA_LOG_RETENTION_BYTES=1073741824
KAFKA_LOG_SEGMENT_BYTES=268435456
KAFKA_LOG_RETENTION_MS=300000
KAFKA_LOG_CLEANUP_POLICY=delete

View File

@ -3,4 +3,4 @@ COAP_BIND_ADDRESS=0.0.0.0
COAP_BIND_PORT=5683
COAP_TIMEOUT=10000
TB_KAFKA_SERVERS=localhost:9092
TB_KAFKA_SERVERS=kafka:9092

View File

@ -3,4 +3,4 @@ HTTP_BIND_ADDRESS=0.0.0.0
HTTP_BIND_PORT=8081
HTTP_REQUEST_TIMEOUT=60000
TB_KAFKA_SERVERS=localhost:9092
TB_KAFKA_SERVERS=kafka:9092

View File

@ -1,6 +1,6 @@
REMOTE_JS_EVAL_REQUEST_TOPIC=js.eval.requests
TB_KAFKA_SERVERS=localhost:9092
TB_KAFKA_SERVERS=kafka:9092
LOGGER_LEVEL=info
LOG_FOLDER=logs
LOGGER_FILENAME=tb-js-executor-%DATE%.log

View File

@ -3,4 +3,4 @@ MQTT_BIND_ADDRESS=0.0.0.0
MQTT_BIND_PORT=1883
MQTT_TIMEOUT=10000
TB_KAFKA_SERVERS=localhost:9092
TB_KAFKA_SERVERS=kafka:9092

View File

@ -0,0 +1,5 @@
# ThingsBoard server configuration for Cassandra database
DATABASE_TS_TYPE=cassandra
DATABASE_ENTITIES_TYPE=cassandra
CASSANDRA_URL=cassandra:9042

View File

@ -1,3 +1,10 @@
# ThingsBoard server configuration
ZOOKEEPER_ENABLED=true
ZOOKEEPER_URL=zookeeper:2181
RPC_HOST=${TB_HOST}
TB_KAFKA_SERVERS=kafka:9092
JS_EVALUATOR=remote
TRANSPORT_TYPE=remote
CACHE_TYPE=redis
REDIS_HOST=redis

View File

@ -0,0 +1,9 @@
# ThingsBoard server configuration for PostgreSQL database
DATABASE_TS_TYPE=sql
DATABASE_ENTITIES_TYPE=sql
SPRING_JPA_DATABASE_PLATFORM=org.hibernate.dialect.PostgreSQLDialect
SPRING_DRIVER_CLASS_NAME=org.postgresql.Driver
SPRING_DATASOURCE_URL=jdbc:postgresql://postgres:5432/thingsboard
SPRING_DATASOURCE_USERNAME=postgres
SPRING_DATASOURCE_PASSWORD=postgres

View File

@ -21,7 +21,7 @@
<appender name="fileLogAppender"
class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>/var/log/thingsboard/thingsboard.log</file>
<file>/var/log/thingsboard/${TB_HOST}/thingsboard.log</file>
<rollingPolicy
class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
<fileNamePattern>/var/log/thingsboard/thingsboard.%d{yyyy-MM-dd}.%i.log</fileNamePattern>

View File

@ -15,7 +15,7 @@
#
export JAVA_OPTS="$JAVA_OPTS -Dplatform=deb -Dinstall.data_dir=/usr/share/thingsboard/data"
export JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/thingsboard/gc.log -XX:+IgnoreUnrecognizedVMOptions -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
export JAVA_OPTS="$JAVA_OPTS -Xloggc:/var/log/thingsboard/${TB_HOST}/gc.log -XX:+IgnoreUnrecognizedVMOptions -XX:+HeapDumpOnOutOfMemoryError -XX:+PrintGCDetails -XX:+PrintGCDateStamps"
export JAVA_OPTS="$JAVA_OPTS -XX:+PrintHeapAtGC -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10"
export JAVA_OPTS="$JAVA_OPTS -XX:GCLogFileSize=10M -XX:-UseBiasedLocking -XX:+UseTLAB -XX:+ResizeTLAB -XX:+PerfDisableSharedMem -XX:+UseCondCardMark"
export JAVA_OPTS="$JAVA_OPTS -XX:CMSWaitDuration=10000 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+CMSParallelInitialMarkEnabled"

Binary file not shown.

Before

Width:  |  Height:  |  Size: 257 KiB

View File

@ -8,6 +8,7 @@ This project provides the build for the ThingsBoard single docker images.
## Running
In this example `thingsboard/tb` image will be used. You can choose any other images with different databases (see above).
Execute the following command to run this docker directly:
`
@ -23,9 +24,9 @@ Where:
- `-p 5683:5683` - connect local port 5683 to exposed internal COAP port 5683
- `-v ~/.mytb-data:/data` - mounts the host's dir `~/.mytb-data` to ThingsBoard DataBase data directory
- `--name mytb` - friendly local name of this machine
- `thingsboard/tb` - docker image
- `thingsboard/tb` - docker image, can be also `thingsboard/tb-postgres` or `thingsboard/tb-cassandra`
After executing this command you can open `http://{yor-host-ip}:9090` in you browser. You should see ThingsBoard login page.
After executing this command you can open `http://{your-host-ip}:9090` in you browser (for ex. `http://localhost:9090`). You should see ThingsBoard login page.
Use the following default credentials:
- **Systen Administrator**: sysadmin@thingsboard.org / sysadmin
@ -65,4 +66,6 @@ $ docker run -it -v ~/.mytb-data:/data --rm thingsboard/tb upgrade-tb.sh
$ docker start mytb
```
**NOTE**: if you use different database change image name in all commands from `thingsboard/tb` to `thingsboard/tb-postgres` or `thingsboard/tb-cassandra` correspondingly.
**NOTE**: replace host's directory `~/.mytb-data` with directory used during container creation.