Centos7完全オフラインインストールpostgresql12.5およびpostgis3.0プラグインチュートリアル

                                                        Centos7完全オフラインインストールpostgresql12.5およびpostgis3.0プラグインチュートリアル

1. Postgresql12.5インストールパッケージとpostgis3.0プラグインおよび関連する依存関係のダウンロードアドレス:

リンク:https://pan.baidu.com/s/12GFnU_kdCJ_4UtJ3F03oXw
抽出コード: 
このコンテンツをコピーした後、このコンテンツをコピーした後にBaidu SkyDriveモバイルアプリを開くと、操作がより便利になります--- BaiduSkyDrive スーパーメンバーV3から共有

オフラインインストールパッケージの内容に関する注意:ファイルには、postgresql12.5インストールパッケージ、postgis3.0インストールパッケージ、および必要な4つの依存関係と2つのjson-c依存rpmパッケージが含まれています。

2.設置前の環境準備

ローカルウェアハウスの場合、ウェアハウスはシステムを使用してISOファイルをインストールするか、公式WebサイトからすべてのISOファイルをダウンロードします。ローカルウェアハウスが構築されたら、次のコマンドを実行します。

yum install gcc gcc-c ++ openssl openssl-devel readline readline-devel -y

すべてのインストールはオフラインであり、それらはすべてソースコードのコンパイルおよびインストール方法であることに注意してください。オペレーティングシステムはcentos7.2を使用します。

通常のユーザーpostgresを追加します。新しいユーザーコマンドはuseraddpostgresです。

最初のステップでダウンロードしたファイルをサーバーにアップロードします。

3.postgresql12.5のインストール

postgresql-12.5.tar.bz2ファイルを見つけて解凍します。解凍コマンドは次のとおりです。tarjxfpostgresql-12.5.tar.bz2

解凍されたディレクトリに入り、次のコマンドを実行します。./configure--prefix = / usr / local / pgsql && make && make install

上の図に示すように、インストールは成功し、postgresqlは非常にユーザーフレンドリーであり、操作とメンテナンスのために起動スクリプトが準備されています。

 

ソースコードパッケージには起動スクリプトが付属しており、スクリプトパスは次のとおりです(コンパイル前に指定された/ usr / local / pgsqlではなく、ソースコードパッケージであることに注意してください)。

[root @ centos7 start-scripts] #pwd
/usr/local/src/postgresql-9.5.24/contrib/start-scripts
[root @ centos7 start-scripts] #ll
total 8
-rw-r--r-- 1 1107 1107 1529 Nov 10 06:34 freebsd
-rw-r--r-- 1 1107 1107 3642 Nov 10 06:34 linux
drwxrwxrwx 2 1107 1107 84 Nov 10 06:45 macos
drwxrwxrwx 2 1107 1107 87 Nov 10 06:45 osx

cp /usr/local/src/postgresql-9.5.24/contrib/start-scripts/linux /etc/init.d/pgsql && chmod + x /etc/init.d/pgsql && chown -Rf /etc/init.d / pgsql#起動スクリプトをself-startupディレクトリにコピーして実行可能権限を付与し、所属するグループをpostgresユーザーに変更します。(rootユーザーは、serviceコマンドを使用して、所属するグループを変更するだけでサービスを開始および停止できます)。

スクリプトで使用される変数は、環境変数の設定に1対1で対応している必要があります。環境変数の設定は次のとおりです。vim/ etc / profile

PGD​​ATA = / usr / local / pgsql / data
export PGDATA
PGHOME = / usr / local / pgsql
export PGHOME
PATH = $ PATH:$ PGHOME / bin:$ PGDATA
export PATH PGDATA

 

pgデータベースを初期化します

環境変数が設定されているため、initdbを直接実行できます。(この手順はバイナリインストールに似ています)、ここでは通常のユーザーを使用してこのコマンドを実行する必要があります。つまり、通常のユーザーpostgresに切り替えます。

コマンドinitdb-dを使用して目的のパスを再指定する場合(ターゲットパスは空である必要があり、postgresユーザーにはこのパスの読み取りと書き込みの権限があることに注意してください)。-dパラメーターが指定しない場合、初期化プログラムは/ etc / profileで定義されたデータベースパスを使用します。

次の図は、データベースの初期化の成功したデモンストレーションを示しています。

[postgres@centos2 ~]$ initdb
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

creating directory /usr/local/pgsql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting default time zone ... PRC
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok

initdb: warning: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.

Success. You can now start the database server using:

    pg_ctl -D /usr/local/pgsql/data -l logfile start

起動スクリプトを使用して、pgサービスの開始、停止、およびステータスのクエリを管理します

service pgsql start | stop | status | restart

[root@centos2 postgresql-12.5]# service pgsql status
pg_ctl: no server running
[root@centos2 postgresql-12.5]# service pgsql start
Starting PostgreSQL: ok
[root@centos2 postgresql-12.5]# ps -ef | grep postgre
postgres  39004      1  0 20:21 ?        00:00:00 /usr/local/pgsql/bin/postmaster -D /usr/local/pgsql/data
postgres  39006  39004  0 20:21 ?        00:00:00 postgres: checkpointer   
postgres  39007  39004  0 20:21 ?        00:00:00 postgres: background writer   
postgres  39008  39004  0 20:21 ?        00:00:00 postgres: walwriter   
postgres  39009  39004  0 20:21 ?        00:00:00 postgres: autovacuum launcher   
postgres  39010  39004  0 20:21 ?        00:00:00 postgres: stats collector   
postgres  39011  39004  0 20:21 ?        00:00:00 postgres: logical replication launcher   
root      39013   1229  0 20:21 pts/0    00:00:00 grep --color=auto postgre

