首页 > 数据库 >欧拉系统postgresql 与PostGis 离线环境安装

欧拉系统postgresql 与PostGis 离线环境安装

时间:2024-09-27 09:02:18浏览次数:1  
标签:postgresql -- make 离线 PostGis pgsql usr && local

postgresql 与PostGis 离线环境安装

上传文件至服务器

#安装所需依赖
yum install /opt/PGsql-13-gis/rpm/* -y

Postgresql安装

tar -zxvf postgresql-13.2.tar.gz
#进入该目录
 ./configure --prefix=/usr/local/pgsql --with-uuid=ossp --with-libxml
make
make install
 #添加用户
 useradd postgres
 mkdir /data/pgsql/data -p
 mkdir /data/pgsql/log -p
 touch /data/pgsql/log/server.log
 chown postgres:postgres /data/pgsql/ -R
 #关闭selinux
  setenforce 0 
  sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  #使用systemd管理pgsql
  cp contrib/start-scripts/linux /etc/init.d/pgsql
  
  ---
  #添加init.d为可选项
  vi /etc/init.d/pgsql
  ###
  PGLOG="/usr/local/pgsql/log/server.log" #修改此项
  ###
  
  chmod a+x /etc/init.d/pgsql
  chkconfig --add /etc/init.d/pgsql
  echo '/usr/local/pgsql/lib' >> /etc/ld.so.conf
  ldconfig
  ---
  
  echo 'export PATH=/usr/local/pgsql/bin/:$PATH' >> /etc/profile #配置环境变量
  echo 'export PGDATA=/data/pgsql/data'  >> /etc/profile
  echo 'export PGHOME=/usr/local/pgsql/:$PATH' >> /etc/profile
  echo 'export LD_LIBRARY_PATH=/usr/local/pgsql/lib/:$LD_LIBRARY_PATH' >> /etc/profile
  source /etc/profile
  su - postgres
  ###
  initdb -D /data/pgsql/data/
  pg_ctl -D /data/pgsql/data/ -l /data/pgsql/log/server.log start
  pg_ctl -D /data/pgsql/data/ -l /data/pgsql/log/server.log stop
  exit
  ###
  systemctl start pgsql #启动数据库
#initdb报错解决方案
echo "kernel.shmmni = 8192" >> /etc/sysctl.conf
sysctl -p

设置外部访问

vi /usr/local/pgsql/data/pg_hba.conf
###
# IPv4 local connections:
host    all             all             0.0.0.0/0               trust
###

vi /usr/local/pgsql/data/postgresql.conf
###
listen_addresses = '*'          # what IP address(es) to listen on;
###

firewall-cmd --zone=public --add-port=5432/tcp --permanent     ##配置防火墙放行5432端口
firewall-cmd --reload       ##防火墙重新加载配置文件
systemctl restart pgsql

安装PostGis

 echo 'export CMAKE_HOME=/usr/bin/cmake' >> /etc/profile

安装proj

tar -zxvf proj-6.1.0.tar.gz
./configure --prefix=/usr/local/proj
make
make install
echo "/usr/local/proj/lib/" >> /etc/ld.so.conf
ldconfig

安装geos

tar -xvf geos-3.8.0.tar.bz2
./configure --prefix=/usr/local/geos
make
make install
echo "/usr/local/geos/lib/" >> /etc/ld.so.conf
ldconfig

安装gdal

tar -zxvf gdal-3.3.3.tar.gz
./configure --prefix=/usr/local/gdal --with-proj=/usr/local/proj
make
make install
echo "/usr/local/gdal/lib/" >> /etc/ld.so.conf
ldconfig

安装json-c

unzip json-c-json-c-0.13.zip
./configure --prefix=/usr/local/json-c/
make
make install
echo "/usr/local/json-c/lib/" >> /etc/ld.so.conf
ldconfig

安装protobuf

tar -zxvf protobuf-3.20.3.tar.gz
./autogen.sh
./configure --prefix=/usr/local/protobuf
make
make install 
echo '/usr/local/protobuf/lib/' >> /etc/ld.so.conf
ldconfig
echo 'export PKG_CONFIG_PATH=/usr/local/protobuf/lib/pkgconfig/' >> /etc/profile
echo 'export PROTOBUF=/usr/local/protobuf' >> /etc/profile
source /etc/profile

安装protobuf-c

tar -zxvf protobuf-c-1.4.0.tar.gz
./autogen.sh
./configure --prefix=/usr/local/protobuf-c/
make
make install
echo "/usr/local/protobuf-c/lib/" >> /etc/ld.so.conf
ldconfig
echo 'export PATH=$CMAKE_HOME/bin:$PROTOBUF_HOME/bin:$PATH:/usr/local/protobuf-c/bin' >> /etc/profile
echo 'export PATH=$CMAKE_HOME/bin:$PROTOBUF_HOME/bin:$PATH:/usr/local/protobuf-c/bin:/usr/local/gadl/bin' >> /etc/profile
source /etc/profile

安装CGAL

tar -zxvf cgal-releases-CGAL-4.7.tar.gz
cmake3 . -DCMAKE_INSTALL_PREFIX=/usr/local/cgal
make
make install
echo "/usr/local/cgal/lib/" >> /etc/ld.so.conf
ldconfig

安装SFCGAL

tar -zxvf SFCGAL-v1.3.10.tar.gz
cmake3 . -DCMAKE_INSTALL_PREFIX=/usr/local/sfcgal
make
make install
echo "/usr/local/sfcgal/lib64" >>  /etc/ld.so.conf
ldconfig

安装postgis

 tar -zxvf postgis-3.1.6.tar.gz
 ./configure --prefix=/usr/local/postgis --with-pgsql=/usr/local/pgsql/bin/pg_config --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-geosconfig=/usr/local/geos/bin/geos-config  --with-projdir=/usr/local/proj --with-gdalconfig=/usr/local/gdal/bin/gdal-config --with-jsondir=/usr/local/json-c  --with-protobufdir=/usr/local/protobuf-c --with-sfcgal=/usr/local/sfcgal/bin/sfcgal-config
 make
 make install

安装pointcloud

tar -zxvf pointcloud-1.2.2.tar.gz
 ./autogen.sh
./configure --prefix=/usr/local/pointcloud --with-pgconfig=/usr/local/pgsql/bin/pg_config --with-xml2config=/usr/bin/xml2-config
make
make install

安装插件

#进入postgresql-13.2下的contrib目录
cd .../postgresql-13.2/contrib/
#安装插件
cd adminpack/ && make && make install && cd ..
cd dblink/ && make && make install && cd ..
cd fuzzystrmatch/ && make && make install && cd ..
cd hstore/ && make && make install && cd ..
cd postgres_fdw/ && make && make install && cd ..
cd tablefunc/ && make && make install && cd ..
cd uuid-ossp/ && make && make install && cd ..
cd xml2/ && make && make install && cd .. 

进入数据库激活插件

ldconfig
su - postgres
psql
##
create extension postgis;
create extension postgis_raster;
create extension postgis_sfcgal;
create extension fuzzystrmatch ;
create extension postgis_tiger_geocoder;
create extension postgis_topology;
create extension adminpack;
create extension dblink ;
create extension hstore ;
create extension postgres_fdw ;
create extension tablefunc ;
create extension "uuid-ossp";
create extension xml2 ;
create extension pointcloud;
create extension pointcloud_postgis ;

测试插件是否安装成功

-- 建表
CREATE TABLE cities ( id int4, name varchar(50) );
-- 添加位置字段
SELECT AddGeometryColumn ('cities', 'the_geom', 4326, 'POINT', 2);
-- 插入几条数据
INSERT INTO cities (id, the_geom, name) VALUES (1,ST_GeomFromText('POINT(-5.911 3.115)',4326),'BeiJing,China');
INSERT INTO cities (id, the_geom, name) VALUES (2,ST_GeomFromText('POINT(-5.921 3.215)',4326),'BeiJing,China');
INSERT INTO cities (id, the_geom, name) VALUES (3,ST_GeomFromText('POINT(-5.931 3.315)',4326),'BeiJing,China');
INSERT INTO cities (id, the_geom, name) VALUES (4,ST_GeomFromText('POINT(-5.941 3.415)',4326),'BeiJing,China');
INSERT INTO cities (id, the_geom, name) VALUES (5,ST_GeomFromText('POINT(-5.951 3.515)',4326),'BeiJing,China');
INSERT INTO cities (id, the_geom, name) VALUES (6,ST_GeomFromText('POINT(-15.951 13.515)',4326),'Out,BeiJing,China');
-- 查询全表
select id,name,ST_AsText(the_geom) from cities ;
-- 查询任意两点间球面距离,并以id排序
SELECT p1.name,p2.name,ST_DistanceSphere(p1.the_geom,p2.the_geom) FROM cities AS p1, cities AS p2 WHERE p1.id > p2.id;
-- 查询矩形内的点
select id, name, ST_AsText(the_geom) from cities where the_geom && ST_SetSRID(ST_MakeBox2D(ST_POINT(-10.0,-10.0),ST_POINT(10.0,10.0)),4326);
-- 任意给出几个点,查询该空间范围内的点,第一个点和最后一个点应是同一个点
select id,name,ST_AsText(cities.the_geom) from cities where the_geom && ST_AsText(ST_MakePolygon(ST_GeomFromText('LINESTRING ( -10.31 10.97 , -10.15 -10.09 , 10.35 10.27 , 10.31 -10.97 , -10.31 10.97)')));
-- 同上
select id,name,ST_AsText(cities.the_geom) from cities where the_geom && ST_MakePolygon(ST_GeomFromText('LINESTRING ( -10.31 10.97 , -10.15 -10.09 , 10.35 10.27 , 10.09 -10.88 , 30.31 -40.97 , -1.11 60.33 , -10.31 10.97)'));
-- string应该用单引号,双引号会报错
update cities set name = 'America,LAS' where id = 5;
-- 删除数据
delete from cities where id = 6;
-- 查询距离点(-87.71 43.741)距离为151600000米的所有点
SELECT name,st_astext(the_geom) FROM cities WHERE ST_DWithin(ST_Transform(ST_GeomFromText('POINT(-87.71 43.741)',4326),26986),ST_Transform(the_geom,26986), 151600000);

标签:postgresql,--,make,离线,PostGis,pgsql,usr,&&,local
From: https://www.cnblogs.com/ajajroom/p/18434956

相关文章

  • 附录A. PostgreSQL 常用命令
    附录A.PostgreSQL常用命令附录A.PostgreSQL常用命令A.1数据定义语言(DDL)命令A.1.1创建数据库(CREATEDATABASE)A.1.2创建表(CREATETABLE)A.1.3创建索引(CREATEINDEX)A.1.4创建视图(CREATEVIEW)A.1.5创建序列(CREATESEQUENCE)A.2数据操纵语言(DML)命令A.2.1插入数据(IN......
  • Docker 教程:在 Mac M2 上运行 PostgreSQL
    前提条件  -已安装[DockerDesktop] 创建Docker卷  首先,创建一个名为`pgdata`的Docker卷,以便用于PostgreSQL数据存储。  dockervolumecreatepgdata运行PostgreSQL容器  使用以下命令启动PostgreSQL容器:  dockerrun--namepostgres -ePOS......
  • 为什么要考工信部人才交流中心PostgreSQL认证?
    为什么要考工信部人才交流中心PostgreSQL认证?随着PostgreSQL数据库在国内的使用越来越多,想要了解PostgreSQL认证的人也多了起来,有了工信部人才交流中心的PostgreSQL证书,可以获得多方面的好处。工信部人才交流中心PostgreSQL认证的发起背景:-技术优势契合信创需求:PostgreSQL数......
  • 对PostgreSQL中的慢查询进行分析和优化的操作指南例子解析
    代码示例:在PostgreSQL中对慢查询进行分析和优化是一个系统性的工作,涉及到多个方面。以下是一些操作指南和示例:识别慢查询:通过配置log_min_duration_statement参数,让PostgreSQL记录执行时间超过特定阈值的查询。使用pg_stat_statements扩展来收集查询的执行统计信息,包括......
  • PostgreSQL慢SQL的定位排查方法例子解析
    代码示例:定位和排查PostgreSQL中的慢SQL查询是一个系统性的工作,通常涉及多个步骤和工具。以下是一个详细的排查流程示例:启用慢查询日志:首先,你需要确认慢查询日志是否已经开启。可以通过查询pg_settings视图来检查log_min_duration_statement的值。如果该值为-1,则表示慢......
  • JRebel and XRebel离线安装
    近期,使用JRebelandXRebel,发现总是安装不上,可能是网络的原因吧。所以就使用离线方式进行安装。JRebel是一款用于Java开发的生产力工具。它的主要功能是加速开发周期,通过在不重启JVM的情况下即时加载代码变更。这样,开发者可以立即看到代码修改的效果,而无需重新部署应用程序,从......
  • 视频汇聚/视频存储/安防视频监控EasyCVR平台RTMP推流显示离线是什么原因?
    视频汇聚/视频存储/安防视频监控EasyCVR视频汇聚平台兼容性强、支持灵活拓展,平台可提供视频远程监控、录像、存储与回放、视频转码、视频快照、告警、云台控制、语音对讲、平台级联等视频能力。EasyCVR安防监控视频综合管理平台采用先进的网络传输技术,支持高清视频的接入和传输,能......
  • 离线一机一码验证和网络验证的区别以及使用场景 (附一机一码加密打包大师下载链接)
    本文主要介绍离线一机一码验证和网络验证的区别及其各自的特点和优势。通过对比这两种验证方式的工作原理、优缺点,使开发人员更好地理解并选择适合自己需求的验证方案。接下来,我们将详细探讨每种验证方式的具体实现和应用场景。离线一机一码验证和网络验证结合实例介绍  ......
  • EasyCVR平台RTMP推流显示离线是什么原因?
    EasyCVR安防监控视频综合管理平台采用先进的网络传输技术,支持高清视频的接入和传输,能够满足大规模、高并发的远程监控需求。有用户反馈,在测试EasyCVR平台推流功能时,OBS显示正在直播,但平台的通道状态却是离线,于是咨询我们如何处理。今天来介绍下排查及解决过程。1)首先检查防火墙是否......
  • Postgresql一行命令备份(pg_dump版)
    pg_dumppg_dump-Upostgres-Fc-dnacos-fnacos_bk.sql;一行命名备份nacos数据库-U:表示备份数据库时,使用的用户名;-Fc:表示备份文件使用传统pg风格,这种格式最灵活;-d:需要备份的数据库名;-f:备份的文件路径参考pg_dump......