暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

linux下run包方式安装PostgreSQL数据库

原创 binguo2008 2024-03-20
243

前言

推荐安装PostgreSQL 9.6.21及以上版本


1. 新建pgdbgrp用户组和postgres用户

groupadd pgdbgrp

useradd -g pgdbgrp postgres


2.下载postgresql-9.6.21-1-linux-x64.run安装包

https://get.enterprisedb.com/postgresql/postgresql-9.6.21-1-linux-x64.run


3.为postgresql-9.6.21-1-linux-x64.run赋予可执行权限

chmod a+x postgresql-9.6.21-1-linux-x64.run


4.软链接下安装PostgreSQL需要的libsasl2.so.2包

cd /usr/lib64

ln -s libsasl2.so.3 libsasl2.so.2


5.正式安装postgresql

./postgresql-9.6.21-1-linux-x64.run


6.编辑postgresql.conf配置文件,调整以下三个参数(优化连接数和性能的)

max_connections值建议设置成1000以上

shared_buffers值建议设置成操作系统总内存的1/4

work_mem值建议设置成16MB

cd /opt/PostgreSQL/9.6/data

vim postgresql.conf

编辑postgresql.conf文件,追加下面三个参数(根据实际追加):

max_connections=1500

shared_buffers=4096MB

work_mem=16MB


7.编辑pg_hba.conf文件,开启IP访问白名单


8.重启Postgresql服务,以使上述调整生效

systemctl restart postgresql-9.6

PS.上面是Postgresql数据库服务重启命令,关闭、启动、查看状态,命令参考如下:

systemctl stop postgresql-9.6

systemctl start postgresql-9.6

systemctl status postgresql-9.6


9. 设置Postgresql数据库服务开机自启

systemctl enable postgresql-9.6.service

systemctl list-unit-files|grep postgres

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论