Hi everyone!
I’m trying to migrate my deprecated MongoDB from mmapv1 storage engine to wiredTiger storage engine to be able to update Rocket.Chat.
Right now the set up is through Ubuntu 22.04 / Docker.
You can see below details of the Rocket.chat containers:
Rocket.Chat Container
±-----------------------------------------------+
| SERVER RUNNING |
±-----------------------------------------------+
| |
| Rocket.Chat Version: 4.5.0 |
| NodeJS Version: 14.18.3 - x64 |
| MongoDB Version: 4.0.28 |
| MongoDB Engine: mmapv1 |
| Platform: linux |
| Process Port: 3000 |
| Site URL: https:// |
| ReplicaSet OpLog: Enabled |
| Commit Hash: 3901xxxxxx |
| Commit Branch: HEAD |
| |
±-----------------------------------------------+
±---------------------------------------------------------------------+
| DEPRECATION |
±---------------------------------------------------------------------+
| |
| YOUR CURRENT MONGODB VERSION (4.0.28) IS DEPRECATED. |
| IT WILL NOT BE SUPPORTED ON ROCKET.CHAT VERSION 5.0.0 AND GREATER, |
| PLEASE UPGRADE MONGODB TO VERSION 4.2 OR GREATER |
| |
±---------------------------------------------------------------------+
MongoDB container
22-06-10T11:51:07.462+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=c7593367e1ae
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] db version v4.0.28
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] git version: af1a9dc12adcfa83cc19571cb3faba26eeddac92
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.2g 1 Mar 2016
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] allocator: tcmalloc
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] modules: none
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] build environment:
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] distmod: ubuntu1604
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] distarch: x86_64
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] target_arch: x86_64
2022-06-10T11:51:07.470+0000 I CONTROL [initandlisten] options: { net: { bindIpAll: true }, replication: { oplogSizeMB: 128, replSet: “rs0” }, storage: { engine: “mmapv1”, mmapv1: { smallFiles: true } } }
2022-06-10T11:51:07.470+0000 I STORAGE [initandlisten]
2022-06-10T11:51:07.470+0000 I STORAGE [initandlisten] ** WARNING: Support for MMAPV1 storage engine has been deprecated and will be
2022-06-10T11:51:07.470+0000 I STORAGE [initandlisten] ** removed in version 4.2. Please plan to migrate to the wiredTiger
2022-06-10T11:51:07.470+0000 I STORAGE [initandlisten] ** storage engine.
2022-06-10T11:51:07.470+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/deprecated-mmapv1
2022-06-10T11:51:07.470+0000 I STORAGE [initandlisten]
2022-06-10T11:51:07.484+0000 I JOURNAL [initandlisten] journal dir=/data/db/journal
2022-06-10T11:51:07.484+0000 I JOURNAL [initandlisten] recover : no journal files present, no recovery needed
2022-06-10T11:51:07.490+0000 I JOURNAL [durability] Durability thread started
2022-06-10T11:51:07.490+0000 I JOURNAL [journal writer] Journal writer thread started
2022-06-10T11:51:07.495+0000 I CONTROL [initandlisten]
2022-06-10T11:51:07.495+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database.
2022-06-10T11:51:07.495+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted.
2022-06-10T11:51:07.495+0000 I CONTROL [initandlisten]
2022-06-10T11:51:07.608+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory ‘/data/db/diagnostic.data’
2022-06-10T11:51:07.613+0000 I REPL [initandlisten] Rollback ID is 1
2022-06-10T11:51:07.614+0000 I REPL [initandlisten] Recovering from an unstable checkpoint (top of oplog: { ts: Timestamp(1654861250, 1), t: 617 }, appliedThrough: { ts: Timestamp(0, 0), t: -1 })
2022-06-10T11:51:07.614+0000 I REPL [initandlisten] No oplog entries to apply for recovery. appliedThrough is null.
2022-06-10T11:51:07.644+0000 I REPL [replexec-0] New replica set config in use: { _id: “rs0”, version: 1, protocolVersion: 1, writeConcernMajorityJournalDefault: true, members: [ { _id: 0, host: “localhost:27017”, arbiterOnly: false, buildIndexes: true, hidden: false, priority: 1.0, tags: {}, slaveDelay: 0, votes: 1 } ], settings: { chainingAllowed: true, heartbeatIntervalMillis: 2000, heartbeatTimeoutSecs: 10, electionTimeoutMillis: 10000, catchUpTimeoutMillis: -1, catchUpTakeoverDelayMillis: 30000, getLastErrorModes: {}, getLastErrorDefaults: { w: 1, wtimeout: 0 }, replicaSetId: ObjectId(‘60029f5619ed4eaf0e49e6ba’) } }
2022-06-10T11:51:07.644+0000 I REPL [replexec-0] This node is localhost:27017 in the config
2022-06-10T11:51:07.644+0000 I REPL [replexec-0] transition to STARTUP2 from STARTUP
2022-06-10T11:51:07.644+0000 I REPL [replexec-0] Starting replication storage threads
2022-06-10T11:51:07.645+0000 I NETWORK [initandlisten] waiting for connections on port 27017
2022-06-10T11:51:07.645+0000 I REPL [replexec-0] transition to RECOVERING from STARTUP2
2022-06-10T11:51:07.645+0000 I REPL [replexec-0] Starting replication fetcher thread
2022-06-10T11:51:07.645+0000 I REPL [replexec-0] Starting replication applier thread
2022-06-10T11:51:07.645+0000 I REPL [replexec-0] Starting replication reporter thread
2022-06-10T11:51:07.646+0000 I NETWORK [LogicalSessionCacheRefresh] Starting new replica set monitor for rs0/localhost:27017
2022-06-10T11:51:07.646+0000 I REPL [rsSync-0] Starting oplog application
2022-06-10T11:51:07.646+0000 I REPL [rsSync-0] transition to SECONDARY from RECOVERING
2022-06-10T11:51:07.646+0000 I REPL [rsSync-0] conducting a dry run election to see if we could be elected. current term: 617
2022-06-10T11:51:07.646+0000 I ASIO [ReplicaSetMonitor-TaskExecutor] Connecting to localhost:27017
2022-06-10T11:51:07.646+0000 I REPL [replexec-0] dry election run succeeded, running for election in term 618
2022-06-10T11:51:07.647+0000 I NETWORK [listener] connection accepted from 127.0.0.1:36758 #2 (1 connection now open)
2022-06-10T11:51:07.648+0000 I NETWORK [conn2] received client metadata from 127.0.0.1:36758 conn2: { driver: { name: “NetworkInterfaceTL”, version: “4.0.28” }, os: { type: “Linux”, name: “Ubuntu”, architecture: “x86_64”, version: “16.04” } }
2022-06-10T11:51:07.657+0000 W NETWORK [ReplicaSetMonitor-TaskExecutor-0] Unable to reach primary for set rs0
2022-06-10T11:51:07.677+0000 I REPL [replexec-0] election succeeded, assuming primary role in term 618
2022-06-10T11:51:07.677+0000 I REPL [replexec-0] transition to PRIMARY from SECONDARY
2022-06-10T11:51:07.677+0000 I REPL [replexec-0] Resetting sync source to empty, which was :27017
2022-06-10T11:51:07.678+0000 I REPL [replexec-0] Entering primary catch-up mode.
2022-06-10T11:51:07.678+0000 I REPL [replexec-0] Exited primary catch-up mode.
2022-06-10T11:51:07.678+0000 I REPL [replexec-0] Stopping replication producer
2022-06-10T11:51:07.678+0000 I REPL [ReplBatcher] Oplog buffer has been drained in term 618
2022-06-10T11:51:07.680+0000 I REPL [rsSync-0] transition to primary complete; database writes are now permitted
2022-06-10T11:51:08.010+0000 I NETWORK [listener] connection accepted from 172.19.0.4:43068 #3 (2 connections now open)
Now, when trying to migrate to wiredTiger storage engine, I use the following docker-compose file as per in the documentation, together with the docker directory.
After stooping all the containers, I do the necessary modifications to match my setup:
version: '2'
services:
rocketchat:
image: rocketchat/rocket.chat:4.5.0
command: >
bash -c
"for (( ; ; )); do
node main.js &&
s=$$? && break || s=$$?;
echo \"Could not start Rocket.Chat. Waiting 5 secs...\";
sleep 5;
done; (exit $$s)"
restart: unless-stopped
volumes:
- /home/ubu/rocket/uploads:/app/uploads
environment:
- PORT=3000
- ROOT_URL=http://localhost:3000
- MONGO_URL=mongodb://mongo:27017/rocketchat
- MONGO_OPLOG_URL=mongodb://mongo:27017/local
- MAIL_URL=smtp://smtp.email
depends_on:
- mongo
ports:
- 3170:3000
labels:
- "traefik.backend=rocketchat"
- "traefik.frontend.rule=Host: your.domain.tld"
mongo:
image: mongo:4.0
restart: unless-stopped
volumes:
- ./data/db:/data/db
# - ./data/db:/data/configdb
- ./data/dump:/dump
command: >
bash -c
"while [ ! -f /data/db/WiredTiger ]; do
echo \"wiredTiger migration hasn't started yet. Waiting 30 secs...\";
sleep 30;
done;
docker-entrypoint.sh mongod --oplogSize 128 --replSet rs0 --storageEngine=wiredTiger;"
depends_on:
- migrator
labels:
- "traefik.enable=false"
migrator:
build: ./docker/
volumes:
- /home/ubu/rocket/data/db:/data/db
mongo-init-replica:
image: mongo:4.0
command: >
bash -c
"for (( ; ; )); do
mongo mongo/rocketchat --eval \"
rs.initiate({
_id: 'rs0',
members: [ { _id: 0, host: 'localhost:27017' } ]})\" &&
s=$$? && break || s=$$?;
echo \"Could not reach MongoDB. Waiting 5 secs ...\";
sleep 5;
done; (exit $$s)"
depends_on:
- mongo
Once it is run the below is the output:
Rocket.Chat Container
/app/bundle/programs/server/node_modules/fibers/future.js:313
throw(ex);
^MongoServerSelectionError: connect ECONNREFUSED 172.19.0.3:27017
at Timeout._onTimeout (/app/bundle/programs/server/npm/node_modules/meteor/npm-mongo/node_modules/mongodb/lib/core/sdam/topology.js:437:30)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7) {
reason: TopologyDescription {
type: ‘Single’,
setName: null,
maxSetVersion: null,
maxElectionId: null,
servers: Map(1) {
‘mongo:27017’ => ServerDescription {
address: ‘mongo:27017’,
error: Error: connect ECONNREFUSED 172.19.0.3:27017
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1159:16) {
name: ‘MongoNetworkError’
},
roundTripTime: -1,
lastUpdateTime: 12189726,
lastWriteDate: null,
opTime: null,
type: ‘Unknown’,
topologyVersion: undefined,
minWireVersion: 0,
maxWireVersion: 0,
hosts: ,
passives: ,
arbiters: ,
tags:
}
},
stale: false,
compatible: true,
compatibilityError: null,
logicalSessionTimeoutMinutes: null,
heartbeatFrequencyMS: 10000,
localThresholdMS: 15,
commonWireVersion: null
}
}
Could not start Rocket.Chat. Waiting 5 secs…
MongoDB Container
wiredTiger migration hasn’t started yet. Waiting 30 secs…
wiredTiger migration hasn’t started yet. Waiting 30 secs…
wiredTiger migration hasn’t started yet. Waiting 30 secs…
wiredTiger migration hasn’t started yet. Waiting 30 secs…
wiredTiger migration hasn’t started yet. Waiting 30 secs…
Rocket Migrator
2022-06-10T12:27:49.181+0000 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:356:17
@(connect):2:6
exception: connect failed
MongoDB shell version v4.0.28
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2022-06-10T12:27:50.240+0000 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:356:17
@(connect):2:6
exception: connect failed
MongoDB shell version v4.0.28
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
2022-06-10T12:27:51.306+0000 E QUERY [js] Error: couldn’t connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:356:17
@(connect):2:6
exception: connect failed
MongoDB shell version v4.0.28
connecting to: mongodb://127.0.0.1:27017/?gssapiServiceName=mongodb
I guess at this point the Rocket Migrator should be migrating MongoDB from mmapv1 storage engine to wiredTiger storage engine but as you can see it doesn’t even connect.
Appreciate any help!!
Thank you!
Alex