其他分享
首页 > 其他分享> > yugabyte docker-compose 运行试用

yugabyte docker-compose 运行试用

作者:互联网

以前运行yugabyte 使用的是yb-docker-ctl,现在直接可以方便的使用docker-compose 运行了

pull image

docker pull yugabytedb/yugabyte

docker-compose file 准备

version: '2'
services:
  yb-master:
      image: yugabytedb/yugabyte:latest
      container_name: yb-master-n1
      command: [ "/home/yugabyte/bin/yb-master", 
                "--fs_data_dirs=/mnt/disk0,/mnt/disk1", 
                "--master_addresses=yb-master-n1:7100", 
                "--replication_factor=1"]
      ports:
      - "7000:7000"
      environment:
        SERVICE_7000_NAME: yb-master
  yb-tserver:
      image: yugabytedb/yugabyte:latest
      container_name: yb-tserver-n1
      command: [ "/home/yugabyte/bin/yb-tserver", 
                "--fs_data_dirs=/mnt/disk0,/mnt/disk1",
                "--start_pgsql_proxy", 
                "--tserver_master_addrs=yb-master-n1:7100"]
      ports:
      - "9042:9042"
      - "6379:6379"
      - "5433:5433"
      - "9000:9000"
      environment:
        SERVICE_5433_NAME: ysql
        SERVICE_9042_NAME: ycql
        SERVICE_6379_NAME: yedis
        SERVICE_9000_NAME: yb-tserver
      depends_on:
      - yb-master
  yb-tserver2:
      image: yugabytedb/yugabyte:latest
      container_name: yb-tserver-n2
      command: [ "/home/yugabyte/bin/yb-tserver", 
                "--fs_data_dirs=/mnt/disk0,/mnt/disk1",
                "--start_pgsql_proxy", 
                "--tserver_master_addrs=yb-master-n1:7100"]
      ports:
      - "9043:9042"
      - "6380:6379"
      - "5434:5433"
      - "9001:9000"
      environment:
        SERVICE_5433_NAME: ysql
        SERVICE_9042_NAME: ycql
        SERVICE_6379_NAME: yedis
        SERVICE_9000_NAME: yb-tserver
      depends_on:
      - yb-master

启动&&测试

docker-compose up -d

效果

 

 


 

 
docker-compose exec yb-master bash -c "YB_ENABLED_IN_POSTGRES=1 FLAGS_pggate_master_addresses=yb-master-n1:7100 /home/yugabyte/postgres/bin/initdb -D /tmp/yb_pg_initdb_tmp_data_dir -U postgres"

效果

docker-compose exec yb-master bash -c "YB_ENABLED_IN_POSTGRES=1 FLAGS_pggate_master_addresses=yb-master-n1:7100 /home/yugabyte/postgres/bin/initdb -D /tmp/yb_pg_initdb_tmp_data_dir -U postgres" 
The files belonging to this database system will be owned by user "root".
This user must also own the server process.
In YugaByte DB, setting LC_COLLATE to C and all other locale settings to en_US.UTF-8 by default. Locale support will be enhanced as part of addressing https://github.com/YugaByte/yugabyte-db/issues/1557The database cluster will be initialized with locales
  COLLATE: C
  CTYPE: en_US.UTF-8
  MESSAGES: en_US.UTF-8
  MONETARY: en_US.UTF-8
  NUMERIC: en_US.UTF-8
  TIME: en_US.UTF-8
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
creating directory /tmp/yb_pg_initdb_tmp_data_dir ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... I0717 07:19:59.569082 71 mem_tracker.cc:250] MemTracker: hard memory limit is 3.276620 GB
I0717 07:19:59.569211 71 mem_tracker.cc:252] MemTracker: soft memory limit is 2.785127 GB
I0717 07:19:59.569696 72 async_initializer.cc:73] Starting to init ybclient
I0717 07:19:59.573350 72 async_initializer.cc:77] Successfully built ybclient
W0717 07:19:59.590526 77 reactor.cc:380] pggate_ybclient_R000: Client call yb.master.MasterService.IsInitDbDone has no timeout set for connection id: { remote: 172.19.0.2:7100 idx: 0 protocol: 0x00007f3d3ce57cd8 -> tcp }
ok
performing post-bootstrap initialization ... I0717 07:20:09.756260 117 mem_tracker.cc:250] MemTracker: hard memory limit is 3.276620 GB
I0717 07:20:09.756646 117 mem_tracker.cc:252] MemTracker: soft memory limit is 2.785127 GB
I0717 07:20:09.757355 118 async_initializer.cc:73] Starting to init ybclient
I0717 07:20:09.760594 118 async_initializer.cc:77] Successfully built ybclient
 
psql -U postgres -h 127.0.0.1 -p 5433

显示数据库

\l
 

效果

 

 
CREATE TABLE users (
    id SERIAL PRIMARY KEY,
    name text
);

说明

以上只是简单的测试,好消息是yugabyte 的企业特性也已经开源可以直接免费使用了,很看好的项目

参考资料

https://docs.yugabyte.com/latest/deploy/docker/docker-compose/

标签:compose,07,SERVICE,yb,yugabyte,master,docker
来源: https://www.cnblogs.com/rongfengliang/p/11201447.html