检查PostGIS、PostgreSQL、GEOS、GDAL、PROJ等各软件的版本依赖关系

http://trac.osgeo.org/postgis/wiki/UsersWikiPostgreSQLPostGIS

1. 创建postgres用户和组

# groupadd -g  dba
# useradd -u -g dba -G root -d /usr/local/pgsql postgres

2. 添加postgres用户环境变量

$ cat ~/.bash_profile
# .bash_profile # Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi # User specific environment and startup programs export PGHOME=/usr/local/pgsql
export PGDATA=/usr/local/pgsql/data
export PATH=$PGHOME/bin:$PATH:$HOME/bin
export LD_LIBRARY_PATH=$PGHOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/lib:/usr/lib:/usr/local/lib:$LD_LIBRARY_PATH
export DATE=`date +"%Y%m%d%H%M"`
export HISTTIMEFORMAT="%Y-%m-%d %H:%M:%S>"

3. 调整系统参数

# tail -n  /etc/sysctl.conf
vm.overcommit_memory=
vm.overcommit_ratio=
fs.aio-max-nr=
fs.file-max=
net.ipv4.ip_local_port_range=
net.core.rmem_default=
net.core.rmem_max=
net.core.wmem_default=
net.core.wmem_max=
kernel.sem=
kernel.shmall=
kernel.shmmax= # tail -n /etc/security/limits.conf
postgres soft nproc
postgres hard nproc
postgres soft nofile
postgres hard nofile

4. 安装依赖包

# yum install -y python-devel perl-ExtUtils-Embed python-devel gcc-c++ openssl-devel readline readline-devel bzip2 zlib zlib-devel openssl openssl-devel pam pam-devel libxml2 libxml2-devel libxslt libxslt-devel openldap openldap-devel libgeos-dev libproj-dev libgdal-dev xsltproc docbook-xsl docbook-xml imagemagick libmagickcore-dev dblatex tcl tcl-devel unixODBC unixODBC-devel libpng12 libpng12-devel

5. 安装PostgreSQL

修改源码文件src/include/pg_config_manual.h中 "#define NAMEDATALEN"的值为256,这一步不是必须的,修改值是因为遇到过R.D的同事要建立的schema长度大于64个字符,但是pG默认是64字符,超过的长度会比截取掉。

注:如果缺少部分系统包的话可以通过如下网址查找 https://centos.pkgs.org/

$ wget https://ftp.postgresql.org/pub/source/v9.5.7/postgresql-9.5.7.tar.bz2
$ tar -jxf postgresql-9.5..tar.bz2
$ cd postgresql-9.5.
$ ./configure --prefix=/usr/local/pgsql --with-wal-segsize= --with-perl --with-python --with-gssapi --with-pam --with-ldap --with-openssl --with-tcl --with-libxml --with-libxslt
$ make
$ make install
$ cd contrib/
$ make && make install
$ mkdir /usr/local/pgsql/{data,arch,plugin}
$ sudo echo "su - postgres -c 'pg_ctl start -D /usr/local/pgsql/data'" >> /etc/rc.local
$ /usr/local/pgsql/bin/initdb -D /usr/local/pgsql/data/
$ cat /usr/local/pgsql/data/postgresql.conf | grep -v "^$" | grep -v "^#"
listen_addresses = '*' # what IP address(es) to listen on;
port = # (change requires restart)
max_connections = # (change requires restart)
shared_buffers = 2048MB # min 128kB
logging_collector = on # Enable capturing of stderr and csvlog
log_directory = 'pg_log' # directory where log files are written,
log_filename = 'postgresql-%Y-%m-%d_%H%M%S.log' # log file name pattern,
$ cat /usr/local/pgsql/data/pg_hba.conf | grep -v "^$" | grep -v "^#"
local all all trust
host all all 127.0.0.1/ trust
host all all 0.0.0.0/ md5
host all all ::/ trust
$ pg_ctl start -W
$ psql
psql (9.5.)
Type "help" for help. postgres=# select version();
version
----------------------------------------------------------------------------------------------------------
PostgreSQL 9.5. on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4. (Red Hat 4.4.-), -bit
( row)

 6.安装PostGIS

6.1 安装Proj4

$ wget http://download.osgeo.org/proj/proj-4.9.3.tar.gz
$ tar -xf proj-4.9..tar.gz
$ cd proj-4.9.
$ ./configure --prefix=/usr/local/pgsql/plugin/proj
$ make
$ make install
# echo "/usr/local/pgsql/plugin/proj/lib" > /etc/ld.so.conf.d/proj-4.9..conf
# ldconfig

6.2 安装GEOS

$ wget http://download.osgeo.org/geos/geos-3.6.1.tar.bz2
$ tar -jxf geos-3.6..tar.bz2
$ cd geos-3.6.
$ ./configure --prefix=/usr/local/pgsql/plugin/geos
$ make
$ make install
# echo "/usr/local/pgsql/plugin/geos/lib" > /etc/ld.so.conf.d/geos-3.6..conf
# ldconfig

