首页 > 其他分享 >docker 安装 postgres 15.1

docker 安装 postgres 15.1

时间:2022-12-23 11:14:29浏览次数:49  
标签:02 15.1 12 postgres UTC 23 2022 docker

docker拉取镜像: docker pull postgres:15.1 创建文件夹,以及启动images

创建文件夹:mkdir -p /opt/docker/postgres
docker run --name postgres \
    -e POSTGRES_PASSWORD=password \
    -p 5432:5432 \
    -v /opt/docker/postgres:/var/lib/postgresql/data \
    -d postgres:latest 
    
    持久化创建docker容器
    docker run --name postgres \
    --restart=always \
    -e POSTGRES_PASSWORD=password \
    -p 5432:5432 \
    -v /data/postgresql:/var/lib/postgresql/data \
    -d postgres:15.1
    un: 创建并运行一个容器;

 --restart=always 表示容器退出时,docker会总是自动重启这个容器;
–name: 指定创建的容器的名字;
-e POSTGRES_PASSWORD=password: 设置环境变量,指定数据库的登录口令为password;
-p 5432:5432: 端口映射将容器的5432端口映射到外部机器的5432端口;

-v  /data/postgresql:/var/lib/postgresql/data   将运行镜像的/var/lib/postgresql/data目录挂载到宿主机/data/postgresql目录
-d postgres:11.4: 指定使用postgres:11.4作为镜像。
启动容器查看启动日志:
[root@128 postgres]# docker ps
CONTAINER ID   IMAGE                COMMAND                  CREATED         STATUS         PORTS                                                  NAMES
d1719ff15b21   postgres:latest      "docker-entrypoint.s…"   6 minutes ago   Up 6 minutes   0.0.0.0:5432->5432/tcp, :::5432->5432/tcp              postgres
b4e746e59cfc   mysql:8.0            "docker-entrypoint.s…"   17 hours ago    Up 17 hours    33060/tcp, 0.0.0.0:3103->3306/tcp, :::3103->3306/tcp   slaver1
59d0ba2f9ba1   mysql:8.0            "docker-entrypoint.s…"   17 hours ago    Up 17 hours    33060/tcp, 0.0.0.0:3102->3306/tcp, :::3102->3306/tcp   slaver
fce67889be45   mysql:8.0            "docker-entrypoint.s…"   17 hours ago    Up 17 hours    33060/tcp, 0.0.0.0:3101->3306/tcp, :::3101->3306/tcp   master
fbbcd73697a1   nacos/nacos-server   "bin/docker-startup.…"   18 hours ago    Up 17 hours    0.0.0.0:8841->8848/tcp, :::8841->8848/tcp              nacos-8841
[root@128 postgres]# docker stop fbbcd73697a1
fbbcd73697a1
[root@128 postgres]# docker logs -f d1719ff15b21
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
initdb: hint: You can change this by editing pg_hba.conf or using the option -A, or --auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /var/lib/postgresql/data -l logfile start

