栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 系统运维 > 运维 > Linux

CentOS7容器内安装PG13

Linux 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

CentOS7容器内安装PG13

[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.
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/641828.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号