milvus日常管理
1.创建用户
create user -u hxl -p Milvus
让需要在auut界面赋予账号权限
2.创建索引(命令交互模式)
milvus_cli >use database -db tb_hxl
milvus_cli > create index
Collection name (tb_car01, tb_car02, tb_car03, tb_car04, car, tb_car): tb_car
The name of the field to create an index for (id, vector, color, brand): vector
Index name: idx_n1
Index type (FLAT, IVF_FLAT, IVF_SQ8, IVF_PQ, RNSG, HNSW, ANNOY, AUTOINDEX, DISKANN, GPU_IVF_FLAT, GPU_IVF_PQ, SPARSE_INVERTED_INDEX, SPARSE_WAND, SCANN, STL_SORT, Trie, INVERTED, ) []: IVF_FLAT
Vector Index metric type (L2, IP, HAMMING, TANIMOTO, COSINE, ) []: L2
Index params nlist: 10
Status(code=0, message=)
Create index successfully!
milvus_cli > list indexes -c tb_car
+----+--------------+--------------+--------------+---------------+-----------------+
| | Field Name | Index Name | Index Type | Metric Type | Params |
+====+==============+==============+==============+===============+=================+
| 0 | vector | idx_n1 | IVF_FLAT | L2 | {'nlist': '10'} |
+----+--------------+--------------+--------------+---------------+-----------------+
说明:
1.nlist默认是:128
2.Vector Index metric type:
指定目标向量与查询向量之间距离度量的相似性算法。取值如下:
L2:全称是 Euclidean distance,指欧几里得距离,它计算向量之间的直线距离,所得的值越小,越与搜索值相似。L2在低维空间中表现良好,但是在高维空间中,由于维度灾难的影响,L2的效果会逐渐变差。
IP:全称为 Inner Product,是一种计算向量之间相似度的度量算法,它计算两个向量之间的点积(内积),所得值越大越与搜索值相似。
COSINE:余弦相似度(Cosine Similarity)算法,是一种常用的文本相似度计算方法。它通过计算两个向量在多维空间中的夹角余弦值来衡量它们的相似程度。所得值越大越与搜索值相似。
3.重新部署(做了持久化的数据不会丢失)
cd /home/middle/milvus
docker-compose down
docker-compose up -d
停掉后删除
[root@host135 milvus]# docker-compose down
Stopping attu ... done
Stopping milvus-standalone ... done
Stopping milvus-etcd ... done
Stopping milvus-minio ... done
Removing attu ... done
Removing milvus-standalone ... done
Removing milvus-etcd ... done
Removing milvus-minio ... done
Removing network milvus
重新创建
[root@host135 milvus]# docker-compose up -d
Creating network "milvus" with the default driver
Creating milvus-etcd ... done
Creating milvus-minio ... done
Creating milvus-standalone ... done
Creating attu ... done
查看启动的时间
[root@host135 milvus]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
cfd4105c212c zilliz/attu:v2.4.6 "docker-entrypoint.s…" About a minute ago Up 59 seconds 0.0.0.0:8000->3000/tcp, :::8000->3000/tcp attu
4a0ccf674d8c milvusdb/milvus:v2.4.6 "/tini -- milvus run…" About a minute ago Up About a minute (health: starting) 0.0.0.0:9091->9091/tcp, :::9091->9091/tcp, 0.0.0.0:19530->19530/tcp, :::19530->19530/tcp milvus-standalone
0f4e9e402238 minio/minio:RELEASE.2023-03-20T20-16-18Z "/usr/bin/docker-ent…" About a minute ago Up About a minute (healthy) 0.0.0.0:9000-9001->9000-9001/tcp, :::9000-9001->9000-9001/tcp milvus-minio
2234968a714c quay.io/coreos/etcd:v3.5.5 "etcd -advertise-cli…" About a minute ago Up About a minute (healthy) 2379-2380/tcp milvus-etcd
或是使用如下命令
docker-compose down 停止所有容器,并删除容器(这样下次使用docker-compose up时就一定会是新容器了)
docker-compose up -d --force-recreate 使用 --force-recreate 可以强制重建容器(否则只能在容器配置有更改时才会重建容器)
4.查看milvus各组件日志
docker logs --tail=1000 attu
docker logs --tail=100 milvus-standalone
docker logs --tail=1000 milvus-etcd
docker logs --tail=1000 milvus-minio