I encountered some tough problems .
I’m try to finish M310/homework 1.6 .
I can’t fully understand description :
The command can success : testsaslauthd -u adam -p password -f /var/run/saslauthd/mux
And first auto-shell :
#!/bin/bash
course="M310"
exercise="HW-1.6"
workingDir="$HOME/${course}-${exercise}"
dbDir="$workingDir/db"
logName="mongo.log"
ports=(31160 31161 31162)
replSetName="TO_BE_SECURED"
host=`hostname -f`
initiateStr="rs.initiate({
_id: '$replSetName',
members: [
{ _id: 1, host: '$host:31160' },
{ _id: 2, host: '$host:31161' },
{ _id: 3, host: '$host:31162' }
]
})"
# create working folder
mkdir -p "$workingDir/"{r0,r1,r2}
# launch mongod's
for ((i=0; i < ${#ports[@]}; i++))
do
mongod --auth --dbpath "$workingDir/r$i" --logpath "$workingDir/r$i/$logName.log" --port ${ports[
$i]} --replSet $replSetName --fork --setParameter authenticationMechanisms=PLAIN --setParameter sas
lauthdPath="/var/run/saslauthd/mux"
done
# wait for all the mongods to exit
sleep 3
# initiate the set
mongo --port ${ports[0]} --eval "$initiateStr"
The result is :
So I delete --auth,and kill all mongo process and remove all mongo’s data,run again! initiate success,
and run follow command:
db.getSiblingDB("$external").createUser({user:‘adam’,roles:[{role:‘root’,db:‘admin’}]})
db.getSiblingDB("$external").auth({mechanism:“PLAIN”,user:‘adam’,pwd:‘password’,digestPassword: false})
now, the result:
but when I reboot with --auth, the errorlog:
So I try to start only one server:
initiate success,create user:‘adam’ success,and auth success. But add member :
How can I deployment the mongo replica with LDAP?