溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

postgresql9.6安裝

發布時間:2020-05-16 09:54:09 來源:網絡 閱讀:4605 作者:一個笨小孩 欄目:數據庫

目前postgresql的最新版本已經是10.4 ;本次安裝的版本是9.6,大版本之間還是有很多新特性的。


1、postgresql9.6的新功能:

 ①:并行查詢

   并行查詢是9.6版本的最大亮點。在之前的版本中,即使擁有多個空閑處理器,但數據庫限制只能利用單個CPU的計算能力。9.6版本支持并行查詢操作,因此能夠利用服務器上的幾個或所有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的訪問。


向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

亚洲午夜精品一区二区_中文无码日韩欧免_久久香蕉精品视频_欧美主播一区二区三区美女