Назад | Перейти на главную страницу

Перенос данных Rocket.Chat на другой жесткий диск

У меня Rocket.Chat работает на Ubuntu 18.04.4 LTS через Snap. Я хотел бы переместить данные (но не всю оснастку) на другой жесткий диск. Пока это то, что я пробовал:

Резервное копирование Rocket.Chat

sudo service snap.rocketchat-server.rocketchat-server stop
sudo snap run rocketchat-server.backupdb
sudo service snap.rocketchat-server.rocketchat-server start

Разрешить съемный носитель

sudo snap connect rocketchat-server:removable-media

Остановить Rocket.Chat и mongodb

sudo service snap.rocketchat-server.rocketchat-server stop
sudo service snap.rocketchat-server.rocketchat-mongo stop

Создайте каталог на внешнем диске для хранения данных Rocket.Chat

sudo mkdir /mnt/mountpoint/rocketchat-server-data

Переместить общий каталог из каталога Snap на внешний диск

sudo mv /var/snap/rocketchat-server/common /mnt/mountpoint/rocketchat-server-data/common

Замените общий каталог Snap символьной ссылкой на новое место на внешнем диске

sudo ln -s /mnt/mountpoint/rocketchat-server-data/common /var/snap/rocketchat-server/common

Запустите mongodb и Rocket.Chat

sudo service snap.rocketchat-server.rocketchat-mongo start
sudo service snap.rocketchat-server.rocketchat-server start

Однако после запуска RocketChat не может подключиться к mongodb:

May 07 15:28:16 hostname rocketchat-server.rocketchat-server[4281]: Was unable to connect to Mongo.  Please make sure Mongo has started successfully: sudo systemctl status snap.rocketchat-server.rocketchat-mongo to view logs: sudo journalctl -u snap.rocketchat-server.rocketchat-mongo
May 07 15:28:16 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Main process exited, code=exited, status=1/FAILURE
May 07 15:28:16 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Failed with result 'exit-code'.
May 07 15:28:17 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Service hold-off time over, scheduling restart.
May 07 15:28:17 hostname systemd[1]: snap.rocketchat-server.rocketchat-server.service: Scheduled restart job, restart counter is at 7.
May 07 15:28:17 hostname systemd[1]: Stopped Service for snap application rocketchat-server.rocketchat-server.
May 07 15:28:17 hostname systemd[1]: Started Service for snap application rocketchat-server.rocketchat-server.
May 07 15:28:17 hostname rocketchat-server.rocketchat-server[4518]: Mongo is not available, can't start. Waiting 10 seconds and trying again

В ответ я попытался изменить разрешения для common каталог (только временно) с:

sudo chmod -R 777 /mnt/mountpoint/rocketchat-server-data/common

Затем я перезапустил все, но получил то же сообщение об ошибке. У кого-нибудь есть идеи?

Спасибо!

Обновление 1: (забыл прикрепить статус mongod)

Бег sudo service snap.rocketchat-server.rocketchat-mongo status

Производит:

