mineshaftgap / d4m-nfs

Docker for Mac with NFS for performance improvements over osxfs
296 stars 26 forks source link

Data from MYSQL is removed from /tmp #48

Closed leolandotan closed 7 years ago

leolandotan commented 7 years ago

I've been successfully using this with multiple projects. So I would have volumes on /tmp/docker/project1/mysql, /tmp/docker/project2/mysql and etc.

I noticed that after I would restart my machine, the /tmp/docker folder is gone and I would need to import large databases again.

Am I doing something wrong on why it's not persistent or is this really how this works?

Thanks!

if-kyle commented 7 years ago

If I follow correctly, the files on your mac (not in the container) are at /tmp. The /tmp directory is deleted anytime a reboot happens on the host (mac) system. This is the same as a linux box. This is not related to d4m-nfs. I would suggest moving the directory location else where on the mac.

leolandotan commented 7 years ago

Thanks for your feedback @if-kyle !

So my Docker shared folder would be something different from "/tmp" like "/mynewtmp". Then my docker-compose.yml mysql service would look like:

  db:
    build: docker/mysql
    volumes:
      - /mynewtmp/docker/project1/mysql:/var/lib/mysql
    environment:

Is this correct?

Is a volume declaration of ./data/mysql:/var/lib/mysql for my mysql service not possible? Like just placing it inside my project and the same for my other projects?

Thanks!

if-kenn commented 7 years ago

@leolandotan we don't use relative paths here, but it sounds like it works fine for others, see: #5

leolandotan commented 7 years ago

Hi @if-kenn !

Thanks for the link. My apologies for being noob here.

Here are my configurations so far that worked: d4m-nfs/etc/d4m-nfs-mounts.txt

/Users:/Users:0:0

Docker > Preferences > File Sharing

/tmp

/etc/exports

# d4m-nfs exports

"/Users" -alldirs -mapall=0:0 localhost

/tmp/d4m-mount-nfs.sh

ln -nsf /tmp/d4m-apk-cache /etc/apk/cache
apk update
apk add nfs-utils sntpc
rpcbind -s > /dev/null 2>&1

DEFGW=$(ip route|awk '/default/{print $3}')
FSTAB="\n\n# d4m-nfs mounts\n"

if true && ! $(grep ':/mnt' /tmp/d4m-nfs-mounts.txt > /dev/null 2>&1); then
  mkdir -p /mnt

  FSTAB="${FSTAB}${DEFGW}:/Users/leotan /mnt nfs nolock,local_lock=all 0 0"
fi

if [ -e /tmp/d4m-nfs-mounts.txt ]; then
  while read MOUNT; do
    DSTDIR=$(echo "$MOUNT" | cut -d: -f2)
    mkdir -p ${DSTDIR}
    FSTAB="${FSTAB}\n${DEFGW}:$(echo "$MOUNT" | cut -d: -f1) ${DSTDIR} nfs nolock,local_lock=all 0 0"
  done < /tmp/d4m-nfs-mounts.txt
fi

if ! $(grep "d4m-nfs mounts" /etc/fstab > /dev/null 2>&1); then
    echo adding d4m nfs config to /etc/fstab:
    echo -e $FSTAB | tee /etc/fstab
else
    echo d4m nfs mounts already exist in /etc/fstab
fi

sntpc -i 10 ${DEFGW} &

sleep .5
mount -a
touch /tmp/d4m-done

/tmp/d4m-nfs-mounts.txt

/Users:/Users:0:0

docker-compose.yml

...
  mysql:
    image: mysql:5.7
    volumes:
      - ./data/mysql:/var/lib/mysql
...

I'm using:

Fresh Drupal site installation loads pretty well.

Is there a way to know that the site is really using d4m-nfs like d4m-nfs may be running but the my Docker project isn't using it or as long as d4m-nfs started with no error my project is working with d4m-nfs already?

Thanks!

if-kyle commented 7 years ago

From the docker-compose.yml, as long as the ./data/mysql is not in the /tmp directory of your mac, then you are in fact using d4m and not the default (slow) osxfs file system.

You could speed test this by modifying Docker > Preferences > File Sharing and removing /tmp and replacing it with the location of ./data/mysql (absolute path), and then do NOT run d4m script before starting your containers.