离线安装postgresql 和 postgis

修改 yum 配置文件

vi /etc/yum.conf

修改 cachedir 到上传的缓存文件夹
cachedir文件夹下是 base code epel extras 等文件夹

[main]
cachedir=/home/postgis

安装

1,安装工具类

yum -C install wget net-tools epel-release -y

2,安装服务类

yum install pgdg-redhat-repo-latest.noarch.rpm -y

3,安装数据库

yum -C install postgresql10-contrib postgresql10-server –y

4,查询版本

psql --version

5,初始化数据库

/usr/pgsql-10/bin/postgresql-10-setup initdb

6,启动数据库

sudo systemctl start postgresql-10

7,设置数据库开机自启

sudo systemctl enable postgresql-10.service

8,设置数据超级管理员密码

su - postgres
psql
ALTER USER postgres WITH PASSWORD 'user';

9,修改数据库配置

vi /var/lib/pgsql/10/data/postgresql.conf

修改 listten_addresses

listten_addresses = "localhost"
listten_addresses = "*"

修改 pg_hba

vi /var/lib/pgsql/10/data/pg_hba.conf

# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     peer
# IPv4 local connections:
host    all             all             127.0.0.1/32            ident
# IPv6 local connections:
host    all             all             ::1/128                 ident
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     peer
host    replication     all             127.0.0.1/32            ident
host    replication     all             ::1/128                 ident
# TYPE  DATABASE        USER            ADDRESS                 METHOD

# "local" is for Unix domain socket connections only
local   all             all                                     md5
# IPv4 local connections:
host    all             all             127.0.0.1/32            md5
# IPv6 local connections:
host    all             all             ::1/128                 md5
host    all             all             0.0.0.0/0               md5
# Allow replication connections from localhost, by a user with the
# replication privilege.
local   replication     all                                     md5
host    replication     all             127.0.0.1/32            md5
host    replication     all             ::1/128                 md5

10,重启数据库

systemctl restart postgresql-10.service

11,安装postgis

yum -C install postgis30_10.x86_64 postgis30_10-client.x86_64 -y

工具
yum -C install ogr_fdw10 -y
yum -C install pgrouting_10 -y

12,创建gis和工具

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
CREATE EXTENSION ogr_fdw;
查询是否成功
SELECT postgis_full_version();

posted @ 2022-04-12 10:34  枫·影  阅读(458)  评论(0编辑  收藏  举报