通过下载docker镜像部署milvus(2.4.6)
Os:Centos 7
milvus:2.4.6
Python:3.6.5
1.查看docker和docker-compose版本
[root@host134 milvus]# docker -v
Docker version 26.1.4, build 5650f9b
[root@host134 milvus]# docker-compose -v
docker-compose version 1.29.2, build unknown
安装docker的方法如下:
https://www.cnblogs.com/hxlasky/p/18343441
2.准备目录
mkdir -p /soft/milvus ##docker imgae存放目录
mkdir -p /home/middle/milvus ##安装部署目录
3.下载docker镜像
下载后的文件存放在 /soft/milvus 目录
[root@host135 soft]# ls -1
attu2.4.6.tar.gz
etcd.tar.gz
milvus2.4.6.tar.gz
minio.tar.gz
4.下载docker-compose.yml
到milvus项目地址下载文件
https://github.com/milvus-io/milvus/releases/tag/v2.4.6
如下图所识
或是通过wget命令下载
进入到milvus目录执行命令
# CPU单机版
cd /home/middle/milvus
wget https://github.com/milvus-io/milvus/releases/download/v2.4.6/milvus-standalone-docker-compose.yml -O docker-compose.yml
# GPU单机版
cd /home/middle/milvus
wget https://github.com/milvus-io/milvus/releases/download/v2.4.6/milvus-standalone-docker-compose-gpu.yml -O docker-compose.yml
下载安装文件,注意这里的路径版本是v2.4.6,根据自己实际情况选择CPU和GPU版本,不清楚的话就选CPU版本.
也可以其他地方下载后上传到服务器
5.下载 milvus.yml 文件
进入到milvus目录执行
cd /home/middle/milvus
# 注意改成自己对应的milvus版本号
wget https://raw.githubusercontent.com/milvus-io/milvus/v2.4.6/configs/milvus.yaml
报错误:
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8002::154|:443... failed: Network is unreachable.
解决办法:
查询raw.githubusercontent.com的真实IP
在 https://www.ipaddress.com/ 查询raw.githubuercontent.com的真实IP.
raw.githubusercontent.com has IPv4 address 185.199.108.133
raw.githubusercontent.com has IPv4 address 185.199.109.133
raw.githubusercontent.com has IPv4 address 185.199.110.133
raw.githubusercontent.com has IPv4 address 185.199.111.133
修改hosts
在/etc/hosts/中绑定查到的host,例如:
185.199.108.133 raw.githubusercontent.com
下载好后,确保该文件位于milvus工作目录下,然后编辑该文件,找到其中的 common > security > authorizationEnabled 并将其设置为true
也可以其他地方下载后上传到服务器
若这里没有下载配置文件的话,先启动容器,然后把容器里的配置文件拷贝出来,然后修改docker-compose.yml,添加外放到宿主机的配置项目
1.拷贝容器里的配置文件到本地目录
docker cp a8fef21de8c3:/milvus/configs/milvus.yaml /home/middle/milvus/
2.docker-compose.yml添加持久化配置项目
- ${DOCKER_VOLUME_DIRECTORY:-.}/milvus.yaml:/milvus/configs/milvus.yaml
3.重新部署
cd /home/middle/milvus
docker-compose down
docker-compose up -d
4.尝试修改配置文件
5.修改配置文件后需要重启才生效
docker-compose stop standalone
docker-compose start standalone
6.登录容器查看修改是否生效
docker exec -ti milvus-standalone /bin/bash
6.编辑docker-compose.yml文件
[root@host135 milvus]# more docker-compose.yml
version: '3.5'
services:
etcd:
container_name: milvus-etcd
image: quay.io/coreos/etcd:v3.5.5
environment:
- ETCD_AUTO_COMPACTION_MODE=revision
- ETCD_AUTO_COMPACTION_RETENTION=1000
- ETCD_QUOTA_BACKEND_BYTES=4294967296
- ETCD_SNAPSHOT_COUNT=50000
volumes:
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
healthcheck:
test: ["CMD", "etcdctl", "endpoint", "health"]
interval: 30s
timeout: 20s
retries: 3
minio:
container_name: milvus-minio
image: minio/minio:RELEASE.2023-03-20T20-16-18Z
environment:
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
ports:
- "9001:9001"
- "9000:9000"
volumes:
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
command: minio server /minio_data --console-address ":9001"
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
interval: 30s
timeout: 20s
retries: 3
standalone:
container_name: milvus-standalone
image: milvusdb/milvus:v2.4.6
command: ["milvus", "run", "standalone"]
security_opt:
- seccomp:unconfined
environment:
ETCD_ENDPOINTS: etcd:2379
MINIO_ADDRESS: minio:9000
volumes:
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
- ${DOCKER_VOLUME_DIRECTORY:-.}/milvus.yaml:/milvus/configs/milvus.yaml
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
interval: 30s
start_period: 90s
timeout: 20s
retries: 3
ports:
- "19530:19530"
- "9091:9091"
depends_on:
- "etcd"
- "minio"
attu:
container_name: attu
image: zilliz/attu:v2.4.6
environment:
MILVUS_URL: milvus-standalone:19530
ports:
- "8000:3000"
depends_on:
- "standalone"
networks:
default:
name: milvus
a.红色部分为新增
b.这里的etcd端口是没有暴露给到容器外部的,这样的话就无法使用birdwatcher查看etcd里面的内容了,如需要暴露的话,可以参考如下连接:
https://www.cnblogs.com/hxlasky/p/18542045
7.加载镜像cd到milvus文件夹下,Docker加载镜像.
cd到镜像存放的目录
[root@host134 milvus]# cd /soft/milvus_docker_image/2.4.6
[root@host135 2.4.6]# docker load -i milvus2.4.6.tar.gz
[root@host135 2.4.6]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
<none> <none> 636269526977 3 weeks ago 1.79GB
打标签
[root@host135 2.4.6]# docker tag 636269526977 milvusdb/milvus:v2.4.6
[root@host134 milvus]#docker load -i attu2.4.6.tar.gz
[root@host135 2.4.6]# docker tag 3d15903f4290 zilliz/attu:v2.4.6
[root@host134 milvus]#docker load -i etcd.tar.gz
Loaded image: quay.io/coreos/etcd:v3.5.5
[root@host134 milvus]#docker load -i minio.tar.gz
Loaded image: minio/minio:RELEASE.2023-03-20T20-16-18Z
8.查看镜像
[root@host135 milvus]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
zilliz/attu v2.4.6 3d15903f4290 7 days ago 293MB
milvusdb/milvus v2.4.6 636269526977 3 weeks ago 1.79GB
minio/minio RELEASE.2023-03-20T20-16-18Z 400c20c8aac0 16 months ago 252MB
quay.io/coreos/etcd v3.5.5 673f29d03de9 23 months ago 182MB
9.修改日志级别
配置文件:milvus.yaml
这里我修改日志级别为:warn
log:
level: warn # Only supports debug, info, warn, error, panic, or fatal. Default 'info'.
file:
rootPath: # root dir path to put logs, default "" means no log file will print. please adjust in embedded Milvus:
/tmp/milvus/logs
maxSize: 300 # MB
maxAge: 10 # Maximum time for log retention in day.
maxBackups: 20
format: text # text or json
stdout: true # Stdout enable or not
9.启动镜像
[root@host135 milvus]# cd /home/middle/milvus
[root@host135 milvus]# docker-compose up -d
或是通过如下方式启动
[root@middle milvus]# docker-compose -f /home/middle/milvus/docker-compose.yml up -d
10.登录attu
http://192.168.1.135:8000
默认的用户和密码
root/Milvus
11.登录minio
http://192.168.1.135:9001/login
账号密码
MINIO_ACCESS_KEY: minioadmin
MINIO_SECRET_KEY: minioadmin
若使用了milvus-backup,备份文件会存储在backup目录
查询账号需要的权限(针对某个数据库设置)
Query
Search
ShowPartitions
DescribeAlias
DescribeCollection
ListAliases
ListDatabases
SelectOwnership
ShowCollections
SelectUser
12.重启动
进入到docker-compose目录
cd /home/middle/milvus
docker-compose stop
docker-compose start
[root@middle milvus]# cd /home/middle/milvus
[root@middle milvus]# docker-compose stop
Stopping attu ... done
Stopping milvus-standalone ... done
Stopping milvus-minio ... done
Stopping milvus-etcd ... done
[root@middle milvus]# docker-compose start
Starting etcd ... done
Starting minio ... done
Starting standalone ... done
Starting attu ... done