上の写真は、サービスの正常な開始のスクリーンショットです

4.ハイバージョンcmakeのインストールと構成

 

この例では、解凍して名前をcmakeに変更し、パスは/ usr / local / cmakeで、環境変数の構成は次のとおりです。vim/ etc / profile

CMAKE_HOME = / usr / local / cmake
PATH = $ PATH:$ CMAKE_HOME / bin
export PATH

5.gdalのコンパイルとインストールに依存します

tar xf gdal-2.1.3.tar.xz 
    cd gdal-2.1.3/ 
    ./configure --prefix=/usr/local/gdal
    echo $?
     make && make install

ここで、指定されたパスは後でpostgisを参照するためのものであることを説明する必要があります。デフォルトがの場合、環境変数の構成は簡単ではありません。 

成功したコンパイルのスクリーンショット:

6、geosのコンパイルとインストールに依存します

tar jxf geos-3.8.0.tar.bz2
cd geos-3.8.0/src
cmake ../
make && make install

 成功したコンパイルのスクリーンショット:

7、proj4のコンパイルとインストールに依存します

 tar zxf proj-4.9.3.tar.gz 
 cd proj-4.9.3/
  ./configure 
    make && make install
    echo $?

 正常にコンパイルされたスクリーンショット(実行可能プログラムプロジェクトがあります):

8.json-cをコンパイルしてインストールします

コンパイルする前に、フォルダーに2つのrpmパッケージをインストールする必要があります。これらの2つのrpmパッケージは、json-cに強く依存しています。インストールコマンドは次のとおりです。rpm-ivh* .rpm

次の図は、json-cの公式のコンパイル手順を示しています。

  unzip mirrors-json-c-master.zip 
  cd json-c/
  mkdir build
  cd build/
     cmake ../
     make && make install

9、postgisをコンパイルしてインストールします

vim /etc/ld.so.conf

/usr/local/lib
/usr/local/lib64
/usr/local/pgsql/lib

これは長文です。3行目はpostgresqlのlibライブラリの場所を示しています。pgがインストールされている場所に記述してください。この例では、pgは/ usr / local / pgsqlの下にインストールされているため、注意が必要です。このように書く! 

/ etc / profileのように効果的である必要があります。コマンドは次のとおりです。ldconfig

エクスポートLD_LIBRARY_PATH = / usr / local / lib:$ LD_LIBRARY_PATH:/ usr / local / include /

エクスポートPKG_CONFIG_PATH = / usr / local / lib / pkgconfig

./configure --with-pgconfig = / usr / local / pgsql / bin / pg_config --with-gdalconfig = / usr / local / gdal / bin / gdal-config

make && make install
 

成功したプリコンパイルのスクリーンショット:

--------------- Extensions --------------- 
  PostGIS Raster:                     enabled
  PostGIS Topology:                   enabled
  SFCGAL support:                     disabled
  Address Standardizer support:       disabled

 -------- Documentation Generation -------- 
  xsltproc:             /usr/bin/xsltproc
  xsl style sheets:     
  dblatex:              
  convert:              
  mathml2.dtd:          http://www.w3.org/Math/DTD/mathml2/mathml2.dtd

 成功したコンパイルのスクリーンショット:

for OLD_VERSION in 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.1.9 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.2.7 2.2.8 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.3.5 2.3.6 2.3.7 2.3.8 2.3.9 2.3.10 2.3.11 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.4.8 2.4.9 2.5.0 2.5.1 2.5.2 2.5.3 2.5.4 3.0.0alpha4 3.0.0beta1 3.0.0rc1 3.0.0rc2; do \
	ln -fs "${tpl}" /usr/local/pgsql/datadir/extension/postgis_topology--$OLD_VERSION--3.0.0.sql; \
done
/usr/bin/install -c -m 644 .//postgis_topology.control '/usr/local/pgsql/datadir/extension/'
/usr/bin/install -c -m 644  postgis_topology.control sql/postgis_topology--3.0.0.sql sql/postgis_topology--unpackaged--3.0.0.sql  '/usr/local/pgsql/datadir/extension/'
make[2]: Leaving directory `/root/postgis-3.0.0/extensions/postgis_topology'
make[1]: Leaving directory `/root/postgis-3.0.0/extensions'
[root@centos6 postgis-3.0.0]# echo $?
0

postgresqlサービスを開始し、コマンドライン操作インターフェイスに入り、次のコマンドを実行します。 

拡張postgisを作成する

select * from pg_available_extensions where name like'postgis% ';

プラグインの通常の状態は少なくとも3行です。

postgres=# select * from pg_available_extensions where name like 'postgis%';
          name          | default_version | installed_version |                               comment                               
------------------------+-----------------+-------------------+---------------------------------------------------------------------
 postgis                | 3.0.0           | 3.0.0             | PostGIS geometry, geography, and raster spatial types and functions
 postgis_tiger_geocoder | 3.0.0           |                   | PostGIS tiger geocoder and reverse geocoder
 postgis_topology       | 3.0.0           |                   | PostGIS topology spatial types and functions
 postgis_raster         | 3.0.0           |                   | PostGIS raster types and functions
(4 rows)

 

 

 

 

 

おすすめ

転載: blog.csdn.net/alwaysbefine/article/details/114874242