§2024-08-18
¶1. Ubuntu 24.04 LTS (Noble Numbat)
alexlai@hc4Noble:~$ lsblk -f
NAME FSTYPE FSVER LABEL UUID FSAVAIL FSUSE% MOUNTPOINTS
sda
├─sda1 ext4 1.0 BOOT f980a748-b1be-4691-a7dd-7d59e612e496 829.5M 3% /boot
├─sda2 swap 1 0a2e84d2-325e-431a-82b8-c2b5104bec4d [SWAP]
├─sda3 ext4 1.0 root 78dc0f0c-8110-43b0-958b-986fdbe882fb 54.3G 2% /
└─sda4 xfs xfs e10fb855-3c73-49d2-8a1d-3d7c4e46213d 163.6G 1% /opt/xfs
¶2. Deploy with Ubuntu@rocket.chat
Preparation steps
Depending on the version of Rocket.Chat you want to install, check the release notes to see the supported engine versions for MongoDB and NodeJs, and install as recommended.
- MongoDB
- Please refer to the official MongoDB documentation on how to install MongoDB on Ubuntu.
- Download Binary
$ mkdir -p build/src && cd $_
alexlai@hc4Noble:~/build/src$ wget https://repo.mongodb.org/apt/ubuntu/dists/jammy/mongodb-org/7.0/multiverse/binary-arm64/mongodb-org-server_7.0.12_arm64.deb
$ sudo dpkg -i mongodb-org-server_7.0.12_arm64.deb
Selecting previously unselected package mongodb-org-server.
(Reading database ... 28873 files and directories currently installed.)
Preparing to unpack mongodb-org-server_7.0.12_arm64.deb ...
Unpacking mongodb-org-server (7.0.12) ...
Setting up mongodb-org-server (7.0.12) ...
info: Selecting UID from range 100 to 999 ...
info: Adding system user `mongodb' (UID 106) ...
info: Adding new user `mongodb' (UID 106) with group `nogroup' ...
info: Not creating `/nonexistent'.
info: Selecting GID from range 100 to 999 ...
info: Adding group `mongodb' (GID 109) ...
info: Adding user `mongodb' to group `mongodb' ...
Processing triggers for man-db (2.12.0-4build2) ...
$ mongod -version
db version v7.0.12
Build Info: {
"version": "7.0.12",
"gitVersion": "b6513ce0781db6818e24619e8a461eae90bc94fc",
"openSSLVersion": "OpenSSL 3.0.13 30 Jan 2024",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu2204",
"distarch": "aarch64",
"target_arch": "aarch64"
}
}
- setup /opt/xfs
$ sudo mkdir /opt/xfs/mongodb
alexlai@hc4Noble:~/build/src$ sudo mkdir /opt/xfs/mongodb/data
alexlai@hc4Noble:~/build/src$ sudo mkdir /opt/xfs/mongodb/log
alexlai@hc4Noble:~/build/src$ sudo chown mongodb:mongodb -R /opt/xfs/mongodb/
alexlai@hc4Noble:~/build/src$ ls -l /opt/xfs/mongodb/
total 0
drwxr-xr-x 2 mongodb mongodb 6 Aug 18 14:35 data
drwxr-xr-x 2 mongodb mongodb 6 Aug 18 14:35 log
- /etc/mongod.conf
# mongod.conf
# for documentation of all options, see:
# http://docs.mongodb.org/manual/reference/configuration-options/
# Where and how to store data.
storage:
dbPath: /opt/xfs/mongodb/data
# engine:
# wiredTiger:
# where to write logging data.
systemLog:
destination: file
logAppend: true
path: /opt/xfs/mongodb/log/mongod.log
# network interfaces
net:
port: 27017
bindIp: 127.0.0.1
# how the process runs
processManagement:
timeZoneInfo: /usr/share/zoneinfo
#security:
#operationProfiling:
replication:
replSetName: rs01
#sharding:
## Enterprise-Only Options:
#auditLog:
- /usr/lib/systemd/system/mongod.service
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network-online.target
Wants=network-online.target
[Service]
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
Environment="MONGODB_CONFIG_OVERRIDE_NOFORK=1"
ExecStart=/usr/bin/mongod --config /etc/mongod.conf
RuntimeDirectory=mongodb
# file size
LimitFSIZE=infinity
# cpu time
LimitCPU=infinity
# virtual memory size
LimitAS=infinity
# open files
LimitNOFILE=64000
# processes/threads
LimitNPROC=64000
# locked memory
LimitMEMLOCK=infinity
# total threads (user+kernel)
TasksMax=infinity
TasksAccounting=false
# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
[Install]
WantedBy=multi-user.target
- test to start mongod.service
alexlai@hc4Noble:~$ sudo systemctl restart mongod.service
alexlai@hc4Noble:~$ sudo systemctl status mongod.service
● mongod.service - MongoDB Database Server
Loaded: loaded (/usr/lib/systemd/system/mongod.service; disabled; preset: enabled)
Active: active (running) since Sun 2024-08-18 15:16:56 CST; 2s ago
Docs: https://docs.mongodb.org/manual
Main PID: 2004 (mongod)
Memory: 168.9M (peak: 169.4M)
CPU: 2.348s
CGroup: /system.slice/mongod.service
└─2004 /usr/bin/mongod --config /etc/mongod.conf
Aug 18 15:16:56 hc4Noble systemd[1]: Started mongod.service - MongoDB Database Server.
Aug 18 15:16:56 hc4Noble mongod[2004]: {"t":{"$date":"2024-08-18T07:16:56.300Z"},"s":"I", "c":"CONTROL", "id":7484500, "ctx":"main","msg":"Environment variable MONGODB_CONFIG_OVERRIDE_NOF>
- enable mongod.service
alexlai@hc4Noble:~$ sudo systemctl enable mongod.service
Created symlink /etc/systemd/system/multi-user.target.wants/mongod.service → /usr/lib/systemd/system/mongod.service.
Rocket.Chat 6.11.1 Latest Engine versions
Node: 14.21.3
MongoDB: 4.4, 5.0, 6.0
Apps-Engine: 1.44.0
-
NodeJS
- Follow the official guide to install NodeJS on Ubuntu. You can also use third-party tools like nvm or n.
When deploying MongoDB, it is crucial to secure MongoDB instances and close all MongoDB ports from public access. Unsecured instances can lead to significant security vulnerabilities. Your vigilance in these practices is essential for maintaining the integrity and safety of your systems.
- using fnm to control node version
$ sudo apt install unzip
installs fnm (Fast Node Manager)
alexlai@hc4Noble:~$ curl -fsSL https://fnm.vercel.app/install | bash Checking dependencies for the installation script... Checking availability of curl... OK! Checking availability of unzip... OK! Downloading https://github.com/Schniz/fnm/releases/latest/download/fnm-arm64.zip... ######################################################################## 100.0% Installing for Bash. Appending the following to /home/alexlai/.bashrc:
fnm
FNM_PATH="/home/alexlai/.local/share/fnm"
if [ -d "$FNM_PATH" ]; then
export PATH="$FNM_PATH:$PATH"
eval "fnm env
"
fi
In order to apply the changes, open a new terminal or run the following command:
source /home/alexlai/.bashrc $ source /home/alexlai/.bashrc $ alexlai@hc4Noble:~$ fnm list-remote ... v22.5.1 v22.6.0
$ fnm install v14.21.3 Installing Node v14.21.3 (arm64)
alexlai@bookworm:~$ fnm list
- v14.21.3 default
- system
alexlai@hc4Noble:~$ which node /run/user/1026/fnm_multishells/2194_1723966064595/bin/node
alexlai@hc4Noble:$ ls /home/alexlai/.local/share/fnm/node-versions/v22.6.0/installation/bin/node
/home/alexlai/.local/share/fnm/node-versions/v22.6.0/installation/bin/node
alexlai@hc4Noble:$ /home/alexlai/.local/share/fnm/node-versions/v22.6.0/installation/bin/node --version
v22.6.0
alexlai@hc4Noble:$ sudo ln -sf /home/alexlai/.local/share/fnm/node-versions/v22.6.0/installation/bin/node /usr/bin/node
alexlai@hc4Noble:$ sudo ln -sf /home/alexlai/.local/share/fnm/node-versions/v22.6.0/installation/bin/npm /usr/bin/npm
[sudo] password for alexlai:
alexlai@hc4Noble:~$ sudo ln -sf /home/alexlai/.local/share/fnm/node-versions/v22.6.0/installation/bin/npx /usr/bin/npx
alexlai@hc4Noble:$ which node
/run/user/1026/fnm_multishells/2194_1723966064595/bin/node
alexlai@hc4Noble:$ /usr/bin/node --version
v22.6.0
- test other user
root@hc4Noble:/home/alexlai# which node /usr/bin/node root@hc4Noble:/home/alexlai# node Welcome to Node.js v22.6.0. Type ".help" for more information.
root@hc4Noble:/home/alexlai# which npm /usr/bin/npm root@hc4Noble:/home/alexlai# which npx /usr/bin/npx