AI 에이전트의 경우: 문서 인덱스는 https://www.mongodb.com/ko-kr/docs/llms.txt에서 사용할 수 있으며, 모든 페이지의 마크다운 버전은 어떤 URL 경로에 .md를 추가하여 사용할 수 있습니다.

MongoDB 엔터프라이즈 로 검색 설치 및 사용

Kubernetes Operator를 사용하여 MongoDB Search 및 Vector Search 리소스를 배포 Kubernetes 클러스터 에서 MongoDB 엔터프라이즈 v8.0.10 이상으로 실행 수 있습니다. 이 절차에서는 Kubernetes 클러스터 의 새 복제본 세트 또는 기존 복제본 세트 로 실행 mongot 프로세스 배포 하고 구성하는 방법을 보여 줍니다.

MongoDB Search 및 Vector Search를 배포 하려면 다음이 필요합니다.

  • 로컬에서 사용할 수 있는 kubeconfig 가 포함 실행 Kubernetes 클러스터 입니다.

  • Kubernetes 명령줄 도구인 kubectl이(가) 클러스터 와 통신하도록 구성되었습니다.

  • 이 튜토리얼의 명령을 실행 하려면 Bash v5.1 이상을 사용해야 합니다.

  • Ops Manager 또는 MongoDB Cloud Manager 프로젝트 및 API 자격 증명.

1

이 절차의 후속 단계에서 사용할 환경 변수를 설정하다 하려면 다음을 복사하고 환경 변수의 값을 설정하다 다음 환경 변수를 로드합니다.

# set it to the context name of the k8s clusterexport K8S_CTX="<local cluster context>" # the following namespace will be created if not existsexport MDB_NS="mongodb" # name of the MongoDB Custom Resource.export MDB_RESOURCE_NAME="mdb-rs" # OM/CM's project name to be used to manage mongodb replica setexport OPS_MANAGER_PROJECT_NAME="<arbitrary project name>" # URL to Cloud Manager or Ops Manager instanceexport OPS_MANAGER_API_URL="https://cloud-qa.mongodb.com" # The API key can be an Org Owner - the operator can create the project automatically then.# The API key can also be created in a particular project that was created manually with the Project Owner scope .export OPS_MANAGER_API_USER="abcdefg"export OPS_MANAGER_API_KEY="00000-abcd-efgh-1111-12345678"export OPS_MANAGER_ORG_ID="62a73abcdefgh12345678" # minimum required MongoDB version for running MongoDB Search is 8.0.10export MDB_VERSION="8.0.10" # root admin user for convenience, not used here at all in this guideexport MDB_ADMIN_USER_PASSWORD="admin-user-password-CHANGE-ME"# regular user performing restore and search queries on sample mflix databaseexport MDB_USER_PASSWORD="mdb-user-password-CHANGE-ME"# user for MongoDB Search to connect to the replica set to synchronise data fromexport MDB_SEARCH_SYNC_USER_PASSWORD="search-sync-user-password-CHANGE-ME" export OPERATOR_HELM_CHART="mongodb/mongodb-kubernetes"# comma-separated key=value pairs for additional parameters passed to the helm-chart installing the operatorexport OPERATOR_ADDITIONAL_HELM_VALUES="" export MDB_CONNECTION_STRING="mongodb://mdb-user:${MDB_USER_PASSWORD}@${MDB_RESOURCE_NAME}-svc.${MDB_NS}.svc.cluster.local:27017/?replicaSet=${MDB_RESOURCE_NAME}"
2

Helm 은 Kubernetes 에서 MongoDB 인스턴스의 배포서버 및 관리 자동화합니다. Kubernetes Operator 연산자 설치를 위한 Helm 차트 포함된 Helm 리포지토리 이미 추가한 경우 이 단계를 건너뜁니다. 그렇지 않으면 Helm 리포지토리 추가합니다.

다음 명령을 추가, 복사, 붙여넣기 및 실행 하려면 다음을 수행하세요.

helm repo add mongodb https://mongodb.github.io/helm-chartshelm repo update mongodbhelm search repo mongodb/mongodb-kubernetes
3

