Objective:
My version is 2.6.9, has Auth's master and slave, found in the internet for a long time have not found, finally found in the official online method, in fact very simple
If you do have a verified master-slave, then need to use the KeyFile verification, the official said
When running withauthorization
enabled, in Master-slavedeployments Configure a keyFile
So that slave mongod
instances can authenticate and communicate with the master mongod
instance.
To enable authentication and configure the keyFile
Add the following option to your configuration file:
Keyfile=/srv/mongodb/keyfile
So we need to configure KeyFile, the configuration is very simple (but if you don't know the egg hurts)
1. You can use OpenSSL to generate a random key
OpenSSL rand-base64 741 >>key1
[[email protected]data2]# OpenSSL rand-base64 741
mkme0hj8tiiky9+dm/jkgyezbc4zdrgyvfkfqc48pkxivw+3icmevpwhbdjv9xr/
Rztkpwyf8idp9qmpujtohl2hsdah72r+5dk7ap0lzymieu1ysiqav1g6vpbfiiwf
Xfwzwklp6fss6ywboyhos4yaqwycr20o6mrwutwc3ymuiiy5uu9go+8xws+uubbp
Iym8zaawub7use51nkipi+w+zh2lvmf3nkhjpxujlss4iuvjjba4ubriie+lqtyr
71xqpz5hcqw2pywwzsdmqv69fukalgucepodguy8dt8vey9od/sg0+lolrztqsv2
Iwbp2tyuqvstq80stlqao5lofgc4nz3mtgn5ivfnvcvuxhu4y0ybe246rdpp83ia
5xbzmddavuoookft87g7mq169gsvj/4ks0nerfrwpwkglacbfkrd2h8/yss3pnth
Xzxs9xsuhxngalr7a2s0gho+nieo4/mimfiflyuicxh4spohtc+enynaaeukkkrv
Wuvi9+ocbdib1jhdwk/lq4edabb1cleaslylwhrnxwjz+3y+nfixwyrlob1vae3s
Jqd15d59t3x82h6tilumvdqthl4dipuvsztlhvsjuulypgispwmxyzuitgbudqvp
4ds/grvjr3eb94623rfxizx98u3p6sapqiyfiou7ruhhtnzjimm5fohu1hjl42yr
Fggwjg9yzkeneoqoscpgbrenkv08nxiscyfr2tw6ykrdyrxczwlncco36eklvzrk
49sguuz8kvxb7kxakztth/dkzambqrawoauzjvj5h465wdln9cnixxznk85sxlpv
Bjun9ki5shfrxf1ftduvmid2ibudr6pb08xethqyyhhlcmrzmsdyyoujd9whbbx5
O3vas83rsdahqkwlkgxdyercverjrggu681ksj5rc0vzthhpkrhzn4w+ttddm2lr
Y6xako22sow4b/ss67c63hwm1gqh
2. Place key in the MongoDB directory and set 0600 permissions
[email protected] mongodb]# ll
Total 76
Drwxr-xr-x. 2 root root 4096 May 5 01:20 bin
-rw-r--r--. 1 1046 1046 34520 Mar 07:49 gnu-agpl-3.0
-RW-------. 1 root root 1004 May 6 04:43 Key1
-rw-r--r--. 1 root root 1620 May 6 04:55 mongodb.conf
-rw-r--r--. 1 1046 1046 1359 Mar 07:49 README
-rw-r--r--. 1 1046 1046 17793 Mar 07:49 third-party-notices
3, modify the mongodb.conf configuration file, remove the KeyFile option Comment, and fill in the current Key1 path
Keyfile=/usr/local/services/mongodb/key1
4. Now it's time to start
1) Modify the mongodb.conf configuration file from the library
Master=false
Slave=true
source= Main Library IP
Slavedelay=60
Autoresync=true
2) Start from library
MongoDB does have authentication (auth) of master and slave