安装pgdg库
直接yum install会提示no packege
所以先要安装这个库
https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7.5-x86_64/pgdg-redhat-repo-latest.noarch.rpm
rpm -ivh pgdg-redhat-repo-latest.noarch.rpm
安装Postgresql
可以选版本,改变数字就行
yum -y install postgresql10-server postgresql10
Postgresql-12
yum -y install postgresql12-server postgresql12
su - postgres
初始化数据库 -D 指定目录
/usr/pgsql-12/bin/initdb -D /home/postgresql/data -U postgres
启动数据库
/usr/pgsql-12/bin/pg_ctl -D /homeplus/postgresql/data -l logfile start
进入数据库
psql
安装Postgis
yum -y install epel-release
yum -y install postgis30_12 postgis30_12-utils postgis30_12-client
创建扩展
psql -d yourdatabase -c "CREATE EXTENSION postgis;"
-- if you built with raster support and want to install it --
psql -d yourdatabase -c "CREATE EXTENSION postgis_raster;"
-- if you want to install topology support --
psql -d yourdatabase -c "CREATE EXTENSION postgis_topology;"
-- if you built with sfcgal support and want to install it --
psql -d yourdatabase -c "CREATE EXTENSION postgis_sfcgal;"
-- if you want to install tiger geocoder --
psql -d yourdatabase -c "CREATE EXTENSION fuzzystrmatch"
psql -d yourdatabase -c "CREATE EXTENSION postgis_tiger_geocoder;"
-- if you installed with pcre
-- you should have address standardizer extension as well
psql -d yourdatabase -c "CREATE EXTENSION address_standardizer;"