运行

编译和安装Milvus完成后,需要通过以下操作使用Milvus数据库。

  1. 激活Python虚拟环境。

    1
    conda activate milvus
    

  2. 启动etcd。

    可以将etcd的数据目录根据具体情况进行调整。

    1
    etcd --data-dir=/data/milvus/data/etcd-data/ &
    

    若启动没有失败,且回显信息如下所示则表示启动成功。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    [1] 346
    (milvus) [milvus@localhost ~]$ {"level":"info","ts":"2025-02-28T09:32:17.681+0800","caller":"etcdmain/etcd.go:72","msg":"Running: ","args":["etcd","--data-dir=/data1/milvus/etcd-data/"]}
    {"level":"info","ts":"2025-02-28T09:32:17.681+0800","caller":"embed/etcd.go:131","msg":"configuring peer listeners","listen-peer-urls":["http://localhost:2380"]}
    {"level":"info","ts":"2025-02-28T09:32:17.681+0800","caller":"embed/etcd.go:139","msg":"configuring client listeners","listen-client-urls":["http://localhost:2379"]}
    {"level":"info","ts":"2025-02-28T09:32:17.681+0800","caller":"embed/etcd.go:307","msg":"starting an etcd server","etcd-version":"3.5.0","git-sha":"946a5a6f2","go-version":"go1.16.3","go-os":"linux","go-arch":"arm64","max-cpu-set":320,"max-cpu-available":320,"member-initialized":false,"name":"default","data-dir":"/data1/milvus/etcd-data/","wal-dir":"","wal-dir-dedicated":"","member-dir":"/data1/milvus/etcd-data/member","force-new-cluster":false,"heartbeat-interval":"100ms","election-timeout":"1s","initial-election-tick-advance":true,"snapshot-count":100000,"snapshot-catchup-entries":5000,"initial-advertise-peer-urls":["http://localhost:2380"],"listen-peer-urls":["http://localhost:2380"],"advertise-client-urls":["http://localhost:2379"],"listen-client-urls":["http://localhost:2379"],"listen-metrics-urls":[],"cors":["*"],"host-whitelist":["*"],"initial-cluster":"default=http://localhost:2380","initial-cluster-state":"new","initial-cluster-token":"etcd-cluster","quota-size-bytes":2147483648,"pre-vote":true,"initial-corrupt-check":false,"corrupt-check-time-interval":"0s","auto-compaction-mode":"periodic","auto-compaction-retention":"0s","auto-compaction-interval":"0s","discovery-url":"","discovery-proxy":"","downgrade-check-interval":"5s"}
    {"level":"info","ts":"2025-02-28T09:32:17.740+0800","caller":"etcdserver/backend.go:81","msg":"opened backend db","path":"/data1/milvus/etcd-data/member/snap/db","took":"58.87735ms"}
    {"level":"info","ts":"2025-02-28T09:32:17.741+0800","caller":"etcdserver/raft.go:448","msg":"starting local member","local-member-id":"8e9e05c52164694d","cluster-id":"cdf818194e3a8c32"}
    {"level":"info","ts":"2025-02-28T09:32:17.741+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d switched to configuration voters=()"}
    {"level":"info","ts":"2025-02-28T09:32:17.741+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d became follower at term 0"}
    {"level":"info","ts":"2025-02-28T09:32:17.741+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"newRaft 8e9e05c52164694d [peers: [], term: 0, commit: 0, applied: 0, lastindex: 0, lastterm: 0]"}
    {"level":"info","ts":"2025-02-28T09:32:17.741+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d became follower at term 1"}
    {"level":"info","ts":"2025-02-28T09:32:17.742+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d switched to configuration voters=(10276657743932975437)"}
    {"level":"warn","ts":"2025-02-28T09:32:17.742+0800","caller":"auth/store.go:1220","msg":"simple token is not cryptographically signed"}
    {"level":"info","ts":"2025-02-28T09:32:17.742+0800","caller":"mvcc/kvstore.go:415","msg":"kvstore restored","current-rev":1}
    {"level":"info","ts":"2025-02-28T09:32:17.743+0800","caller":"etcdserver/quota.go:94","msg":"enabled backend quota with default value","quota-name":"v3-applier","quota-size-bytes":2147483648,"quota-size":"2.1 GB"}
    {"level":"info","ts":"2025-02-28T09:32:17.743+0800","caller":"etcdserver/server.go:843","msg":"starting etcd server","local-member-id":"8e9e05c52164694d","local-server-version":"3.5.0","cluster-version":"to_be_decided"}
    {"level":"info","ts":"2025-02-28T09:32:17.743+0800","caller":"etcdserver/server.go:728","msg":"started as single-node; fast-forwarding election ticks","local-member-id":"8e9e05c52164694d","forward-ticks":9,"forward-duration":"900ms","election-ticks":10,"election-timeout":"1s"}
    {"level":"info","ts":"2025-02-28T09:32:17.743+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d switched to configuration voters=(10276657743932975437)"}
    {"level":"info","ts":"2025-02-28T09:32:17.743+0800","caller":"membership/cluster.go:393","msg":"added member","cluster-id":"cdf818194e3a8c32","local-member-id":"8e9e05c52164694d","added-peer-id":"8e9e05c52164694d","added-peer-peer-urls":["http://localhost:2380"]}
    {"level":"info","ts":"2025-02-28T09:32:17.744+0800","caller":"embed/etcd.go:276","msg":"now serving peer/client/metrics","local-member-id":"8e9e05c52164694d","initial-advertise-peer-urls":["http://localhost:2380"],"listen-peer-urls":["http://localhost:2380"],"advertise-client-urls":["http://localhost:2379"],"listen-client-urls":["http://localhost:2379"],"listen-metrics-urls":[]}
    {"level":"info","ts":"2025-02-28T09:32:17.744+0800","caller":"embed/etcd.go:580","msg":"serving peer traffic","address":"127.0.0.1:2380"}
    {"level":"info","ts":"2025-02-28T09:32:17.744+0800","caller":"embed/etcd.go:552","msg":"cmux::serve","address":"127.0.0.1:2380"}
    {"level":"info","ts":"2025-02-28T09:32:18.442+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d is starting a new election at term 1"}
    {"level":"info","ts":"2025-02-28T09:32:18.442+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d became pre-candidate at term 1"}
    {"level":"info","ts":"2025-02-28T09:32:18.442+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d received MsgPreVoteResp from 8e9e05c52164694d at term 1"}
    {"level":"info","ts":"2025-02-28T09:32:18.442+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d became candidate at term 2"}
    {"level":"info","ts":"2025-02-28T09:32:18.442+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d received MsgVoteResp from 8e9e05c52164694d at term 2"}
    {"level":"info","ts":"2025-02-28T09:32:18.442+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"8e9e05c52164694d became leader at term 2"}
    {"level":"info","ts":"2025-02-28T09:32:18.442+0800","logger":"raft","caller":"etcdserver/zap_raft.go:77","msg":"raft.node: 8e9e05c52164694d elected leader 8e9e05c52164694d at term 2"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"etcdserver/server.go:2027","msg":"published local member to cluster through raft","local-member-id":"8e9e05c52164694d","local-member-attributes":"{Name:default ClientURLs:[http://localhost:2379]}","request-path":"/0/members/8e9e05c52164694d/attributes","cluster-id":"cdf818194e3a8c32","publish-timeout":"7s"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"embed/serve.go:98","msg":"ready to serve client requests"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"etcdserver/server.go:2476","msg":"setting up initial cluster version using v2 API","cluster-version":"3.5"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"etcdmain/main.go:47","msg":"notifying init daemon"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"etcdmain/main.go:53","msg":"successfully notified init daemon"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"membership/cluster.go:531","msg":"set initial cluster version","cluster-id":"cdf818194e3a8c32","local-member-id":"8e9e05c52164694d","cluster-version":"3.5"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"api/capability.go:75","msg":"enabled capabilities for version","cluster-version":"3.5"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"etcdserver/server.go:2500","msg":"cluster version is updated","cluster-version":"3.5"}
    {"level":"info","ts":"2025-02-28T09:32:18.443+0800","caller":"embed/serve.go:140","msg":"serving client traffic insecurely; this is strongly discouraged!","address":"127.0.0.1:2379"}
    

  3. 启动MinIO。

    可以将MinIO的数据目录根据具体情况进行调整。

    1
    minio server /data/milvus/data/minio-data/ &
    

    若启动没有失败,且回显信息如下所示则表示启动成功。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    Copyright: 2015-2025 MinIO, Inc.
    License: GNU AGPLv3 - https://www.gnu.org/licenses/agpl-3.0.html
    Version: RELEASE.2024-11-07T00-52-20Z (go1.23.3 linux/arm64)
    
    API: http://90.88.163.51:9000  http://172.17.0.1:9000  http://192.168.122.1:9000  http://127.0.0.1:9000
       RootUser: minioadmin
       RootPass: minioadmin
    
    WebUI: http://90.88.163.51:42551 http://172.17.0.1:42551 http://192.168.122.1:42551 http://127.0.0.1:42551
       RootUser: minioadmin
       RootPass: minioadmin
    
    CLI: https://min.io/docs/minio/linux/reference/minio-mc.html#quickstart
       $ mc alias set 'myminio' 'http://90.88.163.51:9000' 'minioadmin' 'minioadmin'
    
    Docs: https://docs.min.io
    WARN: Detected default credentials 'minioadmin:minioadmin', we recommend that you change these values with 'MINIO_ROOT_USER' and 'MINIO_ROOT_PASSWORD' environment variables
    

  4. 可选:若是有代理,需要先停止代理。

    1
    2
    3
    unset http_proxy
    unset https_proxy
    unset ftp_proxy
    

  5. 启动Milvus单机版。

    milvus run standalone

    若启动没有失败,且回显信息如下所示则表示启动成功。

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    2025/02/28 09:35:53 maxprocs: Leaving GOMAXPROCS=320: CPU quota undefined
    Set runtime dir at /run/milvus failed, set it to /tmp/milvus directory
    
        __  _________ _   ____  ______
       /  |/  /  _/ /| | / / / / / __/
      / /|_/ // // /_| |/ / /_/ /\ \
     /_/  /_/___/____/___/\____/___/
    
    Welcome to use Milvus!
    Version:   v2.4.5-dev
    Built:     Thu Dec 26 05:42:26 AM UTC 2024
    GitCommit: 60695bdb44
    GoVersion: go version go1.21.10 linux/arm64
    
    TotalMem: 538996178944
    UsedMem: 112807936
    
    open pid file: /tmp/milvus/standalone.pid
    lock pid file: /tmp/milvus/standalone.pid
    [2025/02/28 09:35:53.943 +08:00] [INFO] [roles/roles.go:307] ["starting running Milvus components"]
    

    或者:

    1
    ~/milvus/scripts/start_standalone.sh
    

    启动之后需要使用ps -ef | grep milvus命令查看是否启动成功,回显信息如下所示则表示启动成功。

    1
    2
    root      851035       1  4 09:38 pts/3    00:00:00 ./bin/milvus run standalone --run-with-subprocess
    root      851053  851035 13 09:38 pts/3    00:00:00 ./bin/milvus run standalone
    
    • 使用脚本启动或者关闭Milvus,需要先进入Milvus的安装目录下,脚本会识别当前目录,然后使能jemalloc等特性。在别的目录下,会启动Milvus失败。
    • 如果需要关闭Milvus,请使用以下命令:
      ~/milvus/scripts/stop.sh