Kubernetes Operator는 MongoDB, MongoDBOpsManager 및 MongoDBSearch 사용자 지정 리소스를 감시하고 MongoDB deployment의 수명 주기를 관리합니다. Kubernetes Operator용 MongoDB 컨트롤러를 이미 설치한 경우 이 단계를 건너뛰세요. 그렇지 않으면 이전 단계에서 추가한 Helm 리포지토리 에서 Kubernetes Operator용 MongoDB 컨트롤러를 설치합니다.

mongodb 네임스페이스 에 Kubernetes Operator용 MongoDB 컨트롤러를 설치하려면 다음을 복사하여 붙여넣고 실행 .

helm upgrade --install --debug --kube-context "${K8S_CTX}" \ --create-namespace \ --namespace="${MDB_NS}" \ mongodb-kubernetes \ ${OPERATOR_ADDITIONAL_HELM_VALUES:+--set ${OPERATOR_ADDITIONAL_HELM_VALUES}} \ "${OPERATOR_HELM_CHART}"
4

이미 MongoDB 엔터프라이즈 배포한 경우 다음 단계로 건너뜁니다. 그렇지 않으면 MongoDB 엔터프라이즈 리소스 배포 .

MongoDB 엔터프라이즈 배포 하려면 다음 단계를 완료하세요.

  1. mdb-rs(이)라는 MongoDB 사용자 지정 리소스 만듭니다.

    리소스 mongod 및 mongodb-agent 컨테이너의 CPU 및 메모리 리소스를 정의하고 Kubernetes Operator에게 3 멤버로 MongoDB 복제본 세트 구성하도록 지시합니다.

    MongoDB 엔터프라이즈 배포 하려면 네임스페이스 에서 다음을 복사하여 붙여넣고 실행 .

    kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOFapiVersion: mongodb.com/v1kind: MongoDBmetadata: name: ${MDB_RESOURCE_NAME}spec: members: 3 version: ${MDB_VERSION}-ent type: ReplicaSet opsManager: configMapRef: name: om-project credentials: om-credentials security: authentication: enabled: true ignoreUnknownUsers: true modes: - SCRAM agent: logLevel: DEBUG statefulSet: spec: template: spec: containers: - name: mongodb-enterprise-database resources: limits: cpu: "2" memory: 2Gi requests: cpu: "1" memory: 1GiEOF
  2. MongoDB 리소스 배포서버 완료될 때까지 기다립니다.

    MongoDB 사용자 지정 리소스 적용 Kubernetes 연산자 MongoDB 노드(포드) 배포를 시작합니다. 이 단계에서는 mdbc-rs 리소스의 상태 단계가 Running가 되어 MongoDB Community 복제본 세트 작동 가능함을 나타낼 때까지 실행을 일시 중지합니다.

    echo "Waiting for MongoDB resource to reach Running phase..."kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait --for=jsonpath='{.status.phase}'=Running "mdb/${MDB_RESOURCE_NAME}" --timeout=400secho; echo "MongoDB resource"kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get "mdb/${MDB_RESOURCE_NAME}"echo; echo "Pods running in cluster ${K8S_CTX}"kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get pods
5

MongoDB 보안 액세스 위해 인증 필요합니다. 이 단계에서는 세 개의 Kubernetes 시크릿을 생성합니다.

  • mdb-admin-user-password: MongoDB 관리자의 자격 증명입니다.

  • mdb-user-password: 검색 쿼리를 수행할 수 있는 권한이 있는 사용자의 자격 증명입니다.

  • mdbc-rs-search-sync-source-password: mongot 프로세스 에서 데이터를 동기화하고 인덱스를 관리 위해 내부적으로 사용하는 검색 전용 사용자에 대한 자격 증명입니다.

Kubernetes Operator는 이러한 시크릿을 MongoDB pod에 마운트합니다.

시크릿을 생성하려면 MongoDB Server 배포하고 MongoDB Search 및 Vector Search를 배포 하려는 네임스페이스 에 다음을 복사하여 붙여넣은 후 실행 .

