环境:
OS:Centos 7
milvus:2.3.5
milvus-cli:1.0.0
1.在线安装
你可以使用 Python 包管理在线安装,注意 Python 版本要在 3.9 以上。在线安装只需要一条命令即可:
[root@host134 bin]# pip -V pip 23.0.1 from /usr/local/lib/python3.8/site-packages/pip (python 3.8) [root@host134 bin]# pip install milvus-cli ERROR: Ignored the following versions that require a different python version: 2.1.0 Requires-Python >=3.9; 2.1.0rc0 Requires-Python >=3.9; 2.1.1 Requires-Python >=3.9; 2.1.2 Requires-Python >=3.9; 2.1.3 Requires-Python >=3.9; 2.1.4 Requires-Python >=3.9; 2.2.0 Requires-Python >=3.9; 2.2.0rc0 Requires-Python >=3.9; 2.2.1 Requires-Python >=3.9; 2.2.2 Requires-Python >=3.9 ERROR: Could not find a version that satisfies the requirement grpcio==1.37.1 (from pymilvus) (from versions: none) ERROR: No matching distribution found for grpcio==1.37.1
这里需要安装python 3.9以上版本
[root@host134 Python-3.9.19]# python -V
Python 3.9.19
[root@host134 Python-3.9.19]# which milvus_cli
/usr/local/bin/milvus_cli
2.登录milvus
[root@host134 Python-3.9.19]# milvus_cli __ __ _ _ ____ _ ___ | \/ (_) |_ ___ _ ___ / ___| | |_ _| | |\/| | | \ \ / / | | / __| | | | | | | | | | | | |\ V /| |_| \__ \ | |___| |___ | | |_| |_|_|_| \_/ \__,_|___/ \____|_____|___| Milvus cli version: 1.0.0 Pymilvus version: 2.4.3 Learn more: https://github.com/zilliztech/milvus_cli. milvus_cli > 连接到服务器 milvus_cli > connect -uri http://192.168.1.134:19530 -t root:Milvus Connect Milvus successfully. +---------+---------------------+ | Address | 192.168.1.134:19530 | | Alias | default | +---------+---------------------+ milvus_cli > list databases +---------+ | db_name | +---------+ | default | | db_test | +---------+ milvus_cli > use database -db db_test Using database db_test successfully! milvus_cli > use database -db default Using database default successfully! milvus_cli > list collections ['mytest', 'hello_milvus']
##创建数据库
milvus_cli > create database -db db_hxl Create database db_hxl successfully! milvus_cli > list databases +---------+ | db_name | +---------+ | db_test | | db_hxl | | default | +---------+
3.创建集合
milvus_cli > use database -db db_hxl Using database db_hxl successfully! milvus_cli > create collection --help Usage: milvus_cli create collection [OPTIONS] Create collection. Example: create collection -c car -f id:INT64:primary_field -f vector:FLOAT_VECTOR:128 -f color:INT64:color -f brand:ARRAY:64:VARCHAR:128 -p id -A -d 'car_collection' Options: -c, --collection-name TEXT Collection name to specify alias. -p, --schema-primary-field TEXT Primary field name. -A, --schema-auto-id [Optional, Flag] - Enable auto id. -desc, --schema-description TEXT [Optional] - Description details. -d, --is-dynamic TEXT [Optional] - Collection schema supports dynamic fields or not. -level, --consistency-level TEXT [Optional] - Consistency level: Bounded,Session,Strong, Eventual . -f, --schema-field TEXT [Multiple] - FieldSchema. Usage is "<Name>:<DataType>:<Dim(if vector) or Description>", Array Type is <Name>:<DataTyp e>:<MaxCapacity>:<ElementDataType>(:<MaxLeng th>if Varchar) -s, --shards-num INTEGER [Optional] - Shards number --help Show this message and exit.
-c:集合名称
-f:自动名称,多个字段指定多个-f
-p:指定主键字段
-A:启用自增长ID
-desc:集合描述
-d: --is-dynamic TEXT
create collection -c tb_car01 -f id01:INT64:primary_field -f vector:FLOAT_VECTOR:128 -f color:INT64:color -f brand:INT64:brand -p id01 -d 'aaaa'
create collection -c tb_car02 -f id01:INT64:primary_field -f vector:FLOAT_VECTOR:128 -f color:INT64:color -f brand:INT64:brand -p id01 -A -d 'bbbb'
create collection -c tb_car03 -f id01:INT64:primary_field -f vector:FLOAT_VECTOR:128 -f color:INT64:color -f brand:INT64:brand -p id01 -A -desc 'kkkkk'
标签:cli,部署,db,Python,INT64,milvus,3.9 From: https://www.cnblogs.com/hxlasky/p/18349449