Environment
- Juju DB snap channel: 4.0/stable
- Juju controller agent: 2.9.0
- Operating System: Ubuntu 20.04 LTS
- Deployment: Juju HA
Symptom
- Juju controller does not bind port
37017
/ MongoDB Port - Following error log can be found from
/var/snap/juju-db/common/logs/mongodb.log
[replication-0] We are too stale to use <IP_ADDRESS>:37017 as a sync source. Blacklisting this sync source because our last fetched timestamp:
[replication-0] could not find member to sycn from
Guide
1. Pausing Juju Controller and Juju Database (MongoDB)
Execute on all juju controller
- Switch to controller model
juju switch controller
- Login to juju controller
juju ssh <machine_id>
- Stop all juju controller agent Run following command inside
sudo systemctl stop jujud-machine-<machine_id>.service
- Gracefully stop Juju Database (MongoDB)
sudo snap stop juju-db
2. Backup Juju Database
Execute on troubled juju controller
Backup DB
sudo mv /var/snap/juju-db/common/db /var/snap/juju-db/common/db.orig
sudo mkdir /var/snap/juju-db/common/db
sudo chmod 700 /var/snap/juju-db/common/db
3. Start database
Execute on all juju controller
- Start all Juju Database (MongoDB)
sudo snap start juju-db
- Verify sync process
You should see the key
statStr
has value asSECONDARY
# Get user and password
export user=$(sudo grep tag /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2)
export password=$(sudo grep statepassword /var/lib/juju/agents/machine-*/agent.conf | cut -d' ' -f2)
# Make sure the troubled node already run as SECONDARY
mongo 127.0.0.1:37017/juju -u "${user}" -p "${password}" --sslAllowInvalidCertificates --ssl --authenticationDatabase admin --eval "printjson(rs.status())"