Pg14生产环境镜像构建

docker run -itd --name pg14 -v e:\dockerdata\pg14:/tmp/vm -e POSTGRES_PASSWORD=Ice123456 postgres

sh -c 'echo "deb https://mirrors.cloud.tencent.com/postgresql/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
cat <<EOF> /etc/apt/sources.list
deb http://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free
deb http://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free
deb http://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free
deb http://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free
EOF
apt update && apt install -y apt-transport-https ca-certificates vim curl wget net-tools python3 python3-pip postgresql-plpython3-14 iproute2 inetutils-ping postgresql-14-auto-failover postgresql-14-dirtyread postgresql-14-mysql-fdw postgresql-14-pgaudit postgresql-14-pgcron postgresql-14-repack postgresql-14-repmgr postgresql-14-tds-fdw postgresql-14-wal2json pgbouncer

#compile
apt install -y build-essential libreadline-dev zlib1g-dev flex bison libxml2-dev libxslt-dev libssl-dev libxml2-utils xsltproc


curl https://install.citusdata.com/community/deb.sh | bash
apt-get -y install postgresql-14-citus-10.2 postgresql-14-pgcron


docker run -itd --name pg14_2 -e POSTGRES_PASSWORD=Ice123456 postgres

新版

docker run -it --name deb10 debian

cat < /etc/apt/sources.list deb http://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free deb http://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free EOF apt update && apt install -y apt-transport-https ca-certificates vim curl wget net-tools python3 python3-pip iproute2 inetutils-ping pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

基于citus

sh -c 'echo "deb https://mirrors.cloud.tencent.com/postgresql/repos/apt bullseye-pgdg main" > /etc/apt/sources.list.d/pgdg.list' cat < /etc/apt/sources.list deb http://mirrors.ustc.edu.cn/debian/ bullseye main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ bullseye-updates main contrib non-free deb http://mirrors.ustc.edu.cn/debian/ bullseye-backports main contrib non-free deb http://mirrors.ustc.edu.cn/debian-security/ bullseye-security main contrib non-free EOF

```bash
apt update && apt install -y apt-transport-https ca-certificates vim curl wget net-tools python3 python3-pip postgresql-plpython3-14 iproute2 inetutils-ping postgresql-14-auto-failover postgresql-14-dirtyread postgresql-14-mysql-fdw postgresql-14-pgaudit postgresql-14-pgcron postgresql-14-repack postgresql-14-repmgr pgbouncer rsync openssh-server


## 测试
```bash
docker network create ctnet
for h in ct1 ct2 ct3 ct4;do
echo $h;
docker run -itd --name $h --net ctnet --hostname $h -e POSTGRES_PASSWORD=Ice123456 mycitus:1.0;
done

#
for h in ct1 ct2 ct3 ct4;do
echo $h;
docker exec -it -u postgres $h psql -c "create database lhcz;"
docker exec -it -u postgres $h psql -c "create extension citus;" lhcz
docker exec -it -u postgres $h psql -c "create extension mysql_fdw;" lhcz
done
#修改pg_hba使其同网段可以免密访问
docker exec -it -u postgres ct1 bash
>vi ~/data/pg_hba.conf
顶部增加一行
host all all 172.22.0.2/24 trust
保存退出
>pg_ctl reload -D ~/data

docker exec -it -u postgres ct1 psql -c "select citus_set_coordinator_host('ct1',5432);" lhcz
docker exec -it -u postgres ct1 psql -c "select citus_add_secondary_node('ct4',5432,'ct1',5432,'default');" lhcz
docker exec -it -u postgres ct1 psql -c "select master_add_node('ct2',5432);" lhcz
docker exec -it -u postgres ct1 psql -c "select master_add_node('ct3',5432);" lhcz
docker exec -it -u postgres ct1 psql -c "select citus_get_active_worker_nodes();" lhcz

centos7版本

yum update -y
curl https://install.citusdata.com/community/rpm.sh | bash
yum install --installroot=/usr/loca/pgdb -y python3 python3-pip vim curl wget