6.3 安装GDAL

$ wget http://download.osgeo.org/gdal/2.1.2/gdal-2.1.2.tar.gz
$ tar -xf gdal-2.1..tar.gz
$ cd gdal-2.1.
$ ./configure --prefix=/usr/local/pgsql/plugin/gdal
$ make
$ make install
# echo "/usr/local/pgsql/plugin/gdal/lib" > /etc/ld.so.conf.d/gdal-2.1..conf
# ldconfig

6.4 安装PostGIS

$ wget http://download.osgeo.org/postgis/source/postgis-2.2.5.tar.gz
$ tar -xf postgis-2.2..tar.gz
$ cd postgis-2.2.
$ ./configure --prefix=/usr/local/pgsql/plugin/postgis --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=/usr/local/pgsql/plugin/geos/bin/geos-config --with-gdalconfig=/usr/local/pgsql/plugin/gdal/bin/gdal-config --with-projdir=/usr/local/pgsql/plugin/proj
..............................................................................................
PostGIS is now configured for x86_64-pc-linux-gnu -------------- Compiler Info -------------
C compiler: gcc -g -O2
SQL preprocessor: /usr/bin/cpp -traditional-cpp -w -P -------------- Dependencies --------------
GEOS config: /usr/local/pgsql/plugin/geos/bin/geos-config
GEOS version: 3.6.
GDAL config: /usr/local/pgsql/plugin/gdal/bin/gdal-config
GDAL version: 2.1.
PostgreSQL config: /usr/local/pgsql/bin/pg_config
PostgreSQL version: PostgreSQL 9.5.
PROJ4 version:
Libxml2 config: /usr/bin/xml2-config
Libxml2 version: 2.7.
JSON-C support: no
PCRE support: no
PostGIS debug level:
Perl: /usr/bin/perl --------------- Extensions ---------------
PostGIS Raster: enabled
PostGIS Topology: enabled
SFCGAL support: disabled
Address Standardizer support: disabled -------- Documentation Generation --------
xsltproc: /usr/bin/xsltproc
xsl style sheets: /usr/share/sgml/docbook/xsl-stylesheets
dblatex:
convert:
mathml2.dtd: http://www.w3.org/Math/DTD/mathml2/mathml2.dtd
$ make
$ make install

7. 检查PostGiS是否安装成功

postgres=# CREATE EXTENSION hstore;
postgres=# CREATE EXTENSION postgis;
CREATE EXTENSION
postgres=# CREATE EXTENSION postgis_topology;
CREATE EXTENSION
postgres=# CREATE EXTENSION fuzzystrmatch;
CREATE EXTENSION
postgres=# CREATE EXTENSION postgis_tiger_geocoder;
CREATE EXTENSION
postgres=# \dx
List of installed extensions
Name | Version | Schema | Description
------------------------+---------+------------+---------------------------------------------------------------------
fuzzystrmatch | 1.0 | public | determine similarities and distance between strings
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
postgis | 2.2.5 | public | PostGIS geometry, geography, and raster spatial types and functions
postgis_tiger_geocoder | 2.2.5 | tiger | PostGIS tiger geocoder and reverse geocoder
postgis_topology | 2.2.5 | topology | PostGIS topology spatial types and functions
(5 rows)

8.将PostgreSQL配置为系统服务

[Unit]
Description=PostgreSQL database server
Documentation=https://www.postgresql.org/docs/
After=syslog.target
After=network.target
Wants=network-online.target [Service]
Type=forking
User=postgres
Group=dba
Restart=always
LimitNOFILE= # Note: avoid inserting whitespace in these Environment= lines, or you may
# break postgresql-setup. # Location of database directory
Environment=PGDATA=/usr/local/pgsql/data/ # Maximum number of seconds pg_ctl will wait for postgres to start. Note that
# PGSTARTTIMEOUT should be less than TimeoutSec value.
Environment=PGSTARTTIMEOUT= # Where to send early-startup messages from the server (before the logging
# options of postgresql.conf take effect)
# This is normally controlled by the global default set by systemd
# StandardOutput=syslog # Disable OOM kill on the postmaster
OOMScoreAdjust=-
Environment=PG_OOM_ADJUST_FILE=/proc/self/oom_score_adj
Environment=PG_OOM_ADJUST_VALUE= ExecStart=/usr/local/pgsql/bin/pg_ctl start -D ${PGDATA} -s -w -t ${PGSTARTTIMEOUT}
ExecStop=/usr/local/pgsql/bin/pg_ctl stop -D ${PGDATA} -s -m fast
ExecReload=/usr/local/pgsql/bin/pg_ctl reload -D ${PGDATA} -s
KillMode=mixed
KillSignal=SIGINT # Do not set any timeout value, so that systemd will not kill postmaster
# during crash recovery.
TimeoutSec= [Install]
WantedBy=multi-user.target

