I am having a problem with starting mongoDB on a Rasberry Pi with systemd, using Raspberry Pi OS 64 bits.
This is my environment:
root@raspberrypi:~ # uname -a
Linux raspberrypi 5.10.17-v8+ #1403 SMP PREEMPT Mon Feb 22 11:37:54 GMT 2021 aarch64 GNU/Linux
root@raspberrypi:~ #
root@raspberrypi:~ # mongo --version
MongoDB shell version v4.4.4
Build Info: {
"version": "4.4.4",
"gitVersion": "8db30a63db1a9d84bdcad0c83369623f708e0397",
"openSSLVersion": "OpenSSL 1.1.1d 10 Sep 2019",
"modules": [],
"allocator": "tcmalloc",
"environment": {
"distmod": "ubuntu1804",
"distarch": "aarch64",
"target_arch": "aarch64"
}
}
root@raspberrypi:~ #
And this is the configuration file for the mongod server:
root@raspberrypi:~# cat /home/mongodb/mongo-One.cfg
storage:
dbPath: /mnt/mongoDB-One/DB_Data
journal:
enabled: true
net:
#bindIp: 192.168.10.114
port: 22330
systemLog:
destination: file
path: /mnt/mongoDB-One/DB_Data/mongod.log
logAppend: true
replication:
replSetName: mngoRepSet
root@raspberrypi:~#
This is the systemd service file:
root@raspberrypi:~# cat /lib/systemd/system/mongod-One.service
[Unit]
Description=MongoDB Database Server
Documentation=https://docs.mongodb.org/manual
After=network-online.target
Wants=network-online.target
Requires=network-online.target
[Service]
User=mongodb
Group=mongodb
EnvironmentFile=-/etc/default/mongod
ExecStart=/usr/bin/mongod --config /home/mongodb/mongo-One.cfg
PIDFile=/var/run/mongodb/mongod.pid
# 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
Type=idle
# Recommended limits for mongod as specified in
# https://docs.mongodb.com/manual/reference/ulimit/#recommended-ulimit-settings
[Install]
WantedBy=multi-user.target
root@raspberrypi:~#
In this configuration the server starts as expected (note that the bindIp line in the server configuration is commented out). But troubles come when I remove the comment on the bindIp line.
I then get this error in the logs:
{"t":{"$date":"2021-03-20T12:51:15.862+09:00"},"s":"E", "c":"STORAGE", "id":20568, "ctx":"initandlisten","msg":"Error setting up listener","attr":{"error":{"code":9001,"codeName":"SocketException","errmsg":"Cannot assign requested address"}}}
It seems to show a network issue, but I have done everything I can think of in the systemd service file to make sure the network would be ready when starting the service. Can someone see something I am missing?
I can also confirm that after failing at boot time, the service can be manually started using:
root@raspberrypi:~ # systemctl start mongod-One