snap.rocketchat-server.rocketchat-mongo.service - Service for snap application rocketchat-server.rocketchat-mongo
   Loaded: loaded (/etc/systemd/system/snap.rocketchat-server.rocketchat-mongo.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Thu 2020-05-07 16:50:53 EDT; 1s ago
  Process: 16485 ExecStart=/usr/bin/snap run rocketchat-server.rocketchat-mongo (code=exited, status=1/FAILURE)
 Main PID: 16485 (code=exited, status=1/FAILURE)

May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Service hold-off time over, scheduling restart.
May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Scheduled restart job, restart counter is at 5.
May 07 16:50:53 hostname systemd[1]: Stopped Service for snap application rocketchat-server.rocketchat-mongo.
May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Start request repeated too quickly.
May 07 16:50:53 hostname systemd[1]: snap.rocketchat-server.rocketchat-mongo.service: Failed with result 'exit-code'.
May 07 16:50:53 hostname systemd[1]: Failed to start Service for snap application rocketchat-server.rocketchat-mongo.

Обновление 2

sudo journalctl -u snap.rocketchat-server.rocketchat-mongo производит следующее:

-- Logs begin at Thu 2020-03-19 14:41:33 EDT, end at Thu 2020-05-07 17:07:33 EDT. --
Apr 27 10:52:04 hostname systemd[1]: Started Service for snap application rocketchat-server.rocketchat-mongo.
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] MongoDB starting : pid=5004 port=27017 dbpath=/var/snap/rocketchat-server/common 64-bit 
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] db version v3.6.14
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] git version: cbef87692475857c7ee6e764c8f5104b39c342a1
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] allocator: tcmalloc
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] modules: none
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] build environment:
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten]     distarch: x86_64
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten]     target_arch: x86_64
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.797-0400 I CONTROL  [initandlisten] options: { net: { bindIp: "127.0.0.1" }, processManagement: { pidFilePath: "/var/snap/ro
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten]
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten] **          See http://dochub.mongodb.org/core/prodnotes-filesystem
Apr 27 10:52:07 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:07.798-0400 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=3422M,session_max=20000,eviction=(threads_min=
Apr 27 10:52:08 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:08.916-0400 I STORAGE  [initandlisten] WiredTiger message [1587999128:916340][5004:0x7faa065a4a40], txn-recover: Set global rec
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 W STORAGE  [initandlisten] Detected configuration for non-active storage engine mmapv1 when current storage engine 
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten]
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.081-0400 I CONTROL  [initandlisten]
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.242-0400 I STORAGE  [initandlisten] createCollection: local.startup_log with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.298-0400 W FTDC     [initandlisten] Error getting directory iterator '/sys/block': Permission denied
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.298-0400 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory '/var/snap/rocketchat-serv
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.299-0400 I STORAGE  [initandlisten] createCollection: local.me with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.352-0400 I STORAGE  [initandlisten] createCollection: local.replset.minvalid with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.389-0400 I STORAGE  [initandlisten] createCollection: local.replset.election with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.431-0400 I REPL     [initandlisten] Did not find local initialized voted for document at startup.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.432-0400 I REPL     [initandlisten] Did not find local Rollback ID document at startup. Creating one.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.432-0400 I STORAGE  [initandlisten] createCollection: local.system.rollback.id with no UUID.
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.486-0400 I REPL     [initandlisten] Initialized the rollback ID to 1
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.487-0400 I REPL     [initandlisten] Did not find local replica set configuration document at startup;  NoMatchingDocument: D
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.488-0400 I NETWORK  [initandlisten] waiting for connections on port 27017
Apr 27 10:52:09 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:09.488-0400 I CONTROL  [LogicalSessionCacheReap] Sessions collection is not set up; waiting until next sessions reap interval: 
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.393-0400 I NETWORK  [listener] connection accepted from 127.0.0.1:42776 #1 (1 connection now open)
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.416-0400 I NETWORK  [conn1] received client metadata from 127.0.0.1:42776 conn1: { application: { name: "MongoDB Shell" }, d
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.435-0400 I REPL     [conn1] replSetInitiate admin command received from client
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.499-0400 I REPL     [conn1] replSetInitiate config object with 1 members parses ok
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.499-0400 I REPL     [conn1] ******
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.499-0400 I REPL     [conn1] creating replication oplog of size: 4367MB...
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.500-0400 I STORAGE  [conn1] createCollection: local.oplog.rs with no UUID.
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.516-0400 I STORAGE  [conn1] Starting WiredTigerRecordStoreThread local.oplog.rs
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.517-0400 I STORAGE  [conn1] The size storer reports that the oplog contains 0 records totaling to 0 bytes
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.517-0400 I STORAGE  [conn1] Scanning the oplog to determine where to place markers for truncation
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.690-0400 I REPL     [conn1] ******
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.691-0400 I STORAGE  [conn1] createCollection: local.system.replset with no UUID.
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.745-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.system.rollback.id
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.745-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.system.replset
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.745-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.me
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.startup_log
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.replset.minvalid
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.oplog.rs
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I COMMAND  [conn1] Assigning UUID <UUID here> to collection local.replset.election
Apr 27 10:52:15 hostname rocketchat-server.rocketchat-mongo[4932]: 2020-04-27T10:52:15.746-0400 I STORAGE  [conn1] createCollection: admin.system.version with provided UUID: <UUID here>

Обновление 3

Во время дополнительных исследований я нашел этот пост: https://forums.rocket.chat/t/changing-mongo-data-directory/1458/3 что, кажется, указывает на то, что Snap не позволит использовать внешние каталоги, даже если они являются символьными ссылками. Я попытался переопределить это через AppArmor, добавив строку:

alias /var/snap/rocketchat-server/common -> /mnt/mountpoint/rocketchat-server-data/common,

к /etc/apparmor.d/tunables/alias и перезапуск AppArmor и Mongo. Это не сработало.