CentOS 7 安装 postgreSQL 9.4

发布时间:2020-07-11 10:50:36 作者:紫色葡萄
来源:网络 阅读:1489

CentOS 7仓库中的postgresql软件包太老,我们希望从postgresql 官方获取支持,尤其是关于postgresql 集群方面的支持,比如pgpool 。


安装postgresql 9.4

yum install https://download.postgresql.org/pub/repos/yum/9.4/redhat/rhel-7-x86_64/pgdg-centos94-9.4-2.noarch.rpm 
yum install postgresql-9.4-server


初始化数据库

mkdir -p /data/pgsql
chmod 755 /data
chmod 755 /data/pgsql
chown -R postgres:postgres /data/pgsql
sudo -u postgres /usr/pgsql-9.4/bin/initdb -D /data/pgsql --encoding='UTF8' --locale='zh_CN.UTF-8' --lc-collate='zh_CN.UTF-8' --lc-ctype='zh_CN.UTF-8'


创建文件/etc/systemd/system/postgresql-9.4.service ,

touch /etc/systemd/system/postgresql-9.4.service

内容如下

.include /usr/lib/systemd/system/postgresql-9.4.service
[Service]
Environment=PGPORT=5432
Environment=PGDATA=/data/pgsql

启动postgresql

systemctl daemon-reload
systemctl enable postgresql-9.4
systemctl start postgresql-9.4


设置postgres用户密码

psql -U postgres
alter user postgres with password '123456';


主要的性能参数

shared_buffers = 4GB    #物理内存的1/4左右,不超过8G
work_mem = 32MB       #work_mem * max_connections 不超过物理内存
max_connections = 500    #最大连接数
maintenance_work_mem = 256MB
effective_cache_size = 8GB  #能够使用的最大缓存,建议物理内存1/2
fsync = on  #是否强制刷写硬盘,on开启可防止数据丢失,off关闭,性能会更好。
推荐阅读:
  1. centos6.7安装单节点postgresql
  2. centos如何安装metasploit

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

postgresql gr ce

上一篇:XML的作用是什么

下一篇:MySQL对window函数执行sum函数会出现什么BUG

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》