银河麒麟V10使用编译安装PostSQL+PostGIS

一、安装环境


银河麒麟V10

1、PostGIS简介


  PostGIS是对象关系型数据库系统PostgreSQL的一个扩展,PostGIS提供如下空间信息服务功能: 空间对象、空间索引、空间操作函数和空间操作符。同时,PostGIS遵循OpenGIS的规范。

二、使用make安装PostGIS

此时发现postgis在麒麟系统环境内并没有提供相关yum安装包,那么则进行所需运行环境程序的编译安装即可。


1、安装编译时环境


设置安装相应编译文件后也需要对相应的文件进行用户的授权,否则运行时会显示该用户无权限,或者文件不存在。运行 create extension *会出现错误

1.1、proj4安装

[root@localhost home]# wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz   # 下载文件

银河麒麟V10使用编译安装PostSQL+PostGIS_第1张图片

[root@localhost ~]# cd /home  # 如果已经下载好了,直接复制粘贴到该目录下
[root@localhost home]# tar -zxvf proj-4.9.3.tar.gz  # 解压
[root@localhost home]# cd proj-4.9.3

银河麒麟V10使用编译安装PostSQL+PostGIS_第2张图片

[root@localhost proj-4.9.3]# ./configure --prefix=/data-postgis/pgsql/plugin/proj

[root@localhost proj-4.9.3]# ./configure --prefix=/data-postgis/pgsql/plugin/proj 
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking C_WFLAGS for maximum warnings... -Wall -Wdeclaration-after-statement
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking whether ln -s works... yes
checking whether make sets $(MAKE)... (cached) yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for exp in -lm... yes
checking for ANSI C header files... (cached) yes
checking for localeconv... yes
checking jni.h usability... no
checking jni.h presence... no
checking for jni.h... no
checking whether to enable Java/JNI support... disabled
checking for mutexes... checking for pthread_create in -lpthread... yes
checking for pthread_mutexattr_settype in -lpthread... yes
checking whether PTHREAD_MUTEX_RECURSIVE is declared... yes
enabled, pthread
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating cmake/Makefile
config.status: creating src/Makefile
config.status: creating man/Makefile
config.status: creating man/man1/Makefile
config.status: creating man/man3/Makefile
config.status: creating nad/Makefile
config.status: creating jniwrap/Makefile
config.status: creating jniwrap/org/Makefile
config.status: creating jniwrap/org/proj4/Makefile
config.status: creating nad/install
config.status: creating proj.pc
config.status: creating src/proj_config.h
config.status: executing depfiles commands
config.status: executing libtool commands
[root@localhost proj-4.9.3]#

详情

[root@localhost proj-4.9.3]# make
 [root@localhost proj-4.9.3]# make install

 银河麒麟V10使用编译安装PostSQL+PostGIS_第3张图片

 银河麒麟V10使用编译安装PostSQL+PostGIS_第4张图片

[root@localhost proj-4.9.3]# echo "/data-postgis/pgsql/plugin/proj/lib" > /etc/ld.so.conf.d/proj-4.9.3.conf
[root@localhost proj-4.9.3]#  ldconfig

 1.2、geos

[root@localhost home]# wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2
[root@localhost home]# tar -jxf geos-3.6.1.tar.bz2
[root@localhost home]# cd geos-3.6.1 
[root@localhost geos-3.6.1]# ./configure --prefix=/data-postgis/pgsql/plugin/geos
[root@localhost geos-3.6.1]# make  预计5分钟

 银河麒麟V10使用编译安装PostSQL+PostGIS_第5张图片

root@localhost geos-3.6.1]# make install
[root@localhost geos-3.6.1]# echo "/data-postgis/pgsql/plugin/geos/lib" > /etc/ld.so.conf.d/geos-3.6.1.conf
root@localhost geos-3.6.1]# ldconfig

 1.3、gdal

[root@localhost home]# wget http://download.osgeo.org/gdal/2.1.2/gdal-2.1.2.tar.gz
[root@localhost home]# tar -zxvf gdal-2.1.2.tar.gz
[root@localhost home]# cd gdal-2.1.2
[root@localhost gdal-2.1.2]# ./configure --prefix=/data-postgis/pgsql/plugin/gdal
[root@localhost gdal-2.1.2]# make && make install  # 预计时间30分钟

银河麒麟V10使用编译安装PostSQL+PostGIS_第6张图片

银河麒麟V10使用编译安装PostSQL+PostGIS_第7张图片

 [root@localhost gdal-2.1.2]# echo "/data-postgis/pgsql/plugin/gdal/lib" > /etc/ld.so.conf.d/gdal-2.1.2.conf 
[root@localhost gdal-2.1.2]# ldconfig
[root@localhost home]# cd /home

 2. 编译postgis安装包


2.1 编译安装

[root@localhost home]# wget http://postgis.net/stuff/postgis-2.5.3dev.tar.gz
[root@localhost home]# tar -zxvf postgis-2.5.3dev.tar.gz
[root@localhost home]# cd postgis-2.5.3dev
./configure --prefix=/data-postgis/pgsql/plugin/postgis --with-pgconfig=/www/server/pgsql/bin/pg_config --with-geosconfig=/data-postgis/pgsql/plugin/geos/bin/geos-config --with-gdalconfig=/data-postgis/pgsql/plugin/gdal/bin/gdal-config --with-projdir=/data-postgis/pgsql/plugin/proj
[root@localhost postgis-2.5.3dev]# make
[root@localhost postgis-2.5.3dev]# make install

 这里完成需要重新创建一个新的postgis_25数据库,详细参见postgresql部署3部分的-初始化数据库。否则启动/重启后一直提示找不到数据库。

2.2 安装扩展插件

# 切换postgres用户
su - postgres
# 登录PG数据库
psql
# 创建一个数据库
create database postgis;
# 切换到postgis库中
\c postgis
# 显示一下扩展模块
\dx

运行如下sql内容

CREATE EXTENSION postgis;
CREATE EXTENSION postgis_topology;
--CREATE EXTENSION fuzzystrmatch;
--CREATE EXTENSION postgis_tiger_geocoder

 做到这里就完成的插件的安装。

3、创建数据库spatial_testdb

CREATE DATABASE spatial_testdb OWNER postgres;

进入 \c spatial_testdb 

4、安装PostGis扩展

spatial_testdb=# CREATE EXTENSION postgis;
spatial_testdb=# CREATE EXTENSION postgis_topology;
spatial_testdb=# CREATE EXTENSION ogr_fdw;

然后可以验证是否安装成功

SELECT postgis_full_version();

你可能感兴趣的:(数据库,数据库)