1. 获取所需依赖包
wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/llvm5.0-devel-5.0.1-7.el7.x86_64.rpm
wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/llvm5.0-5.0.1-7.el7.x86_64.rpm
wget https://download-ib01.fedoraproject.org/pub/epel/7/x86_64/Packages/l/llvm5.0-libs-5.0.1-7.el7.x86_64.rpm
yum install -y centos-release-scl-rh llvm5*
yum install -y epel-release
2. 安装数据库
sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
sudo yum install -y postgresql15-server
3. 初始化数据库
sudo /usr/pgsql-15/bin/postgresql-15-setup initdb
4. 设置开机自启动
sudo systemctl enable postgresql-15
5. 启动数据库(状态:status | 重启:restart | 停止:stop)
sudo systemctl start postgresql-15
6. 配置信息
a. 打开配置文件
vi /etc/profile
b. 补充配置信息(i 开始输入;Esc + :wq包存退出)
#PGSQL_HOME
export PGSQL_HOME=/usr/pgsql-15
export PATH=$PATH:$PGSQL_HOME/bin
#生效配置
source /etc/profile
7. 替换系统中旧版本的psql脚本为新的版本
mv /usr/bin/psql /usr/bin/psql.bak
ln -s /usr/pgsql-15/bin/psql /usr/bin/psql
8. 初始化数据库密码
a. 切到postgres用户下
su postgres
b. 进入sql模式
psql
c. 修改postgres的密码
alter user postgres with password 'postgres';
d. 退出sql模式
\q
9. 可远程连接配置
a. 关闭防火墙
# 查看防火墙状态
systemctl status firewalld.service
# 或
firewall-cmd --state
# 启动防火墙
systemctl start firewalld.service
# 关闭防火墙
systemctl stop firewalld.service
# 查看是否开机启动
systemctl is-enabled firewalld.service
# 禁止开机启动
systemctl disable firewalld.service
b. 修改数据库监听地址
// 打开配置文件
vi /var/lib/pgsql/15/data/postgresql.conf
// 打开监听注释,监听地址改为*
listen_addresses = '*'
// 打开配置文件
vi /var/lib/pgsql/15/data/pg_hba.conf
// 新增一行,若连接不上则将 scram-sha-256 修改为 trust 信任模式
host all all 0.0.0.0/0 scram-sha-256
c. 重启数据库服务
sudo systemctl restart postgresql-15
1. 安装依赖组件
sudo yum install epel-release
2. 查看可用的postgis的包
yum list postgis*
3. 选择postgis的包(版本与postgres保持一致)
sudo yum install postgis33_15.x86_64
5. 查看安装信息
rpm -qi postgis33_15.x86_64
1. 连接数据库
2. 添加postgis扩展
create extension postgis;
create extension postgis_raster;
create extension postgis_topology;
create extension postgis_sfcgal;
create extension fuzzystrmatch;
create extension address_standardizer;
create extension address_standardizer_data_us;
create extension postgis_tiger_geocoder;