1. Install tb-postgres
tb-postgres is a single instance of ThingsBoard and PostgreSQL database.
Pull the tb-postgres image
docker pull thingsboard/tb-postgres
Create the tb-postgres container
docker run -itd --name tb-postgres -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -p 5685:5685/udp -p 5432:5432 -v ~/mytb-data:/data -v ~/mytb-logs:/var/log/thingsboard --restart always thingsboard/tb-postgres
Configure postgres remote connection
Enter the /data/ directory of the tb-postgres container
Modify pg_hba.conf
host all all 0.0.0.0/0 trust
Modify postgresql.conf
listen_addresses = '*'
Use navicat to connect to the postgresql database, the database name and account password are thingsboard by default
Enter http://IP:9090 in the browser to open the tb console
Default system administrator account username: [email protected] password: sysadmin
Default tenant administrator account: Username: [email protected] Password: tenant
Log in to the tb console and create a gateway device
Copy the access token of the gateway device, which will be used by tb-gateway below.
2. Install tb-gateway
Pull the tb-gateway image
docker pull thingsboard/tb-gateway
Create tb-gateway container
docker run -itd --name tb-gateway -v ~/tb-gateway/logs:/var/log/thingsboard-gateway -v ~/tb-gateway/extensions:/var/lib/thingsboard_gateway/extensions -v ~/tb-gateway/config:/etc/thingsboard-gateway/config --restart always thingsboard/tb-gateway
Enter the /thingsboard-gateway/config directory
Modify tb_gateway.yaml
thingsboard:
host: 192.168.1.100
port: 1883
remoteShell: false
remoteConfiguration: false
statistics:
enable: true
statsSendPeriodInSeconds: 3600
configuration: statistics.json
maxPayloadSizeBytes: 1024
minPackSendDelayMS: 0
checkConnectorsConfigurationInSeconds: 60
handleDeviceRenaming: true
checkingDeviceActivity:
checkDeviceInactivity: false
inactivityTimeoutSeconds: 120
inactivityCheckPeriodSeconds: 10
security:
accessToken: yKyniKO5CAtX8fsWn2p6
qos: 1
Modify the host in the configuration file to the IP of tb-postgres, and modify the accessToken to the access token copied above.
Modify mqtt.json
Modified
to mqtt-server information