mongod社区版 + mongot社区版,实现数据库+向量库检索等功能

部署目录层级

kotlin 复制代码
mongo
├── mongod
│   ├── data
│   ├── docker-compose.yml
│   ├── init.txt
│   ├── mongodb-community-server_8.2.1-ubi8.tar
│   ├── mongod.conf
│   └── sampledata.archive
└── mongot
    ├── data
    ├── docker-compose.yml
    ├── mongodb-community-search_0.54.0.tar
    ├── mongot.conf
    └── pwfile

部署 mongod社区版

创建文件 mongod.conf

yaml 复制代码
storage:
   dbPath: /data/db

net:
   port: 27017
   bindIp: 0.0.0.0

setParameter:
   searchIndexManagementHostAndPort: mongot-service:27028
   mongotHost: mongot-service:27028
   skipAuthenticationToSearchIndexManagementServer: false
   useGrpcForSearch: true


replication:
   replSetName: rs0

创建文件 init.txt

php 复制代码
# 进入shell
mongosh


# 查副本集状态
rs.status()


# 创建副本集
rs.initiate({
   _id: "rs0",
   members: [
     { _id: 0, host: "宿主机ip:27017" }
   ]
 });


# 建用户
db.getSiblingDB('admin').createUser({
   user: '数据库用户名',
   pwd: '数据库密码',
   roles: [{ role: 'root', db: 'admin' }]
});


use admin;

show users;

创建文件 docker-compose.yml

yaml 复制代码
services:
  mongod-service:
    user: root
    image: mongodb/mongodb-community-server:8.2.1-ubi8
    container_name: mongod
    command: 
         mongod --config /etc/mongod.conf 
    ports:
      - 27017:27017
    volumes:
      - ./data:/data/db
      - ./mongod.conf:/etc/mongod.conf:ro
      - /etc/hosts:/etc/hosts
    networks:
      - mongo-network
    healthcheck:
      test: ["CMD", "mongosh", "--eval", "db.adminCommand('ping')"]
      interval: 10s
      timeout: 5s
      retries: 5
      start_period: 30s

networks:
  mongo-network:
    name: mongo-network

启动

csharp 复制代码
docker-compose up -d
根据init.txt,进入容器,初始化

部署 mongot社区版

创建文件 mongot.conf

yaml 复制代码
syncSource:
   replicaSet:
      hostAndPort: "mongod-service:27017"
      username: 数据库用户名
      passwordFile: /mongot-community/pwfile
      authSource: admin
      tls: false
      readPreference: primaryPreferred
storage:
   dataPath: "/data/mongot"
server:
   grpc:
      address: "mongot-service:27028"
      tls:
         mode: "disabled"
metrics:
   enabled: true
   address: "mongot-service:9946"
healthCheck:
   address: "mongot-service:8080"
logging:
   verbosity: DEBUG

创建文件 pwfile

bash 复制代码
echo -n "数据库密码" > pwfile
chmod 400 pwfile

创建文件 docker-compose.yml

yaml 复制代码
services:
  mongot-service:
    user: root
    image: mongodb/mongodb-community-search:0.54.0
    container_name: mongot
    networks:
      - mongo-network
    volumes:
      - ./data:/data/mongot
      - ./mongot.conf:/mongot-community/config.default.yml
      - ./pwfile:/mongot-community/pwfile:ro
      - /etc/hosts:/etc/hosts
    ports:
      - 27028:27028
      - 9946:9946
      - 8080:8080
    healthcheck:
      test: ["CMD", "curl", "-f", "http://宿主机ip:8080/health"]
      interval: 30s
      timeout: 10s
      retries: 3

networks:
  mongo-network:
    name: mongo-network

启动

复制代码
docker-compose up -d

验证

ruby 复制代码
验证
https://www.mongodb.com/zh-cn/docs/atlas/atlas-vector-search/tutorials/vector-search-quick-start/?deployment-type=self#init-mongo.sh
相关推荐
q***333711 分钟前
SpringMVC新版本踩坑[已解决]
android·前端·后端
武子康13 分钟前
大数据-166 Apache Kylin 1.6 Streaming Cubing 实战:Kafka 到分钟级 OLAP
大数据·后端·apache kylin
回家路上绕了弯18 分钟前
彻底解决超卖问题:从单体到分布式的全场景技术方案
分布式·后端
8***293136 分钟前
能懂!基于Springboot的用户增删查改(三层设计模式)
spring boot·后端·设计模式
IT_陈寒1 小时前
Python高手都在用的5个隐藏技巧,让你的代码效率提升50%
前端·人工智能·后端
Qiuner1 小时前
Spring Boot 机制二:配置属性绑定 Binder 源码解析(ConfigurationProperties 全链路)
java·spring boot·后端·spring·binder
Victor3561 小时前
Redis(151)Redis的内存使用如何监控?
后端
Victor3561 小时前
Redis(150)Redis的性能瓶颈如何排查?
后端
豆浆whisky2 小时前
Go并发模式选择指南:找到最适合你项目的并发方案|Go语言进阶(19)
开发语言·后端·golang
Y***h18710 小时前
第二章 Spring中的Bean
java·后端·spring