2020国产成人精品视频,性做久久久久久久久,亚洲国产成人久久综合一区,亚洲影院天堂中文av色

分享

Postgresql源碼安裝

 highoo 2019-05-19

以在64位CentOS6.5操作系統(tǒng)上源碼安裝postgresql-9.6beta1為例

 

一.進入官網(wǎng)下載代碼(postgresql-9.6beta1.tar.gz)

https://www.

 

二.將源碼上傳到服務(wù)器/home/alian目錄下

可以在windows安裝ssh或xftp工具,也可以在CentOS安裝lrzsz的rpm包(使用rz,sz命令)上傳或下載文件。

 

三.將源碼在當(dāng)前目錄下解壓

[root@localhost alian]# tar xzvf postgresql-9.6beta1.tar.gz

 

四.進入解壓后的目錄postgresql-9.6beta1,使用configure工具查看編譯幫助

[root@localhost postgresql-9.6beta1]# ./configure --help

 

五.根據(jù)幫助中各配置描述選擇適合自己的配置選項

如下命令中

--prefix=/opt/pg9.6

pg軟件的安裝路徑

 

以下4個配置不是必須的,但如果想修改必須要重新initdb

--with-segsize=1

表在操作系統(tǒng)上物理文件大小,單位GB,默認(rèn)值為1,如果表大于1GB,將在操作系統(tǒng)上分割成多個1GB的文件。

--with-blocksize=32

塊大小,單位KB,默認(rèn)值為8,是表數(shù)據(jù)I/O和存儲的單元,范圍1-32,且必須是2的N次方。

--with-wal-segsize=32

WAL在操作系統(tǒng)上物理文件大小,單位MB,默認(rèn)值16,范圍1-64,且必須是2的N次方。

--with-wal-blocksize=64

WAL塊大小,單位KB,是WAL I/O和存儲的單元,范圍1-64,且必須是2的N次方。

復(fù)制代碼
[root@localhost postgresql-9.6beta1]# ./configure --prefix=/opt/pg9.6 --with-segsize=1 --with-blocksize=32 --with-wal-segsize=32 --with-wal-blocksize=64


checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking which template to use... linux
checking whether to build with 64-bit integer date/time support... yes
checking whether NLS is wanted... no
checking for default port number... 5432
checking for block size... 32kB
checking for segment size... 1GB
checking for WAL block size... 64kB
checking for WAL segment size... 32MB
checking for gcc... gcc

..............
復(fù)制代碼

 

 

configure過程中可能會出現(xiàn)下面的錯誤,原因是缺少對應(yīng)的庫,安裝對應(yīng)的庫即可。

復(fù)制代碼
configure: error: readline library not found

[root@localhost postgresql-9.6beta1]# yum install readline-devel

 configure: error: zlib library not found

[root@localhost postgresql-9.6beta1]# yum install zlib-devel
復(fù)制代碼

 

 

六.configure成功后,可以直接執(zhí)行make命令進行簡單編譯,也可以執(zhí)行make world將contrib目錄下的擴展工具一起編譯,當(dāng)然也可以先進行簡單編譯,然后進入contrib下對某一工具進行單獨編譯

方法一:簡單安裝

1.執(zhí)行命令

[root@localhost postgresql-9.6beta1]# make && make install

命令執(zhí)行完之后,pg軟件就被安裝到/opt/pg9.6路徑下

[root@localhost postgresql-9.6beta1]# ls /opt/pg9.6/
bin include lib share

 

2.如果想安裝contrib下的某一擴展工具,以檢測數(shù)據(jù)庫運行的pg_stat_statements為例

進入contrib/pg_stat_statements目錄下(前提是已在主目錄下執(zhí)行了configure)

[root@localhost postgresql-9.6beta1]# cd contrib/pg_stat_statements/

 

執(zhí)行命令

[root@localhost pg_stat_statements]# make && make install

 

方法二、全部安裝(contrib下所有的擴展工具)

[root@localhost postgresql-9.6beta1]# make world && make install-world

 

七、軟件安裝完成后,進行初始化

1.新建一個用戶postgres

[root@localhost postgresql-9.6beta1]# groupadd postgres

[root@localhost postgresql-9.6beta1]# useradd postgres

 

2.創(chuàng)建PGDATA目錄

[root@localhost postgresql-9.6beta1]# mkdir -p /mnt/pgdata
[root@localhost postgresql-9.6beta1]# chown postgres:postgres /mnt/pgdata/

 

3.使用postgres用戶初始化

[root@localhost postgresql-9.6beta1]# su postgres

[postgres@localhost postgresql-9.6beta1]$ /opt/pg9.6/bin/initdb -D /mnt/pgdata -E UTF8 --locale=C

 

4.使用postgres用戶啟停數(shù)據(jù)庫

復(fù)制代碼
[postgres@localhost postgresql-9.6beta1]$ /opt/pg9.6/bin/pg_ctl -D /mnt/pgdata/ start
server starting

[postgres@localhost postgresql-9.6beta1]$ /opt/pg9.6/bin/pg_ctl -D /mnt/pgdata/ stop
waiting for server to shut down....LOG: database system is shut down
done
server stopped
復(fù)制代碼

 

5.修改配置文件,使用客戶端訪問數(shù)據(jù)庫

初始化完成后,會自動為數(shù)據(jù)庫創(chuàng)建一個超級用戶postgres(執(zhí)行initdb的用戶),但是數(shù)據(jù)庫還沒有給該用戶設(shè)置訪問密碼,所以啟動數(shù)據(jù)庫后,執(zhí)行下面的命令,給該用戶配置一個密碼

復(fù)制代碼
[postgres@localhost postgresql-9.6beta1]$ /opt/pg9.6/bin/psql -U postgres
psql (9.6beta1)
Type "help" for help.

postgres=# alter user postgres with password 'password';
ALTER ROLE
postgres=# \q
復(fù)制代碼

 

另外,在PGDATA目錄下生成配置文件pg_hba.conf和postgresql.conf,

postgresql.conf中配置#listen_addresses = 'localhost',表示只監(jiān)聽本地連接,將此配置改成*用來監(jiān)聽所有IP的訪問,也可以指定特定的IP(注意前面的注釋符#刪掉)

listen_addresses = '*'

 

pg_hba.conf主要內(nèi)容如下

復(fù)制代碼
# "local" is for Unix domain socket connections only
local all all trust
# IPv4 local connections:
host all all 127.0.0.1/32 trust
# IPv6 local connections:
host all all ::1/128 trust
復(fù)制代碼

 

其中trust表示允許無密碼訪問,這是不安全的,將其改為md5,使用密碼訪問。

復(fù)制代碼
# "local" is for Unix domain socket connections only

local all all md5
# IPv4 local connections:
host all all 127.0.0.1/32 md5
# IPv6 local connections:
host all all ::1/128 md5
復(fù)制代碼

 

修改完密碼和配置文件后重啟服務(wù)再次訪問數(shù)據(jù)庫時就會提示輸入密碼

復(fù)制代碼
[postgres@localhost postgresql-9.6beta1]$ /opt/pg9.6/bin/psql -U postgres
Password for user postgres: 
psql (9.6beta1)
Type "help" for help.

postgres=#
復(fù)制代碼

 

 

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多