PostgreSQL&PostGIS完全安装的更多相关文章

  1. postgresql+postgis+pgrouting安装步骤图解

    1.在此(https://www.bigsql.org/postgresql/installers.jsp/)下载postgresql(开源数据库,gis行业推荐使用); 2.在此(http://wi ...

  2. PostgreSql+PostGIS和uDig的安装

    文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/. 1.前言 总体来说,这两款开源软件均是很好安装的,一般按照提示一步一步 ...

  3. GIS on CentOS 7 之 PostgreSQL & PostGIS

    PostgreSQL & PostGIS 安装postgresql 配置好yum源之后,使用yum info postgresql可发现 postgresql的版本为9.2.23,若想安装最新 ...

  4. 搭建简易Web GIS网站:使用GeoServer+PostgreSQL+PostGIS+OpenLayers3

    Web GIS系列: 搭建简易Web GIS网站:使用GeoServer+PostgreSQL+PostGIS+OpenLayers3 使用GeoServer+QGIS发布WMTS服务 使用GeoSe ...

  5. PostgreSQL+PostGIS

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

  6. postgresql pgagent 的安装及使用

    pgagent 作为postgresql的一个任务调度代理,在postgresql 9.0 以前 是附带在pgadmin 包下面的,只是默认不安装,9.0之后作为了一个单独是的安装包.所以要使用pga ...

  7. postgresql,postgis,geoserver 发布地图服务,并用.net mvc openlayers3进行显示

    1.所需工具 postgres版本 9.6.1 对应的postgis geoserver 2.8.2 openlayers3 2.将postgres postgis ,geosever安装好,再用如下 ...

  8. PostgreSQL(一) 编译安装运行

    原创,如转发需注明出处. 多年没写博客,一直用的个人笔记软件,最近准备阅读PostgreSQL源码,故记录.(这两年PostgreSQL数据库在某些环境下是比较火的,原因想必大家都清楚.) Postg ...

  9. PostgreSQL(PostGIS)安装和入门的若干问题

    1. 装完PostgreSQL后记得打开pgAdmin4启动一下服务器和启动一下数据库,否则PostGIS装不上. 2. pgAdmin4是网页,而3是客户端,当然都可以在File - Prefere ...

随机推荐

  1. 4、Python文件对象及os、os.path和pickle模块(0530)

    文件系统和文件 1.文件系统是OS用于明确磁盘或分区上的文件的方法和数据结构---即在磁盘上组织文件的方法: 文件系统模块:os 2.计算机文件(称文件.电脑档案.档案),是存储在某种长期储存设备或临 ...

  2. 用tsMuxeR GUI给ts视频添加音轨

    收藏比赛的都应该知道,高清的直播流录制了后一般是ts或者mkv封装,前者用tsMuxeR GUI可以对视频音频轨进行操作,后者用mkvtoolnix,两者都是无损操作. 至于其他格式就不考虑了,随便用 ...

  3. jvm到底是什么?有什么作用?工作机制如何?

    1.jvm定义 JVM就是java虚拟机,它是一个虚构出来的计算机,可在实际的计算机上模拟各种计算机的功能.JVM有自己完善的硬件结构,例如处理器.堆栈和寄存器等,还具有相应的指令系统. 2.jvm作 ...

  4. ones测试用例管理平台

    https://ones.ai 团队信息: 公司信息,公司logo付费信息:绑定第三方账户: 成员信息: userid,user_email,激活状态,所属部门组织架构:所属部门: 新建组 团队权钱: ...

  5. CentOS6.5使用yum快速搭建LAMP环境

    1.安装Apache # yum -y install httpd # 开机自启动 # chkconfig httpd on # 启动httpd 服务 # service httpd start # ...

  6. 要使用myConfig.properties配置文件作为实体类的映射文件的话,格式要用=,最关键的要和实例类中通过反射获取值的KEY要一样,不样会反射取不到值

    ABC=https://fsdfsdf.iy.comABCId=L2345345ZhP345ABCKey=sfdf4234f234dhE6Ut0aABCName=Gassd010 上面是myConfi ...

  7. MySQL LIMIT的使用

    SELECT语句返回所有匹配的行,它们可能是指定表中的每个行.为 了返回第一行或前几行,可使用LIMIT子句. 比如我原始的student表如下: 我现在想输出前4行,就使用 SELECT * FRO ...

  8. 牛客网NOIP赛前集训营-提高组(第一场)B 数数字

    数数字 思路: 数位dp 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC optimize(4) #include< ...

  9. lua --- 点号 和 冒号

    冒号的作用:1.定义函数时,给函数添加隐藏的第一个参数 self2.调用函数时,默认把当前调用者作为第一个参数传递进去 如 a:b(c) 可以理解为 a.b(a, c) 以下是用点号的定义和调用函数的 ...

  10. 虚拟机中不能连接usb设备解决办法

    虚拟机中不能连接usb设备解决办法 1.点击开始->运行,在对话框中输入"services.msc",确定,打开windows服务管理器.2.在服务列表中选中"VM ...