Update from Sync Service

This commit is contained in:
FNS Service
2026-04-21 20:40:56 +08:00
parent cb6afe3aef
commit c0ae2f0edb
4 changed files with 314 additions and 82 deletions

View File

@@ -1,18 +1,91 @@
1. ==Install the repository RPM:========yum install== ==https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm==
2. ==Install the client packages:========yum install postgresql12==
3. ==Optionally install the server packages:========yum install postgresql12-server==
4. ==Optionally initialize the database and enable automatic start:========/usr/pgsql-12/bin/postgresql-12-setup initdb========systemctl enable postgresql-12========systemctl start postgresql-12== > 来自 <[https://www.postgresql.org/download/linux/redhat/](https://www.postgresql.org/download/linux/redhat/)>
[Service]
Type=notify
# PostgreSQL 安装
User=postgres
Group=postgres
> CentOS 7 安装 PostgreSQL 12
# Note: avoid inserting whitespace in these Environment= lines, or you may
# break postgresql-setup.
---
# Location of database directory
Environment=PGDATA=/var/lib/pgsql/12/data/
## 安装步骤
初始化之后,数据文件会存在 /var/lib/pgsql/12/data
> 来自 <[https://www.postgresql.org/download/linux/redhat/](https://www.postgresql.org/download/linux/redhat/)>
### 1. 安装 RPM 源
```bash
yum install https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
```
### 2. 安装客户端
```bash
yum install postgresql12
```
### 3. 安装服务端
```bash
yum install postgresql12-server
```
### 4. 初始化数据库
```bash
/usr/pgsql-12/bin/postgresql-12-setup initdb
```
### 5. 启动服务
```bash
systemctl enable postgresql-12
systemctl start postgresql-12
```
---
## 配置
### 数据目录
默认数据目录:`/var/lib/pgsql/12/data/`
### 连接配置
```bash
sudo -u postgres psql
```
```sql
-- 修改 postgres 用户密码
ALTER USER postgres WITH PASSWORD '你的密码';
-- 允许远程连接
-- 编辑 pg_hba.conf
host all all 0.0.0.0/0 md5
-- 编辑 postgresql.conf
listen_addresses = '*'
```
---
## 常用命令
```bash
# 启动/停止/重启
systemctl start postgresql-12
systemctl stop postgresql-12
systemctl restart postgresql-12
# 连接数据库
psql -U postgres -h localhost
# 创建数据库
createdb mydb
# 备份
pg_dump -U postgres mydb > backup.sql
# 恢复
psql -U postgres mydb < backup.sql
```
---
> 参考:[PostgreSQL 官方安装指南](https://www.postgresql.org/download/linux/redhat/)