1. 程式人生 > >docker RabbitMQ 搭建叢集模式,磁碟空間不足,容器遷移目錄

docker RabbitMQ 搭建叢集模式,磁碟空間不足,容器遷移目錄

docker 映象預設存放的目錄是/var/lib/docker
通過檢視容器的log 發現:容器的磁碟滿了,無法啟動

docker logs --tail=100 containID
=INFO REPORT==== 19-Nov-2018::03:55:30 ===
Error description:
   {could_not_start,rabbit,
       {error,
           {{shutdown,
                {failed_to_start_child,rabbit_memory_monitor,
                    {
badarg, [{lists,member,[disk,{error,bad_module}],[]}, {rabbit_memory_monitor,init,1, [{file,"src/rabbit_memory_monitor.erl"}, {line,111}]}, {gen_server2,init_it,6, [
{file,"src/gen_server2.erl"},{line,552}]}, {proc_lib,init_p_do_apply,3, [{file,"proc_lib.erl"},{line,247}]}]}}}, {child,undefined,rabbit_memory_monitor_sup, {rabbit_restartable_sup,start_link, [rabbit_memory_monitor_sup, {
rabbit_memory_monitor,start_link,[]}, false]}, transient,infinity,supervisor, [rabbit_restartable_sup]}}}} Log files (may contain more information): tty tty {"init terminating in do_boot",{could_not_start,rabbit,{error,{{shutdown,{failed_to_start_child,rabbit_memory_monitor,{badarg,[{lists,member,[disk,{error,bad_module}],[]},{rabbit_memory_monitor,init,1,[{file,"src/rabbit_memory_monitor.erl"},{line,111}]},{gen_server2,init_it,6,[{file,"src/gen_server2.erl"},{line,552}]},{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]}}},{child,undefined,rabbit_memory_monitor_sup,{rabbit_restartable_sup,start_link,[rabbit_memory_monitor_sup,{rabbit_memory_monitor,start_link,[]},false]},transient,infinity,supervisor,[rabbit_restartable_sup]}}}}} init terminating in do_boot ()

檢視目錄使用狀況:

df -h

結果:

[[email protected] docker]$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda1        50G   48G   16M 100% /
devtmpfs        7.6G     0  7.6G   0% /dev
tmpfs           7.6G  4.0K  7.6G   1% /dev/shm
tmpfs           7.6G  761M  6.9G  10% /run
tmpfs           7.6G     0  7.6G   0% /sys/fs/cgroup
/dev/sdb1       394G  344M  374G   1% /data
tmpfs           1.6G     0  1.6G   0% /run/user/0
tmpfs           1.6G     0  1.6G   0% /run/user/23239
tmpfs           1.6G     0  1.6G   0% /run/user/18922

可以看到空間已經滿了,所以需要將容器遷移到空間更大的目錄下就解決了。
遷移目錄的步驟如下:

  1. 停止docker服務。
    systemctl stop docker 或者 service docker stop
  2. 建立新的docker目錄,執行命令df -h,找一個大的磁碟,/data 目錄有500G的空間。
    mkdir -p /data/docker
  3. 遷移/var/lib/docker目錄下面的檔案到 /data/docker下面
    cp -R /var/lib/docker/* /data/docker
  4. 修改docker配置,在檔案末新增 --graph=/data/docker
    ExecStart=/usr/bin/dockerd-current \
          --add-runtime docker-runc=/usr/libexec/docker/docker-runc-current \
          --default-runtime=docker-runc \
          --exec-opt native.cgroupdriver=systemd \
          --userland-proxy-path=/usr/libexec/docker/docker-proxy-current \
          --seccomp-profile=/etc/docker/seccomp.json \
          --graph=/data/docker    \
          $OPTIONS \
          $DOCKER_STORAGE_OPTIONS \
          $DOCKER_NETWORK_OPTIONS \
          $ADD_REGISTRY \
          $BLOCK_REGISTRY \
          $INSECURE_REGISTRY \
          $REGISTRIES
    
  5. 過載配置,重啟docker
    systemctl daemon-reload
    systemctl restart docker

參考:
https://blog.csdn.net/qq_37674858/article/details/79976751