GithubHelp home page GithubHelp logo

tonnycao / dispsql Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wooddeep/dispsql

0.0 0.0 0.0 10 KB

基于citusdata:v8.1制作的docker镜像,可用于搭建跨物理节点的分布式postgres数据库(因为官方的docker镜像只能在一个物理节点上启动分布式postgres)。

License: Apache License 2.0

Shell 49.34% Dockerfile 50.66%

dispsql's Introduction

1. 简述dispsql

基于citusdata:v8.1制作的docker镜像,可用于搭建跨物理节点的分布式postgres数据库(因为官方的docker镜像只能在一个物理节点上启动分布式postgres)。

2. 生成镜像

docker build . -t dispsql:v0.0.1

2. 运行分布式postgres

3.1 运行主控节点coordinator(所在ip:192.168.140.95)

docker run -d -p 9700:9700 dispsql:v0.0.1

3.2 运行workder(所在ip:192.168.140.94)

docker run -d -p 9701:9700 dispsql:v0.0.1

3.3 往coordinator中添加worker

docker exec -it <coordinator_container_id> psql -p 9700 -c "select master_add_node(<worker_ip>, 9701);"

docker exec -it 85a3007ccda7 psql -p 9700 -c "select master_add_node('192.168.140.94', 9701);" ## 地址为docker网桥的地址

3.4 数据库操作

查询工作节点

docker exec -it <coordinator_container_id> psql -p 9700 -c "select * from master_get_active_worker_nodes();"

docker exec -it 85a3007ccda7 psql -p 9700 -c "select * from master_get_active_worker_nodes();"

连接主控节点

psql -p 9700 -h 192.168.140.95 -U postgres -d postgres

建表

CREATE TABLE test ( id bigint NOT NULL, name text NOT NULL );

ALTER TABLE test ADD PRIMARY KEY (id);

表分片

SELECT create_distributed_table('test', 'id');

插入数据

insert into test(id, name) values (1, 'lihan');

连接工作接地

psql -p 9700 -h 192.168.140.94 -U postgres -d postgres #可以查询分片的数据

dispsql's People

Contributors

wooddeep avatar niutourenqz avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.