Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongodb is the master and slave of auth.

2025-02-05 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Foreword:

My version is 2.6.9. I have the master and follower of auth. I haven't found it for a long time on the Internet. Finally, I found a way to be the master and follower on the official website. It's actually very simple.

If you are a master and slave with verification, then you need to use keyFile verification, according to the official.

When running with authorization enabled, in master-slave deployments 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, which is very simple (but it hurts if we don't know)

1. You can use openssl to generate a random key

Openssl rand-base64 741 > > key1

[root@localhost 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

Jqd15d59t3x82h7tilUmVDqTHL4DipuVsztLHvSjUUlyPGISPwmxYzuItGbuDqVP

4dS/grvJR3Eb94623rFxiZX98U3p6SaPQIyFiOu7RUhHtNzjiMm5FOhu1Hjl42yR

FGGwJG9yZKenEoQOscPgBRENkv08nxiScyFr2tw6YkRdYRxcZWLNcCO36eKlvZRk

49SgUUz8KVxB7kxakztth/dkzAMbqraWoaUzjvj5h565Wdln9cnixxznk85SXLPV

BJuN9KI5ShFRXF1FtDuVmiD2Ibudr6pb08xEtHQYYHHLcmRZmSdYyOUjd9wHBbX5

O3VAs83rsdAhQkwLKgXDYERcveRjRGgu681Ksj5Rc0VZthhpkrhZN4w+tTddm2LR

Y6xaKo22SoW4B/SS67C63hwM1GQh

2. Place key in the mongodb directory and set 0600 permissions

[root@localhost mongodb] # ll

Total 76

Drwxr-xr-x. 2 root root 4096 May 5 01:20 bin

-rw-r--r--. 1 1046 1046 34520 Mar 23 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 23 07:49 README

-rw-r--r--. 1 1046 1046 17793 Mar 23 07:49 THIRD-PARTY-NOTICES

3. Modify the configuration file of mongodb.conf, remove the comments on keyFile options, and fill in the current key1 path.

KeyFile=/usr/local/services/mongodb/key1

4. You can start to be the master and follower now.

1) modify the slave mongodb.conf configuration file

Master=false

Slave=true

Source= main library IP

Slavedelay=60

Autoresync=true

2) start the slave library

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report