postgresql9.6インストール


現在postgresqlの最新バージョンは10.4です.今回インストールされたバージョンは9.6で、大きなバージョンの間には新しい特性がたくさんあります.
1、postgresql9.6の新機能:
①:パラレルクエリ
パラレルクエリは、バージョン9.6の最大のハイライトです.以前のバージョンでは、複数の空きプロセッサがあったとしても、データベース制限は単一のCPUの計算能力しか利用できませんでした.バージョン9.6ではパラレルクエリ操作がサポートされているため、サーバ上のいくつかのCPUコアまたはすべてのCPUコアを使用して演算することができ、クエリの結果をより迅速に返すことができます.現在、パラレル特性をサポートする操作には、シーケンステーブルのスキャン、集約、エッジ接続があり、操作の詳細や利用可能なカーネルの数によって、ビッグデータの検索効率が向上し、最速で32倍程度に達することができます.
   
②:同期コピー機能の改善:
postgresqlの同期レプリケーション機能は、データベースクラスタの一貫した読み取りのメンテナンスに使用できるように改善されます.まず、同期レプリケーショングループを構成できます.次に、remote_applyモードでは、複数のノードを介してより統一的なインスタンスを作成します.これらのプロパティは、内蔵の自己レプリケーション機能を使用して、独立したノードの負荷分散を維持することをサポートします.
③:フレーズ検索
postgresqlのテキスト検索機能は、フレーズ検索をサポートします.ユーザーは、正確なフレーズを検索したり、類似性のあるフレーズを検索したりすることができます.
高速GINインデックスの単語を使用して、微調整可能なテキスト検索の新しい機能と組み合わせて、postgresqlはすでに「混合検索」の最適な選択となっています.
④:より良いロック監視
   pg_stat_Activityビューでは、プロセスがロックを待っている間にロックのタイプと、クエリーをブロックする待機イベントの詳細が表示されます.さらにpostgresqlはpg_を追加しましたblocking_pids()関数は、指定されたサーバプロセスをブロックするプロセスを知ることができます.
⑤:制御テーブル膨張
これまで、クエリーの結果を表示する長時間実行されたレポートまたはカーソルは、失効したローのクリーンアップを阻止し、データベース内で頻繁に変化するテーブルを膨張させ、データベースのパフォーマンスの問題やストレージ領域の過度な使用を引き起こす可能性があります.
バージョン9.6でold_が追加されましたsnapshot_thresholdパラメータは、クラスタを構成して、トランザクションの更新または削除時に失効したローを消去し、テーブルの膨張を制限します.
さらに、9.6バージョンでは、カスケード操作(拡張モジュール実装をインストールする必要がある)、frozenページのより良い空間回収メカニズム、ローカルインデックスのみのスキャン、コマンド実行の進捗状況レポートのサポート、外部ソート操作のパフォーマンスの改善など、他の機能も追加されました.
--PGバイナリパッケージをダウンロードした後、解凍:
[root@localhost ~]# tar -zxvf postgresql-9.6.9-1-linux-x64-binaries.tar.gz -C/usr/src/
[root@localhost ~]# groupadd pguser
[root@localhost ~]# useradd -g pguser pguser
[root@localhost ~]# passwd pguser
[root@localhost ~]# su - pguser
--PGデータベースを初期化する:
[pguser@localhost ~]$ cd /usr/src/pgsql/bin/
[pguser@localhost bin]$ ./initdb -E uft8 -D /pgsql/data/
The files belonging to this database system will be owned by user "pguser".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
initdb: "uft8" is not a valid server encoding name
[pguser@localhost bin]$ ./initdb -E utf8 -D /pgsql/data/
The files belonging to this database system will be owned by user "pguser".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.UTF-8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /pgsql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
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 /pgsql/data/ -l logfile start
--:      ,~/.bash_profile       
PATH=/usr/local/pgsql/bin:$PATH
export PATH
--     :
[pguser@localhost ~]$ source .bash_profile 
[pguser@localhost ~]$ pg_ctl -D /pgsql/data/ -l /home/pguser/postgres.log start
server starting
   :
./postgres -D /pgsql/data > /pgsql/data/postgres.log &

注意:
データベースのインストールが完了すると、システム・ユーザー、データベース・ユーザー、デフォルトの名前はpostgresです.
[root@localhost ~]# ps -ef |grep postgre
pguser    14160      1  0 01:36 pts/0    00:00:00/usr/src/pgsql/bin/postgres -D/pgsql/data
pguser    14162  14160  0 01:36 ?        00:00:00 postgres: checkpointer process   
pguser    14163  14160  0 01:36 ?        00:00:00 postgres: writer process   
pguser    14164  14160  0 01:36 ?        00:00:00 postgres: wal writer process   
pguser    14165  14160  0 01:36 ?        00:00:00 postgres: autovacuum launcher process   
pguser    14166  14160  0 01:36 ?        00:00:00 postgres: stats collector process   
pguser    14246  14160  0 01:42 ?        00:00:00 postgres: pguser testdb [local] idle
root      14256  14009  0 01:42 pts/1    00:00:00 grep --color=auto postgre
--接続テスト:
[pguser@localhost ~]$ psql --list
                               List of databases
   Name    | Owner  | Encoding |   Collate   |    Ctype    | Access privileges 
-----------+--------+----------+-------------+-------------+-------------------
 postgres  | pguser | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | pguser | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pguser        +
           |        |          |             |             | pguser=CTc/pguser
 template1 | pguser | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/pguser        +
           |        |          |             |             | pguser=CTc/pguser
 testdb    | pguser | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
(4 rows)
--データベースにログインします(postgresがデータベースであることを上から確認します).
[pguser@localhost ~]$ psql postgres
psql.bin (9.6.9)
Type "help"for help.
postgres=# select version();
                                                 version                                                  
----------------------------------------------------------------------------------------------------------
 PostgreSQL 9.6.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16), 64-bit
(1 row)
postgres=# 
postgres=#q---PGデータベースを終了する:
またはdbを作成します.
[pguser@localhost ~]$ createdb  testdb
[pguser@localhost~]$psql-d testdb---testdbにログイン
psql.bin (9.6.9)
Type "help"for help.
testdb=# select version();
                                                 version                                                  
----------------------------------------------------------------------------------------------------------
 PostgreSQL 9.6.9 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16), 64-bit
(1 row)
testdb-#\q
pg_ctl-D/pgsql/data stop--PGデータベースを閉じる
 
注意:
pgadminはpostgresqlデータベースを設計、維持、管理する汎用ツールであり、Windows、Linux、freeBSD、mac、solarisプラットフォームで実行できます.pgadminツールは簡単で直感的で、データベースにアクセス、クエリー、制御、管理することができ、同時に多様なグラフィックツールと多種の機能がそろったスクリプトエディタを統合し、各種開発者のpostgresqlへのアクセスを極めて便利にした.