1 min read

快速使用容器安装OB数据库

背景

步骤

  • Docker
mkdir -p ob
mkdir -p obd/cluster

docker run --name ob-test
           -e MODE=slim \
           -d \
           -e OB_TENANT_PASSWORD=PWD8848 \
           -p 2881:2881 \
           -v $PWD/ob:/root/ob \
           -v $PWD/obd/cluster:/root/.obd/cluster \
           -d registry.cn-shenzhen.aliyuncs.com/shuhui/oceanbase-ce:4.2.1.10-110010012025041414

  • docker-compose
version: '3.8'
services:
  nbcb_ob:
    image: registry.cn-shenzhen.aliyuncs.com/shuhui/oceanbase-ce:4.2.1.10-110010012025041414
    container_name: ob-test
    restart: unless-stopped
    environment:
      - MODE=slim
      - OB_TENANT_PASSWORD=PWD8848
    ports:
      - "2881:2881"
    volumes:
      - ./ob:/root/ob
      - ./obd/cluster:/root/.obd/cluster

CLI 验证

# mysql -h 127.0.0.1 -P 2881 -uroot@test -pPWD8848
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3221487641
Server version: 5.7.25 OceanBase_CE 4.2.1.10 (r110010012025041414-1fd6a67001bff18ca20ac2a6f1e174eef10baa62) (Built Apr 14 2025 14:28:39)

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

参考引用