qdrant安装方式很多,这篇文章先测试docker安装方式,也是最简单安装方式
规划为三节点机器
10.10.10.1
10.10.10.2
10.10.10.3
安装目录统一为/qdrant
1。安装docker
可以使用一键安装或者分布安装,这里直接一键安装,三台机器分别都需要安装
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
启动docker,并查看状态
sudo service docker start
systemctl status docker.service
设置docker开机自己启动
systemctl enable docker.service
2.下载qdrant镜像
直接按照官网操作就可以,每台节点操作相同
查看docker状态
sudo docker info
拉取镜像
docker pull qdrant/qdrant
3.配置第一台
然后再第一台创建好qdrant目录
mkdir /qdrant
cd /qdrant
进入目录创建配置文件和数据文件持久化目录
mkdir -p $(pwd)/path/to/
配置配置文件,配置集群参数
vi $(pwd)/path/to/config_001.yaml
cluster:
# Use `enabled: true` to run Qdrant in distributed deployment mode
enabled: true
# Configuration of the inter-cluster communication
p2p:
# Port for internal communication between peers
port: 6335
# Configuration related to distributed consensus algorithm
consensus:
# How frequently peers should ping each other.
# Setting this parameter to lower value will allow consensus
# to detect disconnected node earlier, but too frequent
# tick period may create significant network and CPU overhead.
# We encourage you NOT to change this parameter unless you know what you are doing.
tick_period_ms: 100
编写启动文件
vi qdrant01_start.sh
#!/bin/bash
nohup docker run -p 6333:6333 -p 6335:6335 -v $(pwd)/path/to/data:/qdrant/storage -v $(pwd)/path/to/config_001.yaml:/qdrant/config/production.yaml qdrant/qdrant ./qdrant --uri 'http://10.10.10.1:6335' &
#映射数据目录和配置文件
#$(pwd)/path/to/data -- /qdrant/storage 数据目录
#$(pwd)/path/to/config_001.yaml:/qdrant/config/production.yaml 配置文件production.yaml为配置覆盖文件
–uri 注册第一个启动节点,----bootstrap 添加其他节点到主节点,官网都有接受。
第一个节点启动成功后可以查看状态
curl GET 'http://10.10.10.1:6333/cluster' --header 'Content-Type: application/json'
{"result":{"status":"enabled","peer_id":4393184929800590349,"peers":{"4393184929800590349":{"uri":"http://10.10.10.1:6335/"}},"raft_info":{"term":2,"commit":6,"pending_operations":0,"leader":4393184929800590349,"role":"Leader","is_voter":true},"consensus_thread_status":{"consensus_thread_status":"working","last_update":"2023-04-20T09:07:34.062335053Z"},"message_send_failures":{}},"status":"ok","time":9.78e-6}
可看到集群信息成功
4 第二台操作
步骤雷同,只有部分命令和文件名需要调整,直接写操作
目录准备
mkdir /qdrant
cd /qdrant
mkdir -p $(pwd)/path/to/
配置文件准备
vi $(pwd)/path/to/config_002.yaml
cluster:
# Use `enabled: true` to run Qdrant in distributed deployment mode
enabled: true
# Configuration of the inter-cluster communication
p2p:
# Port for internal communication between peers
port: 6335
# Configuration related to distributed consensus algorithm
consensus:
# How frequently peers should ping each other.
# Setting this parameter to lower value will allow consensus
# to detect disconnected node earlier, but too frequent
# tick period may create significant network and CPU overhead.
# We encourage you NOT to change this parameter unless you know what you are doing.
tick_period_ms: 100
启动文件准备
vi qdrant02_start.sh
#!/bin/bash
nohup docker run -p 6333:6333 -p 6335:6335 -v $(pwd)/path/to/data:/qdrant/storage -v $(pwd)/path/to/config_002.yaml:/qdrant/config/production.yaml qdrant/qdrant ./qdrant --bootstrap 'http://10.10.10.1:6335' &
这里为–bootstrap ‘http://10.10.10.1:6335’ ,注册到第一个节点,就是主节点
- 第3台操作
与第二台基本一样
步骤雷同,只有部分命令和文件名需要调整,直接写操作
目录准备
mkdir /qdrant
cd /qdrant
mkdir -p $(pwd)/path/to/
配置文件准备
vi $(pwd)/path/to/config_003.yaml
cluster:
# Use `enabled: true` to run Qdrant in distributed deployment mode
enabled: true
# Configuration of the inter-cluster communication
p2p:
# Port for internal communication between peers
port: 6335
# Configuration related to distributed consensus algorithm
consensus:
# How frequently peers should ping each other.
# Setting this parameter to lower value will allow consensus
# to detect disconnected node earlier, but too frequent
# tick period may create significant network and CPU overhead.
# We encourage you NOT to change this parameter unless you know what you are doing.
tick_period_ms: 100
启动文件准备
vi qdrant02_start.sh
#!/bin/bash
nohup docker run -p 6333:6333 -p 6335:6335 -v $(pwd)/path/to/data:/qdrant/storage -v $(pwd)/path/to/config_003.yaml:/qdrant/config/production.yaml qdrant/qdrant ./qdrant --bootstrap 'http://10.10.10.1:6335' &
这里为–bootstrap ‘http://10.10.10.1:6335’ ,注册到第一个节点,就是主节点
最后查看集群信息
curl GET 'http://10.10.10.1:6333/cluster' --header 'Content-Type: application/json'
{"result":{"status":"enabled","peer_id":4393184929800590349,"peers":{"4393184929800590349":{"uri":"http://10.10.10.1:6335/"},"16109703143349695036":{"uri":"http://10.10.10.2:6335/"},"1298605932473601859":{"uri":"http://10.10.10.3:6335/"}},"raft_info":{"term":2,"commit":6,"pending_operations":0,"leader":4393184929800590349,"role":"Leader","is_voter":true},"consensus_thread_status":{"consensus_thread_status":"working","last_update":"2023-04-20T09:07:34.062335053Z"},"message_send_failures":{}},"status":"ok","time":9.78e-6}
可以看到目前集群状态正常 一共三个节点
源码安装与刀客类似 ,只是在安装单节点时候按照官网源码方式安装,后面改配置文件即可,
在创建集合时候可以指定分片数量和副本数量
PUT /collections/{collection_name}
{
"vectors": {
"size": 300,
"distance": "Cosine"
},
"shard_number": 6,
"replication_factor": 2,
}
shard_number为分片数量,replication_factor为副本数量,三节点建议分片为6,副本为2