大数据分布式集群架构上gis应用方案-开源greenplum+开源postgis搭建
一编译开源greenplum
下载最新版本:https://github.com/greenplum-db/gpdb
1操作环境准备
操作系统:centos 6.5
greenplum版本:gpdb-4.3.8.2.zip
1.1安装必要操作系统依赖包
yum -y installbzip2-devel libevent-devel apr-devel curl-devel ed python-paramikolibyaml-devel libtool nfs-utilsyum -y install rsynccoreutils glib2 lrzsz sysstat e4fsprogs xfsprogs ntp readline-devel zlibzlib-devel openssl openssl-devel pam-devel libxml2-devel
libxslt-develpython-devel tcl-devel gcc make smartmontools flex bison perl perl-develperl-ExtUtils* OpenIPMI-tools openldap openldap-devel logrotate gcc-c++python-py curl-devel pam
1.2安装python相关
yum install -ypython-setuptools
wget https://bootstrap.pypa.io/get-pip.py
python get-pip.py
pip install setuptools lockfile paramiko psi epydoc
pip install–upgrade setuptools
1.3解压greenplum包至规划目录/solf并编译安装
cd /solf/gpdb-4.3.8.2
./configure–prefix=/gpdb –with-gssapi –with-pgport=5432 –with-libedit-preferred–with-perl –with-python –with-openssl –with-pam –with-krb5 –with-ldap–with-libxml –enable-cassert –enable-debug –enable-testutils–enable-debugbreak –enable-depend –enable-mapreduce
make
make install
完成后gpdb软件在prefix=/gpdb目录中。
二安装greenplum
详细见http://blog.csdn.net/sunziyue/article/details/49026913
三在greenplum基础上编译安装postgis
下载greenplum兼容的开源postgis:
https://github.com/greenplum-db/postgis
(greenplum上不能用http://download.osgeo.org/postgis/source/上面对应的postgis,否则编译通不过,编译时报错。
postgres对应postgis资料如下
postgis下载: http://download.osgeo.org/postgis/source/
版本支持资料: http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS
安装postgis资料:http://postgis.net/docs/postgis_installation.html
https://docs.djangoproject.com/en/dev/ref/contrib/gis/install/postgis/
)
3.1准备环境
(1)geos
wgethttp://download.osgeo.org/geos/geos-3.4.2.tar.bz2
tar xjfgeos-3.4.2.tar.bz2
cd geos-3.4.2
./configure
make
make install
export GEOS_LIBRARY_PATH= ‘/usr/local/lib/libgeos_c.so’
(2)PROJ.4
wgethttp://download.osgeo.org/proj/proj-4.9.1.tar.gz
wgethttp://download.osgeo.org/proj/proj-datumgrid-1.5.tar.gz
tar xzfproj-4.9.1.tar.gz
cd proj-4.9.1/nad
tar xzf../../proj-datumgrid-1.5.tar.gz
cd ..
./configure
make
make install
(3) GDAL
wgethttp://download.osgeo.org/gdal/1.11.2/gdal-1.11.2.tar.gz
tar xzfgdal-1.11.2.tar.gz
cd gdal-1.11.2
./configure
make
make install
GDAL_LIBRARY_PATH =’/usr/local/lib/libgdal.so’
3.2编译postgis
cd /solf/postgis-2.0
./configure –prefix=/postgis –with-pgconfig=/pgdb/bin/pg_config
make
make install
3.3greenplum中安装postgis
[gpadmin@gpmasterpostgresql]$ psql testdb
testdb=# createdatabase postgis;
testdb =#\c postgis postgres
postgis=# createlanguage plpgsql;
拷贝/usr/local/lib下的libgeos_c.so.1、libproj.so.9等相关包到/pgdb/lib/ postgresql下
psql -d postgis -f /pgdb/share/postgresql/contrib/postgis-2.0/postgis.sql
psql -d postgis -f /pgdb/share/postgresql/contrib/postgis-2.0/spatial_ref_sys.sql
3.4greenplum中初步使用postgis
CREATE TABLE cities( id int4, name varchar(50));
SELECTAddGeometryColumn (‘cities’, ‘the_geom’, 4326, ‘POINT’, 2);
INSERT INTO cities(id, the_geom, name) VALUES (1,ST_GeomFromText(‘POINT(-0.125751.508)’,4326),’London, England’);
INSERT INTO cities(id, the_geom, name) VALUES (2,ST_GeomFromText(‘POINT(-81.23342.983)’,4326),’London, Ontario’);
INSERT INTO cities(id, the_geom, name) VALUES (3,ST_GeomFromText(‘POINT(27.91162491-33.01529)’,4326),’East London,SA’);
SELECT id,ST_AsText(the_geom), ST_AsEwkt(the_geom), ST_X(the_geom), ST_Y(the_geom) FROMcities;
SELECT p1.name,p2.name,ST_Distance_Spheroid(p1.the_geom,p2.the_geom,’SPHEROID[“GRS_1980”,6378137,298.257222]’)
FROM cities AS p1, cities AS p2 WHEREp1.id > p2.id;
完成。
转载自:https://blog.csdn.net/sunziyue/article/details/53374704