在ThingsBoard教程之后,他们似乎建议使用本地桌面安装来安装RabbitMQ,只需使用引用它的一些变量来运行对接器。
我个人不喜欢直接在我的电脑上安装这样的应用程序,我更喜欢它们的对接实例。
我希望尝试通过码头同步我的码头ThingsBoard和RabbitMQ。
这是我目前正在使用的docker-compose.yml文件:
version: '2.2'
services:
mytb:
privileged: true
restart: always
depends_on:
- rabbitmq
image: "thingsboard/tb-postgres"
ports:
- "9091:9090"
- "1883:1883"
- "7070:7070"
- "5683-5688:5683-5688/udp"
environment:
TB_QUEUE_TYPE: rabbitmq
TB_QUEUE_RABBIT_MQ_USERNAME: test
TB_QUEUE_RABBIT_MQ_PASSWORD: test123369
TB_QUEUE_RABBIT_MQ_HOST: localhost
TB_QUEUE_RABBIT_MQ_PORT: 5672
volumes:
- ./mytb-data:/data
- ./mytb-logs:/var/log/thingsboard
rabbitmq:
image: rabbitmq:3-management
environment:
# RABBITMQ_ERLANG_COOKIE: 'asdfjasifasjfawfjisfjasifjioasjfoiasj'
RABBITMQ_DEFAULT_USER: test
RABBITMQ_DEFAULT_PASS: test123369
volumes:
- ./rmq-test/db-data:/var/lib/rabbitmq
ports:
- 5672:5672
- 15672:15672
我一直让ThigsBoard服务器以错误重新启动,说它无法连接到RabbitMQ。
我尝试将行:TB_QUEUE_RABBIT_MQ_HOST: localhost
更改为TB_QUEUE_RABBIT_MQ_HOST: rabbitmq
,或者使用分配给码头容器的ip地址,然后在循环中得到这个错误:
Creating mytb_mytb_1 ... done
Attaching to mytb_mytb_1
mytb_1 | mkdir: cannot create directory ‘/data/db’: Permission denied
mytb_1 | The files belonging to this database system will be owned by user "thingsboard".
mytb_1 | This user must also own the server process.
mytb_1 |
mytb_1 | The database cluster will be initialized with locale "C.UTF-8".
mytb_1 | The default database encoding has accordingly been set to "UTF8".
mytb_1 | The default text search configuration will be set to "english".
mytb_1 |
mytb_1 | Data page checksums are disabled.
mytb_1 |
mytb_1 | creating directory /data/db ... initdb: error: could not create directory "/data/db": Permission denied
mytb_1 | pg_ctl: database system initialization failed
mytb_1 | psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
mytb_1 | Is the server running locally and accepting connections on that socket?
mytb_1 | psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
mytb_1 | Is the server running locally and accepting connections on that socket?
mytb_1 | psql: error: connection to server on socket "/var/run/postgresql/.s.PGSQL.5432" failed: No such file or directory
mytb_1 | Is the server running locally and accepting connections on that socket?
发布于 2022-06-15 11:23:28
不客气:)
默认情况下,docker连接内部网络中的服务。要重新定义其他服务,您需要使用服务名称(或别名.),localhost将无法工作。
发布的第二个问题与rabbitmq连接没有什么关系,您的mytb_1容器无法访问您的数据卷映射。服务需要有足够的权限来写入映射的目录。
version: '2.2'
services:
mytb:
privileged: true
restart: always
depends_on:
- rabbitmq
image: "thingsboard/tb-postgres"
ports:
- "9091:9090"
- "1883:1883"
- "7070:7070"
- "5683-5688:5683-5688/udp"
environment:
TB_QUEUE_TYPE: rabbitmq
TB_QUEUE_RABBIT_MQ_USERNAME: test
TB_QUEUE_RABBIT_MQ_PASSWORD: test123369
# Use the rabbitmq service name as a host instead of localhost
TB_QUEUE_RABBIT_MQ_HOST: rabbitmq
TB_QUEUE_RABBIT_MQ_PORT: 5672
volumes:
- ./.mytb-data:/data
- ./.mytb-logs:/var/log/thingsboard
# make sure that the service has sufficient rights to
# write to the mapped directories
rabbitmq:
... (rest of file left out)
https://stackoverflow.com/questions/72629386
复制相似问题