目前postgresql的最新版本已經(jīng)是10.4 ;本次安裝的版本是9.6,大版本之間還是有很多新特性的。
1、postgresql9.6的新功能:
①:并行查詢
并行查詢是9.6版本的大亮點(diǎn)。在之前的版本中,即使擁有多個(gè)空閑處理器,但數(shù)據(jù)庫限制只能利用單個(gè)CPU的計(jì)算能力。9.6版本支持并行查詢操作,因此能夠利用服務(wù)器上的幾個(gè)或所有CPU內(nèi)核進(jìn)行運(yùn)算,這樣講更快返回查詢結(jié)果。目前支持并行特性的操作有順序表掃描、聚合和邊接,根據(jù)操作細(xì)節(jié)和可用內(nèi)核數(shù)目的不同,該并行特性可提高對(duì)大數(shù)據(jù)的檢索效率,最快時(shí)可高達(dá)32倍左右。
②:同步復(fù)制功能的改進(jìn):
postgresql的同步復(fù)制功能能得到改進(jìn),使它能夠用于數(shù)據(jù)庫集群一致讀取的維護(hù)。首先,它現(xiàn)在允許配置同步復(fù)制組,其次,“remote_apply”模式通過多重節(jié)點(diǎn)創(chuàng)建一個(gè)更具統(tǒng)一性的實(shí)例。這些特性支持使用內(nèi)置的自我復(fù)制功能來維護(hù)獨(dú)立節(jié)點(diǎn)的負(fù)載均衡。
③:短語搜索
postgresql的文本搜索功能,現(xiàn)在支持短語搜索。用戶可以搜索精確的某個(gè)短語或者搜索有一定相似性的短語。
使用快速的GIN索引中的單詞,結(jié)合可精細(xì)調(diào)整的文本搜索的新功能,postgresql已經(jīng)成為“混合搜索”的最佳選擇。
④:更好的鎖監(jiān)控
pg_stat_activity視圖提供了更加詳細(xì)的等待信息,當(dāng)一個(gè)進(jìn)程正在等待一個(gè)鎖時(shí),用戶會(huì)看到鎖的類型,以及將查詢阻塞的等待事件的詳細(xì)信息。此外,postgresql還增加了pg_blocking_pids()函數(shù),可以知道哪些進(jìn)程阻塞給定的服務(wù)器進(jìn)程。
⑤:控制表膨脹
到目前為止,一個(gè)長(zhǎng)時(shí)間運(yùn)行的顯示查詢結(jié)果的報(bào)告或游標(biāo)均可能阻止失效行的清理,從而使數(shù)據(jù)庫中經(jīng)常變化的表膨脹,導(dǎo)致數(shù)據(jù)庫的性能問題和存儲(chǔ)空間的過度使用。
9.6版本中添加了old_snapshot_threshold參數(shù),可以將集群配置為允許在更新或刪除事務(wù)時(shí)清除失效行,從而限制表膨脹。
此外,9.6版本還添加了其他功能,例如,支持級(jí)聯(lián)操作(需安裝擴(kuò)展模塊實(shí)現(xiàn)),frozen頁面更好的空間回收機(jī)制,只掃描局部索引,支持命令執(zhí)行進(jìn)度狀態(tài)報(bào)告,外部排序操作的性能改進(jìn)等。
--下載PG二進(jìn)制軟件包后,解壓:
[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數(shù)據(jù)庫:
[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 --:配置環(huán)境變量,~/.bash_profile 添加如下內(nèi)容 PATH=/usr/local/pgsql/bin:$PATH export PATH --啟動(dòng)數(shù)據(jù)庫: [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 &注意:
當(dāng)安裝完數(shù)據(jù)庫后,我們會(huì)有一個(gè)系統(tǒng)用戶,一個(gè)數(shù)據(jù)庫,一個(gè)數(shù)據(jù)庫用戶,他們默認(rèn)的名稱為: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
--連接測(cè)試:
[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)
--登錄數(shù)據(jù)庫(從上面查看得知 postgres是一個(gè)數(shù)據(jù)庫,)
[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數(shù)據(jù)庫:
或者創(chuàng)建一個(gè)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 --關(guān)閉PG數(shù)據(jù)庫
注意:
pgadmin 是一個(gè)設(shè)計(jì)、維護(hù)和管理postgresql數(shù)據(jù)庫的通用工具,可以運(yùn)行在Windows,Linux,freeBSD,mac,solaris平臺(tái)上。pgadmin工具簡(jiǎn)單簡(jiǎn)易直觀,可訪問、查詢、控制和管理數(shù)據(jù)庫,同時(shí)還對(duì)多樣化的圖形工具與多種功能齊全的腳本編輯器進(jìn)行整合,極大方便了各種開發(fā)人員對(duì)postgresql的訪問。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
新聞名稱:postgresql9.6安裝-創(chuàng)新互聯(lián)
網(wǎng)站URL:http://www.chinadenli.net/article46/psseg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站設(shè)計(jì)、靜態(tài)網(wǎng)站、電子商務(wù)、服務(wù)器托管、品牌網(wǎng)站設(shè)計(jì)、移動(dòng)網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容