[root@wcbpg ~]# docker commit centos76pg wcbcentos76:1.0 sha256:6877e73a201823a8cb4bd446e4657d55c774b542a70f18695a8310ee5f0badf5 [root@wcbpg ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE wcbcentos76 1.0 6877e73a2018 6 seconds ago 1.9GB wcbpg 1.0 988fc4d35414 32 minutes ago 1.9GB centos 7.6.1810 f1cb7c7d58b7 2 years ago 202MB #创建CentOS容器 [root@wcbpg ~]#docker run -d --name wcbpg -h wcbpg -p 15432-15439:5432-5439 -v /sys/fs/cgroup:/sys/fs/cgroup --privileged=true wcbcentos76:1.0 /usr/sbin/init b36fc6d4972ca0f178d626a9ff09c67d6fd491fdf6e9159472671f3e33eaadc3 [root@wcbpg ~]# docker exec -it wcbpg bash #在容器内安装依赖 [root@wcbpg /]# yum install -y cmake make gcc zlib gcc-c++ perl readline readline-devel zlib zlib-devel perl python36 tcl openssl ncurses-devel openldap pam #删除已存在的PG,如果没有安装则不用删除 [root@wcbpg /]#yum remove -y postgresql* && rm -rf /var/lib/pgsql && rm -rf /usr/pgsql* && userdel -r postgres && groupdel postgres [root@wcbpg /]#yum install -y sysbench #安装yum源 [root@wcbpg /]# yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm #查看PG版本 [root@wcbpg /]# yum repolist all | grep pgdg [root@wcbpg /]# yum repolist enabled | grep pgdg #安装PG13 [root@wcbpg /]# yum install -y postgresql13 postgresql13-server #验证 [root@wcbpg /]# rpm -aq| grep postgres postgresql13-13.5-1PGDG.rhel7.x86_64 postgresql13-libs-13.5-1PGDG.rhel7.x86_64 postgresql13-server-13.5-1PGDG.rhel7.x86_64 #添加环境变量 [root@wcbpg /]# echo "export PATH=/usr/pgsql-13/bin:$PATH" >> /etc/profile #初始化PG数据库 [root@wcbpg /]# /usr/pgsql-13/bin/postgresql-13-setup initdb Initializing database ... OK [root@wcbpg /]#systemctl enable postgresql-13 [root@wcbpg /]#systemctl start postgresql-13 [root@wcbpg /]#systemctl status postgresql-13 #登录PG数据库 [root@wcbpg /]# su - postgres -bash-4.2$ psql psql (13.5) Type "help" for help.



