您的浏览器禁用了JavaScript(一种计算机语言,用以实现您与网页的交互),请解除该禁用,或者联系我们。[PostgreSQL济南峰会]:在Linux和Windows下PostgreSQL运维避坑 - 发现报告

在Linux和Windows下PostgreSQL运维避坑

2024-09-21类延良PostgreSQL济南峰会风***
AI智能总结
查看更多
在Linux和Windows下PostgreSQL运维避坑

P o s t g r e S Q L济 南 峰 会2 0 2 4 . 0 9 . 2 1 特别声明 本PPT所说的Linux,仅仅是如下三种Linux操作系统:•RHEL •Oracle Linux•SLES CONTENTS 在Linux下的运维注意点01.Lorem ipsum dolor sitamet,consecteturadipiscingelit 在Windows下的运维注意点02.Lorem ipsum dolor sitamet,consecteturadipiscingelit 怎么为PostgreSQL做贡献03.Lorem ipsum dolor sitamet,consecteturadipiscingelit 1.在RHEL8上建立的xfs无法在RHEL7上mount https://access.redhat.com/solutions/4582401问题: Can'tmountaXFSfilesystemcreatedinRHEL8onRHEL7WhentryingtomountaXFSfilesystemthatwascreatedinRHEL8onRHEL7,Igetthiserror:mount:wrongfstype,badoption,badsuperblockon/dev/sdN,missingcodepageorhelperprogram,orothererror. 决议:CreatethefilesystemwithoutthereflinkfeaturetouseaXFSfilesystembothinRHEL8andRHEL7: #mkfs.xfs-mreflink=0/dev/sdN 根源:ThishappensbecauseRHEL8metadatacontainsextrafieldswhichcannotbeproperlyhandledby RHEL7andpreviousreleases. RefertoCHAPTER5.RHEL8.0.0RELEASE-5.1.12.Filesystemsandstorage 2.在SUSE12上,SUSE12的进程数限制 在SUSE12上,SUSE12的进程数限制:SLES12SP2的linux上发生的问题,并不常见,但是给出了一些新的思路。现象是数据库进程达到300个左右时,就无法继续连接数据库了最终的原因是因为在SUSE12上增加了systemd的资源控制,其中默认参数:DefaultTasksMaxwasdefaultvalue(512).systemdlimitedmaximumnumberoftasksthatmaybecreatedintheunit.这个值会影响OS上的maxpid,将该参数设为无限制后解决该问题:修改/etc/systemd/system.conf设置DefaultTasksMax的值为‘infinity’,重启主机。参考自:https://blogs.oracle.com/database4cn/sles12-sp2%e4%b8%8a%e9%81%87%e5%88%b0ora-12518%3a-tns%3alistener-could-not-hand-off-client-connection%e9%94%99%e8%af%af 标题 Mounting XFS filesystem created onRHEL 9 fails on RHEL 8.6 (and older) and RHEL 7 https://access.redhat.com/solutions/7023563 Oracle Linux:Unable to Mount a xfs Filesystem Created on Oracle Linux 9 on Oracle Linux 7or 8 (Doc ID 2945343.1) Oracle Linux: How to Enable Big Timestamps Feature 'bigtime=1' for XFS Filesystems (DocID 2993572.1) 标题 bigtime的解释: # man mkfs.xfs -m global_metadata_optionsThese options specify metadata format options that either apply to the entire filesystem or aren't easily characterised by a specific functionality group. The validglobal_metadata_options are: This option enables filesystems that can handle inode timestamps fromDecember 1901 to July 2486, and quota timer expirations from January 1970 to July 2486.The value is either 0 to disable the feature, or 1 to enable large timestamps. If this feature is not enabled, the filesystem can only handle timestamps fromDecember 1901 to January 2038, and quota timers from January 1970 to February 2106. By default, mkfs.xfs will not enable this feature. If the option-m crc=0 is used,the large timestamp feature is not supported and is disabled. 标题 手工发出pg_ctl启停数据库与systemd去调用pg_ctl启停数据库的区别 两个知识点: 1)systemctl启动的PostgreSQL数据库,pg_ctl stop-m-f能关闭; 2)pg_ctl start的PostgreSQL数据库,systemctl stop停不掉; 请大家思考:这是PG的锅么? 大象说:这也怪我?? Oracle单机DB也有此现象,这其实是与systemd实现方式有关,跟哪种DB无关,见: Auto Startup/Shutdown Issue In RHEL 7.X UsingSystemctl After Manually Shutdown/StartDatabase (Doc ID 2401600.1) 标题 怎么看一个PG数据库实例是通过手工发起pg_ctlstart启动的还是用systemd机制启动的? 答案: cat/sys/fs/cgroup/systemd/system.slice/postgresql-12.service/tasks 看上面的结果有阿拉伯数字(这些数字是PG相关进程的ospid),就表示是由systemctl(systemd)机制启动的 标题 /etc/security/limits.conf中定义的资源限制对systemd机制启动的服务有效吗? 答案是:无效,这是两种不同的资源限制机制,可以说是井水不犯河水。 参考1: How to set limits for services in RHEL 7 and systemdhttps://access.redhat.com/solutions/1257953 Howto set limits(ulimit)for servicesrun by systemdhttps://access.redhat.com/solutions/1346533 查看新盘有无数据的命令适用场景: 工程师接到客户要求,$PGDATA原来在/opt目录下,由于业务增长导致数据量变大,因此,需要将$PGDATA迁移到更大的文件系统中。经过客户协调存储工程师,存储工程师为数据库服务器映射了一个/dev/sdh盘,并且客户对工程师说:就是这个sdh盘,你们用这个盘存放$PGDATA即可。那么问题来了:工程师应该用什么命令来确认这个sdh盘是空的,也就是用什么命令来确认这个sdh盘里边是没有数据的?答案: 使用hexdump/dev/sdh若是返回结果都是0000,就表示是空盘,如下是一个实际的例子: 新盘: # hexdump/dev/sdb 查看新盘有无数据的命令 hexdump会将相同的都是0的行标记为"*",所以即使全部读完,依旧只会显示: 已经被使用的盘:#hexdump/dev/sda https://access.redhat.com/solutions/790733 Tuning a Red Hat Enterprise Linux server for a resident PostgreSQL database https://access.redhat.com/solutions/790733 二、PG在Windows下安装的注意要点 为服务器选择认证过的Windows操作系统版本: 请参考微软windows操作系统(包括Server和Client)对硬件的认证列表(见下面的2个链接)Windowsserver端操作系统的认证列表----https://www.windowsservercatalog.com/WindowsClient端操作系统的认证列表----http://sysdev.microsoft.com/zh-CN/hardware/lpl/上述认证列表主要是服务器型号与Windows操作系统版本之间的兼容认证清单在实际环境中,请务必满足上述兼容认证清单。举例如下:浪潮TS860G3这款服务器,认证过的Windows操作系统版本是:https://www.windowsservercatalog.com/item.aspx?idItem=ad8e968a-c57b-d4e0-7f3e-367a7b18f676&bCatID=1282 选择PostgreSQL版本时注意支持的Windows版本 可以参考https://www.postgresql.org/download/windows/这个网址中有如下的截图 有如下两个注意点(均指64bit操作系统):•从PostgreSQL13开始不支持Windows2012 R2及更低的操作系统版本。 •从PostgreSQL11开始不支持Windows Client操作系统,比如Windows10之类的 标题 不打任何操作系统补丁的Windows2012R2安装不了PostgreSQL数据库 现象是(pg12.4见下),该windows的版本号为6.3,内部版本号是9600. 标题 或者(pg12.5见下): 标题 这是因为Windows 2012 R2没有安装过任何操作系统补丁更新,此操作系统版本的详细版本号见下:(通过在cmd下敲入winver得到) 标题 解决方法是:请按照https://www.microsoft.com/zh-CN/download/details.aspx?id=42334文章的提示进行补丁--- WindowsServer2012R2更新(KB2919355)----更新。 特别提醒:请按照如下的顺序打补丁:1)clearcompressionflag.exe 4)KB2919355若是不安装KB2975061,那么在安装KB2919355时将安装将失败,事件查看器