File tree 3 files changed +136
-0
lines changed
3 files changed +136
-0
lines changed Original file line number Diff line number Diff line change
1
+ # vim:set ft=dockerfile:
2
+ FROM debian:jessie
3
+
4
+ # explicitly set user/group IDs
5
+ RUN groupadd -r postgres --gid=999 && useradd -r -g postgres --uid=999 postgres
6
+
7
+ RUN apt-get update && apt-get install -y git && rm -rf /var/lib/apt/lists/*
8
+
9
+ RUN apt-get update && apt-get install -y \
10
+ make \
11
+ gcc \
12
+ libreadline-dev \
13
+ bison \
14
+ flex \
15
+ zlib1g-dev \
16
+ && rm -rf /var/lib/apt/lists/*
17
+
18
+ RUN mkdir /pg
19
+ RUN chown postgres:postgres /pg
20
+
21
+ USER postgres
22
+
23
+ WORKDIR /pg
24
+ ENV CFLAGS -O0
25
+ RUN git clone -b master https://github.com/postgrespro/postgres_cluster.git --depth 1
26
+
27
+ WORKDIR /pg/postgres_cluster
28
+ RUN ./configure --enable-cassert --enable-debug --prefix /usr/local
29
+ RUN make -j 4
30
+ USER root
31
+ RUN make install
32
+ RUN make -C contrib/raftable install
33
+ RUN make -C contrib/mmts install
34
+
35
+ RUN mkdir -p /var/run/postgresql && chown -R postgres /var/run/postgresql
36
+
37
+ ENV PATH /usr/local/bin:$PATH
38
+ ENV PGDATA /var/run/postgresql/data
39
+
40
+ COPY docker-entrypoint.sh /
41
+
42
+ USER postgres
43
+ ENTRYPOINT ["/docker-entrypoint.sh" ]
44
+
45
+ EXPOSE 5432
46
+ EXPOSE 5431
47
+ CMD ["postgres" ]
Original file line number Diff line number Diff line change
1
+ version : ' 2'
2
+
3
+ networks :
4
+ clusternet :
5
+ driver : bridge
6
+ ipam :
7
+ driver : default
8
+ config :
9
+ - subnet : 10.0.0.0/24
10
+
11
+ services :
12
+ node1 :
13
+ build : .
14
+ networks :
15
+ clusternet :
16
+ ipv4_address : 10.0.0.10
17
+ environment :
18
+ NODEID : ' 1'
19
+ CONNS : ' dbname=postgres host=10.0.0.10 port=5432,dbname=postgres host=10.0.0.20 port=5432,dbname=postgres host=10.0.0.30 port=5432'
20
+ PEERS : ' 1:10.0.0.10:5431,2:10.0.0.20:5431,3:10.0.0.30:5431'
21
+ ports :
22
+ - " 5432:5432"
23
+ - " 5431:5431"
24
+ node2 :
25
+ build : .
26
+ networks :
27
+ clusternet :
28
+ ipv4_address : 10.0.0.20
29
+ environment :
30
+ NODEID : ' 2'
31
+ CONNS : ' dbname=postgres host=10.0.0.10 port=5432,dbname=postgres host=10.0.0.20 port=5432,dbname=postgres host=10.0.0.30 port=5432'
32
+ PEERS : ' 1:10.0.0.10:5431,2:10.0.0.20:5431,3:10.0.0.30:5431'
33
+ ports :
34
+ - " 5434:5432"
35
+ - " 5433:5431"
36
+ node3 :
37
+ build : .
38
+ networks :
39
+ clusternet :
40
+ ipv4_address : 10.0.0.30
41
+ environment :
42
+ NODEID : ' 3'
43
+ CONNS : ' dbname=postgres host=10.0.0.10 port=5432,dbname=postgres host=10.0.0.20 port=5432,dbname=postgres host=10.0.0.30 port=5432'
44
+ PEERS : ' 1:10.0.0.10:5431,2:10.0.0.20:5431,3:10.0.0.30:5431'
45
+ ports :
46
+ - " 5436:5432"
47
+ - " 5435:5431"
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+ set -e
3
+
4
+ mkdir -p " $PGDATA "
5
+ chmod 700 " $PGDATA "
6
+ chown -R postgres " $PGDATA "
7
+
8
+ chmod g+s /run/postgresql
9
+ chown -R postgres /run/postgresql
10
+
11
+ initdb
12
+
13
+ cat >> " $PGDATA /pg_hba.conf" << -EOF
14
+ host all all 0.0.0.0/0 trust
15
+ local replication all trust
16
+ host replication all 0.0.0.0/0 trust
17
+ EOF
18
+
19
+ cat >> " $PGDATA /postgresql.conf" << -EOF
20
+ listen_addresses = '*'
21
+ unix_socket_directories = ''
22
+ port = 5432
23
+ max_prepared_transactions = 200
24
+ max_connections = 200
25
+ max_worker_processes = 100
26
+ wal_level = logical
27
+ fsync = off
28
+ max_wal_senders = 10
29
+ wal_sender_timeout = 0
30
+ max_replication_slots = 10
31
+ shared_preload_libraries = 'raftable,multimaster'
32
+ multimaster.workers = 10
33
+ multimaster.queue_size = 10485760 # 10mb
34
+ multimaster.node_id = $NODEID
35
+ multimaster.conn_strings = '$CONNS '
36
+ multimaster.use_raftable = true
37
+ multimaster.ignore_tables_without_pk = true
38
+ raftable.id = $NODEID
39
+ raftable.peers = '$PEERS '
40
+ EOF
41
+
42
+ " $@ "
You can’t perform that action at this time.
0 commit comments