Postgresql安装指南
PostgreSQL是一个开源的关系型数据库管理系统,提供诸多企业级特性,比如支持窗口函数(用户可以自定义聚合函数并当作窗口函数使用)、普通CTE表达式、递归CTE表达式以及流式复制等。本文介绍在CentOS7上安装和配置Postgresql10.8。
挂载新磁盘到Postgresql数据目录
查看磁盘信息,找到需要挂载的磁盘的设备名,如
/dev/vdb
bash fdisk -l
创建分区文件系统并格式化磁盘
bash mkfs.ext4 /dev/vdb
将设备挂载到
/opt/Postgresql/data
bash mkdir -p /opt/Postgresql/data mount /dev/vdb /opt/Postgresql/data
将磁盘UUID写入fstab文件
通过
blkid
获得磁盘分区的UUID/dev/vda2: UUID="58835b25-74a4-48ee-a350-2c2ba6c97d78" TYPE="xfs" /dev/vda1: UUID="e24498ef-7267-49a6-b842-173a5737bce5" TYPE="xfs" /dev/vdb: UUID="c9f699c0-6e08-41c1-9014-3df5666ca9d3" TYPE="ext4"
vim /etc/fstab
,在文件最后一行追加vdb的UUID和挂载信息
UUID=58835b25-74a4-48ee-a350-2c2ba6c97d78 / xfs defaults 0 0 UUID=e24498ef-7267-49a6-b842-173a5737bce5 /boot xfs defaults 0 0 UUID=c9f699c0-6e08-41c1-9014-3df5666ca9d3 /opt/Postgresql/data ext4 defaults 0 0
安装Postgresql
手动创建用户
postgres
并指定用户主目录到/opt/Postgresql
useradd -d /opt/Postgresql postgres cp ~/.bash_profile /opt/Postgresql/ cp ~/.bashrc /opt/Postgresql/
从EnterpriseDB下载Postgresql的run格式安装包
# 设置文件的权限属性为可执行 chmod u+x postgresql-10.8-4-linux-x64.run
安装Postgresql,指定安装目录到
/opt/Postgresql
、数据目录为/opt/Postgresql/data
,设置默认端口为5432./postgresql-10.8-4-linux-x64.run
配置Postgresql
在
.bashrc
文件中设置环境变量cd /opt/Postgresql # 切换工作目录到postgres用户的主目录 vim .bashrc export PGHOME=/opt/Postgresql export PATH=$PGHOME/bin:$PATH export PGDATA=$PGHOME/data export LD_LIBRARY_PATH=$PGHOME/lib
配置
pg_hba.conf
文件vim /opt/Postgresql/data/pg_hba.conf # IPv4 local connections: host all all 127.0.0.1/32 md5 host all all 0.0.0.0/0 md5
开放防火墙端口
firewall-cmd --add-service=postgresql --permanent firewall-cmd --reload
重新启动
postgresql-10
服务systemctl status postgresql-10 systemctl restart postgresql-10
变更
/opt/Postgresql
目录的拥有者为postgres
用户chown -R postgres:postgres /opt/Postgresql
参考文献
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。