이 작업에 대하여
This procedure guides you through setting up a mongod
locally in order to complete the Install MongoDB Search and MongoDB Vector Search Tarball installation tutorial.
참고
If you already have a replica set with keyfile authentication set up, you can skip this procedure.
단계
Create your keyfile.
키 파일 인증을 사용하면 복제본 세트의 각 mongod
인스턴스는 배포서버에서 다른 멤버를 인증하기 위한 공유 암호로 키 파일의 내용을 사용합니다. 올바른 키 파일을 가진 mongod
인스턴스만 복제본 세트에 참여할 수 있습니다.
참고
내부 멤버십 인증을 위한 키파일은 YAML 형식을 사용해 키파일에 여러 키를 허용합니다. YAML 형식은 다음 중 하나를 허용합니다.
단일 키 문자열(이전 버전과 동일)
키 문자열의 순서
YAML 형식은 텍스트 파일 형식을 사용하는 기존의 단일 키 키파일과 호환됩니다.
키 길이는 6~1024자 사이여야 하며, base64 세트의 문자만 포함할 수 있습니다. 복제본 세트의 모든 멤버는 하나 이상의 공통 키를 공유해야 합니다.
참고
UNIX 시스템에서는 키 파일에 그룹 또는 월드 권한이 없어야 합니다. Windows 시스템에서는 키 파일 권한이 확인되지 않습니다.
원하는 방법을 사용하여 키 파일을 생성할 수 있습니다. 예를 들어 다음 작업에서는 openssl
사용하여 공유 암호로 사용할 복잡한 의사 난수 1024자 문자열을 생성합니다. 그런 다음 chmod
사용하여 파일 소유자에게만 읽기 권한을 제공하도록 파일 권한을 변경합니다.
openssl rand -base64 756 > <path/to/keyfile> chmod 400 <path/to/keyfile>
키파일 사용에 대한 추가 세부 정보 및 요구 사항은 키파일을 참조하세요.
Copy the keyfile.
Copy the keyfile to each server hosting the replica set members. Ensure that the user running the mongod
instances is the owner of the file and can access the keyfile.
Avoid storing the keyfile on storage mediums that can be easily disconnected from the hardware that hosts the mongod
instances, such as a USB drive or a network attached storage device.
Create your mongod configuration file.
To create your configuration file, save the following code to mongod.conf
or your preferred location.
# MongoDB Configuration File # Network configuration net: port: 27017 bindIpAll: true # Equivalent to --bind_ip_all # Replica set configuration replication: replSetName: rs0 # Security configuration #security: # authorization: enabled # Equivalent to --auth # keyFile: </path/to/keyfile> # Search configuration parameters setParameter: mongotHost: localhost:27027 searchIndexManagementHostAndPort: localhost:27027 # Process management configuration processManagement: fork: true # Logging configuration systemLog: destination: file path: /var/log/mongodb/mongod.log logAppend: true
Create your admin user.
To create an admin user on your mongod
, run the following commands, replacing <password>
with the desired password for the myAdmin
user:
use admin db.createUser( { user: "myAdmin", pwd: "<password>", roles: [ { role: "root", db: "admin" } ] } )
For details, see Create a User-Defined Role.
Initiate your replica set.
Use the rs.initiate()
method to initiate your replica set. For details, see this example.
Update your config file to point to your keyfile.
Uncomment the following lines in the mongod.conf
file you created in Create your mongod configuration file. Replace </path/to/keyfile>
with the path to the keyfile you created in Create your keyfile.
security: authorization: enabled # Equivalent to --auth keyFile: </path/to/keyfile>
Restart mongod with keyfile authentication.
To start mongod
with keyfile authentication, specify the config file that you created in Create your mongod configuration file and updated throughout the procedure.
./mongod --config mongod.conf