# admin user with root rolekubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \ create secret generic mdb-admin-user-password \ --from-literal=password="${MDB_ADMIN_USER_PASSWORD}" kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOFapiVersion: mongodb.com/v1kind: MongoDBUsermetadata: name: mdb-adminspec: username: mdb-admin db: admin mongodbResourceRef: name: ${MDB_RESOURCE_NAME} passwordSecretKeyRef: name: mdb-admin-user-password key: password roles: - name: root db: adminEOF # user used by MongoDB Search to connect to MongoDB database to synchronize data from# For MongoDB <8.2, the operator will be creating the searchCoordinator custom role automatically# From MongoDB 8.2, searchCoordinator role will be a built-in role.kubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \ create secret generic mdb-rs-search-sync-source-password \ --from-literal=password="${MDB_SEARCH_SYNC_USER_PASSWORD}"kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOFapiVersion: mongodb.com/v1kind: MongoDBUsermetadata: name: search-sync-source-userspec: username: search-sync-source db: admin mongodbResourceRef: name: ${MDB_RESOURCE_NAME} passwordSecretKeyRef: name: mdb-rs-search-sync-source-password key: password roles: - name: searchCoordinator db: adminEOF # user performing search querieskubectl --context "${K8S_CTX}" --namespace "${MDB_NS}" \ create secret generic mdb-user-password \ --from-literal=password="${MDB_USER_PASSWORD}"kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOFapiVersion: mongodb.com/v1kind: MongoDBUsermetadata: name: mdb-userspec: username: mdb-user db: admin mongodbResourceRef: name: ${MDB_RESOURCE_NAME} passwordSecretKeyRef: name: mdb-user-password key: password roles: - name: readWrite db: sample_mflixEOF
6

로드 밸런싱 없이 검색 노드 의 인스턴스 하나를 배포 할 수 있습니다. 배포 하려면 다음 단계를 완료하세요.

  1. mdbc-rs(이)라는 MongoDBSearch 사용자 지정 리소스 만듭니다.

    이 리소스 검색 노드에 대한 CPU 및 메모리 리소스 요구 사항을 지정합니다. 이 사용자 지정 리소스 의 설정에 대해 자세히 학습하려면 MongoDB 검색 및 벡터 검색 설정을 참조하세요.

    kubectl apply --context "${K8S_CTX}" -n "${MDB_NS}" -f - <<EOFapiVersion: mongodb.com/v1kind: MongoDBSearchmetadata: name: ${MDB_RESOURCE_NAME}spec: # no need to specify source.mongodbResourceRef if MongoDBSearch CR has the same name as MongoDB CR # the operator infer it automatically resourceRequirements: limits: cpu: "3" memory: 5Gi requests: cpu: "2" memory: 3GiEOF
  2. MongoDBSearch 리소스 배포서버 완료될 때까지 기다립니다.

    MongoDBSearch 사용자 지정 리소스 적용 Kubernetes 연산자 검색 노드(pod) 배포를 시작합니다. 이 단계에서는 mdbc-rs 리소스의 상태 단계가 Running가 되어 MongoDB Community 복제본 세트 작동 가능함을 나타낼 때까지 실행을 일시 중지합니다.

    echo "Waiting for MongoDBSearch resource to reach Running phase..."kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait --for=jsonpath='{.status.phase}'=Running mdbs/mdb-rs --timeout=300s
7

MongoDBSearch 을 사용한 MongoDB 리소스 배포서버 성공적인 했는지 확인합니다.

echo "Waiting for MongoDB resource to reach Running phase..."kubectl --context "${K8S_CTX}" -n "${MDB_NS}" wait --for=jsonpath='{.status.phase}'=Running "mdb/${MDB_RESOURCE_NAME}" --timeout=400s
8

네임스페이스 파드에서 MongoDB 복제본 세트 멤버, Kubernetes Operator용 MongoDB 컨트롤러 및 검색 노드에 대해 실행 모든 파드를 확인합니다.

echo; echo "MongoDB resource"kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get "mdb/${MDB_RESOURCE_NAME}"echo; echo "MongoDBSearch resource"kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get mdbs/mdb-rsecho; echo "Pods running in cluster ${K8S_CTX}"kubectl --context "${K8S_CTX}" -n "${MDB_NS}" get pods

이제 MongoDB 엔터프라이즈 와 함께 사용할 MongoDB Search 및 Vector Search를 성공적으로 배포했으므로, MongoDB cluster 에 데이터를 추가하고, MongoDB Search 및 Vector Search 인덱스를 생성하고, 데이터에 대해 쿼리를 실행 . 자세한 학습은 MongoDB 검색 및 벡터 검색 설정을 참조하세요.

이 페이지 평가하기

이 페이지의 내용