1. 程式人生 > 其它 >離線安裝postgresql 和 postgis

離線安裝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();