waiting for server to start....2022-12-23 02:22:12.495 UTC [47] LOG:  starting PostgreSQL 15.1 (Debian 15.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-12-23 02:22:12.496 UTC [47] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-12-23 02:22:12.523 UTC [50] LOG:  database system was shut down at 2022-12-23 02:22:12 UTC
2022-12-23 02:22:12.541 UTC [47] LOG:  database system is ready to accept connections
 done
server started

/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*

waiting for server to shut down...2022-12-23 02:22:13.857 UTC [47] LOG:  received fast shutdown request
.2022-12-23 02:22:13.913 UTC [47] LOG:  aborting any active transactions
2022-12-23 02:22:13.917 UTC [47] LOG:  background worker "logical replication launcher" (PID 53) exited with exit code 1
2022-12-23 02:22:13.917 UTC [48] LOG:  shutting down
2022-12-23 02:22:13.919 UTC [48] LOG:  checkpoint starting: shutdown immediate
2022-12-23 02:22:13.925 UTC [48] LOG:  checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.006 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB
2022-12-23 02:22:13.930 UTC [47] LOG:  database system is shut down
 done
server stopped

PostgreSQL init process complete; ready for start up.

2022-12-23 02:22:14.000 UTC [1] LOG:  starting PostgreSQL 15.1 (Debian 15.1-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2022-12-23 02:22:14.050 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2022-12-23 02:22:14.050 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2022-12-23 02:22:14.051 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-12-23 02:22:14.057 UTC [60] LOG:  database system was shut down at 2022-12-23 02:22:13 UTC
2022-12-23 02:22:14.061 UTC [1] LOG:  database system is ready to accept connections
2022-12-23 02:27:14.127 UTC [58] LOG:  checkpoint starting: time
2022-12-23 02:28:52.266 UTC [58] LOG:  checkpoint complete: wrote 919 buffers (5.6%); 0 WAL file(s) added, 0 removed, 0 recycled; write=98.123 s, sync=0.002 s, total=98.140 s; sync files=251, longest=0.001 s, average=0.001 s; distance=4217 kB, estimate=4217 kB
防火墙中添加端口:
firewall-cmd --zone=public --add-port=5432/tcp --permanent
重新载入
firewall-cmd --reload

客户端连接:密码在创建的命令中,查看ip可以使用 IP add 命令来查看

 

 

 

标签:02,15.1,12,postgres,UTC,23,2022,docker
From: https://www.cnblogs.com/luo12828-foxmail/p/17000238.html

相关文章

  • Dockerfile介绍及常用保留指令
    从本文开始,咱们将介绍docker的另外一个技术点:dockerfile.我们来看看DockerFile相关的知识点,我们将怎么学习?1:DockerFile是什么?2:DockerFile构建过程解析3:常用的保留字指令......
  • Docker 架构演进之路
    转载:https://developer.aliyun.com/article/673009前言Docker已经推出了5年,在这5年中它极大的改变了互联网产品的架构,推进了新的产品开发、测试和运维方法。但是它自身也在......
  • Jenkins+Docker 一键自动化部署 SpringBoot 项目
    Jenkins+Docker一键自动化部署SpringBoot项目 本文章实现最简单全面的Jenkins+docker+springboot 一键自动部署项目,步骤齐全,少走坑路。环境:centos7+git(git......
  • Docker+Jenkins+Gitee+Maven构建后台jar包后配置SSH传送到服务器并执行指定命令
    场景Docker+Jenkins+Gitee+Maven项目配置jdk、maven、gitee等拉取代码并自动构建以及遇到的那些坑:https://blog.csdn.net/BADAO_LIUMANG_QIZHI/article/details/12839905......
  • lightdb数据库链接之postgresql_fdw
    FDW简介FDW(ForeignDataWrapper)是lightdb的一个插件。通过FDW,可以将远程pg数据库映射到本地(映射为server),将远程数据库table映射为本地的foreigntable。通过FDW......
  • Ubuntu:Docker 容器操作
    创建容器1.dockerrun[option]镜像名[向启动容器中传入的命令]常用可选说明-i表示以“交互模式”运行容器-t表示容器启动后会进入其命令行。加入这两个参数......
  • Ubuntu:Docker启动与停止
    安装完成Docker后,默认已经启动了docker服务,如需手动控制docker服务的启停,可执行如下命令启动dockersudoservicedockerstart停止dockersudoservicedockerstop......
  • Docker架构
    一三个基本概念镜像image:dooker镜像相当于一个root文件系统容器container:镜像和容器的关系相当于类和对象的关系。镜像是静态的定义,容器是镜像运行时的实体。容器......
  • docker的dockerfile案例nginx学习
    一、什么是DockerfileDockerfile是自动构建docker镜像的配置文件,将镜像构建过程通过指令的方式定义在Dockerfile中。配合​​dockerbuild​​命令行可以实现自动化的Docker......
  • nvidia-docker安装
    (1)确保NVIDIADrivers和Docker已经安装好$nvcc--version$docker(2)安装nvidia-docker(2.1)设置stable存储库和密钥#注意此步骤可能无法下载,需要手动去网页下载,......