-
Notifications
You must be signed in to change notification settings - Fork 161
which directories should i persist in emqx #89
Comments
|
i added these volumes in my docker-compose file and created an application called "johndoe" in emqx dashboard, but unfortunately this just does not work.
but when i visited dashboard, application was not there and it seemed it was deleted. i ran this command in my host machine and i am pretty sure this file exists in both host and container.
|
service for emqx for persisting data across container recreation services:
emqx:
stdin_open: true
tty: true
restart: always
image: emqx/emqx:v3.0-rc.5
container_name: emqx
entrypoint: []
networks:
- confluent
ports:
- "18083:18083"
- "1883:1883"
- "8080:8080"
volumes:
- ./emqx/log:/opt/emqx/log #working
- ./emqx/data/mnesia:/opt/emqx/data/mnesia #working
- ./emqx/lib:/opt/emqx/lib #not working
- ./emqx/etc:/opt/emqx/etc/plugins/ #not working Using the above configuration i was not able to start the docker container Logs:
I have created the Using only the I want to persist my app configuration in case of container restarts (i.e. when container is recreated) What is the right way to achieve this? Thanks! |
@deepaksood619, I faced the same issue as you regarding persistence (https://github.com/emqx/emqx-docker/pull/91#issuecomment-445826906) ... unfortunately no final solution yet. I haven't tried, but a workaround could be:
|
@RaymondMouthaan, i tried this approach but was not able to copy the files as both
Same i tried as |
@deepaksood619 can you do:
|
/ # ls -al
total 60
drwxr-xr-x 1 root root 4096 Dec 11 15:40 .
drwxr-xr-x 1 root root 4096 Dec 11 15:40 ..
-rwxr-xr-x 1 root root 0 Dec 11 15:40 .dockerenv
drwxr-xr-x 1 root root 4096 Dec 1 10:16 bin
drwxr-xr-x 5 root root 360 Dec 11 15:40 dev
drwxr-xr-x 1 root root 4096 Dec 11 15:40 etc
drwxr-xr-x 1 root root 4096 Dec 1 10:17 home
drwxr-xr-x 1 root root 4096 Dec 1 10:16 lib
drwxr-xr-x 5 root root 4096 Sep 11 20:23 media
drwxr-xr-x 2 root root 4096 Sep 11 20:23 mnt
drwxr-xr-x 1 root root 4096 Dec 1 10:17 opt
dr-xr-xr-x 205 root root 0 Dec 11 15:40 proc
drwx------ 1 root root 4096 Dec 11 15:40 root
drwxr-xr-x 2 root root 4096 Sep 11 20:23 run
drwxr-xr-x 2 root root 4096 Sep 11 20:23 sbin
drwxr-xr-x 2 root root 4096 Sep 11 20:23 srv
dr-xr-xr-x 13 root root 0 Dec 11 15:40 sys
drwxr-xr-x 2 root root 64 Dec 11 14:57 tmp
drwxr-xr-x 1 root root 4096 Dec 1 10:16 usr
drwxr-xr-x 1 root root 4096 Dec 1 10:16 var
/ # whoami
root
/ # |
hmm, weird .. |
already done but with no success
|
Also tried
But can't seem to find the problem |
@RaymondMouthaan, here is the DockerFile emqtt is using for building it's images. Please have a look. |
Like you, i am confused as well .. can you try without persist ? (assuming you have used -v in your docker command)? |
Yes i am able to create the directory now inside But we used |
Great, then there could be at least two reasons I can think of why it doesn't work with /tmp
What you could test is .. mount volume as before but add a file to the host dir and check if this file is visible inside the container. Another test/solution would be, mount /opt/emqx/log to your host file dir, then copy all other dirs to that. So basically instead of /tmp use /opt/emqx/log instead. Maybe remove created logs before copying... |
For the first part, mounting files using For second I got permission denied for the volume mounts. master ● docker run -it -v /hostdir:/opt/emqx/log --name=temp-emqx emqx/emqx:v3.0-rc.5
node.max_ports=1048576
listener.tcp.external.acceptors=64
listener.ssl.external.acceptors=32
node.process_limit=2097152
node.max_ets_tables=2097152
listener.ws.external.acceptors=16
[email protected]
run_erl[517]: errno=13 'Permission denied'
Can't open log file '/opt/emqx/log/erlang.log.1'.
tail: can't open '/opt/emqx/log/erlang.log.1': No such file or directory
tail: no files
Node '[email protected]' not responding to pings.
['2018-12-11T17:01:40Z']:waiting emqx
Node '[email protected]' not responding to pings.
['2018-12-11T17:01:42Z']:waiting emqx
Node '[email protected]' not responding to pings.
['2018-12-11T17:01:43Z']:waiting emqx
Node '[email protected]' not responding to pings.
['2018-12-11T17:01:45Z']:waiting emqx
Node '[email protected]' not responding to pings.
['2018-12-11T17:01:47Z']:waiting emqx
Node '[email protected]' not responding to pings.
['2018-12-11T17:01:48Z']:waiting emqx
['2018-12-11T17:01:48Z']:timeout error But i was able to do this using services:
emqx:
stdin_open: true
tty: true
restart: always
image: emqx/emqx:v3.0-rc.5
container_name: emqx
entrypoint: []
environment:
EMQX_ALLOW_ANONYMOUS: "false"
EMQX_LOADED_PLUGINS: "emqx_recon,emqx_retainer,emqx_management,emqx_dashboard"
networks:
- confluent
ports:
- "18083:18083"
- "1883:1883"
- "8080:8080"
volumes:
- ./emqx/log:/opt/emqx/log #able to mount but
# - ./emqx/data:/opt/emqx/data #not working
# - ./emqx/lib:/opt/emqx/lib #not working
# - ./emqx/etc:/opt/emqx/etc #not working Now doing the above i was able to create file both sides i.e. on host machine and inside docker container and both reflected back to other side. |
Try ./hostdir instead /hostdir and make sure the dir exists. |
Yes! it worked, data is copied to hostdir and emqtt is starting. But the initial problem persists, that an app created from management console in This is what i did-
All the previous session data is there in the
How can i make emqtt use old data folders instead of creating new ones. |
Okee, this confuses me a lot, basically when the dirs / files exists on the host, then emqx creates new ones.. If they don't exist, emqx won't even start 🤔 |
Yes that sums it all... 😐
…On Wed 12 Dec, 2018, 12:27 AM Raymond Mouthaan ***@***.*** wrote:
Okee, this confuses me a lot, basically when the dirs / files exists on
the host, then emqx creates new ones.. If they don't exist, emqx won't even
start 🤔
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<https://github.com/emqx/emqx-docker/issues/89#issuecomment-446319252>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AMmEVEv6tK19L7mFyEjGMdlTRRRBEYw5ks5u4AAegaJpZM4YxbLJ>
.
|
Any update on this issue? |
As far as I can tell emqx is creating folders to contain config files based on the id of the node. This is probably in cases where there are multiple nodes running on a single physical machine without the use of containers in order to avoid conflicts when reading and writing to these files; When a new container is created, the hostname and possibly IP address also change, changing the name of the emqx node and therefore the folders that the node writes to. The solution that worked for me was to manually set the emqx node name via an environment variable to ensure that the node name and therefore configuration folder being used was consistent across container destruction and recreation. The environment variable for controlling this is EMQX_NODE__NAME and should contain data in the format of EMQX_NAME@EMQX_HOST, in my case this was "[email protected]" and user login, and applications are now persistent. |
@WhyKickAmooCow thanks for your reply! Could you supply an example of you full docker command / docker compose file, how you manage to get persistence to work? |
Here is a sample of my docker-compose file. For me it really was as simple as keeping the suggested folders above in volumes, and setting an environment variable. mqtt:
image: emqx-docker-v3.0.0
environment:
- [email protected]
ports:
- 1883:1883
- 8083:8083
- 8084:8084
- 8080:8080
- 18083:18083
volumes:
- ./emqx-config:/opt/emqx/etc
- ./emqx-data:/opt/emqx/data
- ./emqx-lib:/opt/emqx/lib
networks:
ash:
aliases:
- mqtt.local |
Probably my mistake but I still can't get it to work with:
These are the errors I am getting:
All host dirs are created and are empty before creating the service. |
On first setup I let the container run without the lib and etc volumes mounted so not to overwrite the existing folders in the container with empty ones. Then I used |
Thanks, that got me a little further... Still got some issues, but I'll try again later. Either way it's not very user friendly to persist emqx. Hopefully emqx team will improve this, also when running in clustered setup. A full example with a master and a worker including persistence for both would very helpful 👍🏽 |
This here is really an issue when deploying emqx. It does cost time to figure it all out. I finally got really far but now it keeps telling me this remaining bit and then exists abnormally:
|
The logic should be:
|
I have resolved persist with First, use yml file without volume. You must set
After startup the container successfully, you should copy the folder in container to your persist location: docker cp emqx:/opt/emqx/etc ~/emqx/etc
docker cp emqx:/opt/emqx/lib ~/emqx/lib
docker cp emqx:/opt/emqx/data ~/emqx/data
docker cp emqx:/opt/emqx/log ~/emqx/log Then change the owner, group of these folders: cd ~/emqx
chown -R 1000:1000 data etc lib log
chmod -R 775 data etc lib log Modify the
Remove the container and recreate one. That is OK. |
which directories should i persist in emqx ?
Description
I need to persist each application credential i create in emqx in case of backup or something goes wrong.if s.th goes worng with my docker container, my software could still be available and therefore i don't have to create another app id and app secret.
i already tried to persist like below :
but unfortunately it does not work as it expected. when i docker down and docker up again my app credentials will be lost but i believe the logs and data are there.
overall which directories should i persist ? especially if i need to activate emqx_retainer and save messages to disk
The text was updated successfully, but these errors were encountered: