当前位置:网站首页>PG运维篇--服务启停
PG运维篇--服务启停
2022-07-13 18:39:00 【51CTO】
pg启停
启库
(1)直接运行postgres进程启动
postgres -D /home/osdba/pgdata &
-D 用于指定数据目录,命令最后一个&表示后台执行
(2)使用pg_ctl命令启动
pg_ctl -D /home/osdba/pgdata start
停库
(1)直接向运行的postgres主进程发送signal信号,停止数据库
(2)使用pg_ctl命令停止数据库
停止数据库的三种模式
(1)smart shutdown
不允许新连接,等已有的连接全部结束后才关闭数据库。
(2)fast shutdown
快速关闭模式,不再允许新的连接,向所有活跃服务进程发送SIGTERM信号,让它们立即退出,等待所有子进程退出并关闭数据库。如果服务处于在线备份状态,将直接终止备份。
(3)immediate shutdown
立即关闭模式,主进程postgres向所有子进程发送SIGQUIT信号,并且立即退出,所有子进程也会立即退出。采用这种模式退出时,并不会妥善地关闭数据库系统,下次启动时数据库会重放wal日志进行恢复。
操作如下
pg_ctl工具
功能
(1)初始化数据库实例
(2)启动、终止、重启pg
(3)查看pg状态
(4)让数据库实例重新读取配置文件
(5)允许给一个指定的进程发送的信号
使用pg_ctl reload 命令和直接调用函数pg_reload_conf()本质也是发送SIGHUP命令给服务主进程。
单用户模式
指启动pg时加上 --single参数,这时pg进程不会进入后台服务模式,用于以下场景
(1)initdb阶段
(2)修复系统表
(3)当多用户模式不接受所有命令时,可以使用单用户模式连接到数据库
PG中一条记录事务年龄不能超过231,如果超过该范围,这条数据就会丢失,pg不允许这种情况发生,当记录的年龄距离231还有一千万的时候,日志中会有告警。如果不处理,还有一百万时,数据库服务器将自动禁止来自任何用户的连接。
这种情况下,只能把数据库启动到单用户模式下执行VACUUM命名来修复。
边栏推荐
- 泰山OFFICE技术讲座:奇怪的Times New Roman字体的高度
- 基于华为WAC双机VRRP热备份下旁挂三层组网隧道转发模式解决方案
- HJ8 合并表记录 HJ08
- LeetCode(剑指 Offer)- 45. 把数组排成最小的数
- 测试基础4
- Explain ebpf in simple terms | 7 core issues you need to understand
- 【深入浅出玩转FPGA8------亚稳态】
- Small program graduation project of wechat enterprise company (5) assignment
- 【深入浅出玩转FPGA学习7------基于FPGA的跨时钟域信号处理】
- How to turn off the dareu keyboard light
猜你喜欢

Wechat classroom appointment for applet completion works (6) opening defense ppt

从全球价值链视角看,京东云数智供应链对未来经济有何影响?

mySQL上的应用了解

解决GD32F20X支持包安装后打开官方例程无法识别芯片问题

Cat and dog classification vgg16 finetune

Win11本地用户和组怎么管理?Win11创建用户管理员的方法

1. 在 SAP ABAP 事物码 SEGW 里创建 SAP OData 项目

An XML file example

A simple form example

【Renesas RA6M4开发板之I2C(模拟)驱动ssd1306 OLED屏幕】
随机推荐
Fibonacci heap - Analysis and Implementation
Deeply uncover Alibaba cloud's asynchronous task capability of function computing
[unity] preliminary discussion
Binomial reactor principle and analysis
shell脚本学习记录
Small program graduation project of wechat enterprise company (1) development outline
Inclined stack - principle and Implementation
Golang handles web post, get request and string to JSON format conversion
不会真有人觉得聊天机器人难吧——使用BERT加载预训练模型得到中文句子向量
[I2C (Analog) drive ssd1306 OLED screen of Renesas ra6m4 development board]
Common DOS commands
Either retire, change careers, or change management. PS hasn't blogged for two months
Small program graduation project of wechat enterprise company (5) assignment
Brief discussion -- views on the management of technological transformation
Small program graduation project of wechat enterprise company (8) graduation project thesis template
Quick sorting · example 2
Wechat payment apiv3 unified callback interface encapsulation (H5, jsapi, H5, app, applet)
杰理之播 LINEIN 提示音以后可能出现死机【篇】
golang 处理web post、get请求以及string to json格式的转化
Install MySQL database in CentOS system