
PostgreSQL 部署手册
安装
v13:CentOS 8
# Install the repository RPM:
dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-8-x86_64/pgdg-redhat-repo-latest.noarch.rpm
# Disable the built-in PostgreSQL module:
dnf -qy module disable postgresql
# Install PostgreSQL:
dnf install -y postgresql13-server postgresql13-docs postgresql13-contrib
# 创建数据库实例/集群,否则 PostgreSQL 无法启动
/usr/pgsql-13/bin/postgresql-13-setup initdb
# 服务端配置文件中添加以下配置允许侦听远程连接
listen_addresses = '0.0.0.0'
# 或
listen_addresses = '*'
# 客户端认证配置文件中添加以下配置允许远程客户端密码连接
host all all 0.0.0.0/0 md5
# Enable automatic start:
systemctl enable postgresql-13 --now
# systemctl start postgresql-13
# 设置默认管理员 postgres 的密码,允许远程客户端可用密码访问
su - postgres
psql -c "alter user postgres with password 'postgres'"
相关文件及目录
PostgreSQL 使用 OID(Object Identifier)/ filenode 为文件名存储对象。
v12:CentOS 8
sudo dnf module enable postgresql:12 -y
sudo dnf install postgresql-server -y
管理
PostgreSQL 通常以 postgres 用户启动,管理命令需用相同用户执行,切换到 postgres 用户后用以下语句指示在管理工具路径中匹配命令。
# 给 postgres 用户路由管理命令
echo "export PATH=/usr/pgsql-13/bin/:$PATH" >> ~/.bash_profile