溫馨提示×

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

密碼登錄×
登錄注冊(cè)×
其他方式登錄
點(diǎn)擊 登錄注冊(cè) 即表示同意《億速云用戶服務(wù)條款》

源碼編譯怎么安裝pg11.5

發(fā)布時(shí)間:2021-11-05 11:16:34 來源:億速云 閱讀:173 作者:iii 欄目:關(guān)系型數(shù)據(jù)庫(kù)

這篇文章主要介紹“源碼編譯怎么安裝pg11.5”,在日常操作中,相信很多人在源碼編譯怎么安裝pg11.5問題上存在疑惑,小編查閱了各式資料,整理出簡(jiǎn)單好用的操作方法,希望對(duì)大家解答”源碼編譯怎么安裝pg11.5”的疑惑有所幫助!接下來,請(qǐng)跟著小編一起來學(xué)習(xí)吧!

 一、環(huán)境準(zhǔn)備

1、安裝依賴包

yum -y install gcc*  

yum -y install python python-devel  

yum -y install perl-ExtUtils-Embed  

yum -y install zlib-devel

yum -y install readline*

2、創(chuàng)建用戶組、目錄

groupadd -g 1001 postgres    #新增用戶組

useradd -g 1001 -u 1001 postgres    #新增用戶

[root@pg11 ~]# id postgres

uid=1001(postgres) gid=1001(postgres) groups=1001(postgres)

passwd postgres    #為用戶設(shè)置密碼

 3、創(chuàng)建目錄

mkdir -p /usr/local/pgsql11.5

chown -R postgres:postgres /usr/local/pgsql11.5/

mkdir -p /home/osdata/pgdata

chown -R postgres:postgres /home/osdata/

chmod 0700 /home/osdata/pgdata

4、修改環(huán)境變量(postgres用戶)

export PATH=/usr/local/pgsql11.5/bin:$PATH

export LD_LIBRARY_PATH=/usr/local/pgsql11.5/lib

export PGDATA=/home/osdata/pgdata

 5、上傳軟件包,并且解壓縮(root)

[root@pg11 pgsql11.5]# ll

total 19312

-rw-r--r--. 1 root root 19773087 Oct 30 20:05 postgresql-11.5.tar.bz2

[root@pg11 pgsql11.5]#chown -R postgres:postgres /usr/local/pgsql11.5/

[root@pg11 pgsql11.5]# ll

total 19312

-rw-r--r--. 1 postgres postgres 19773087 Oct 30 20:05 postgresql-11.5.tar.bz2

tar -xvf postgresql-11.5.tar.bz2

 6、生成鏈接

ln -sf /usr/local/pgsql11.5 /usr/local/pgsql

二、安裝postgresql

1、編譯

cd postgresql-11.5/

./configure --prefix=/usr/local/pgsql11.5 --with-perl --with-python

2、安裝

一次性把文檔及附加模塊全部進(jìn)行編譯和安裝

gmake world

出現(xiàn)“PostgreSQL, contrib, and documentation successfully made. Ready to install.”說明編譯成功

gmake install-world

出現(xiàn)“PostgreSQL, contrib, and documentation installation complete.”說明安裝成功

查看版本

[postgres@pg11 postgresql-11.5]$ postgres --version

postgres (PostgreSQL) 11.5

 3、初始化數(shù)據(jù)庫(kù)

initdb -D /home/osdata/pgdata/ -W

 4、啟動(dòng)數(shù)據(jù)庫(kù)

pg_ctl -D $PGDATA -l logfile start

5、查看實(shí)例進(jìn)程

[postgres@pg ~]$ ps -ef|grep postgres

postgres  56625      1  0 Mar04 ?        00:00:03 /usr/local/pgsql11.5/bin/postgres -D /home/osdata/pgdata

postgres  56627  56625  0 Mar04 ?        00:00:00 postgres: checkpointer   

postgres  56628  56625  0 Mar04 ?        00:00:01 postgres: background writer   

postgres  56629  56625  0 Mar04 ?        00:00:01 postgres: walwriter   

postgres  56630  56625  0 Mar04 ?        00:00:05 postgres: autovacuum launcher   

postgres  56631  56625  0 Mar04 ?        00:00:10 postgres: stats collector   

postgres  56632  56625  0 Mar04 ?        00:00:00 postgres: logical replication launcher   

root      76758  76699  0 11:01 pts/0    00:00:00 su - postgres

postgres  76759  76758  0 11:01 pts/0    00:00:00 -bash

postgres  76797  76759  0 11:01 pts/0    00:00:00 psql

postgres  76801  56625  0 11:01 ?        00:00:00 postgres: postgres test [local] idle

root      77192  77145  0 11:21 pts/1    00:00:00 su - postgres

postgres  77193  77192  0 11:21 pts/1    00:00:00 -bash

postgres  79582  77193  0 13:45 pts/1    00:00:00 ps -ef

postgres  79583  77193  0 13:45 pts/1    00:00:00 grep --color=auto postgres

查看數(shù)據(jù)庫(kù)狀態(tài)

[postgres@pg11 ~]$ pg_ctl -D /home/osdata/pgdata/ status

pg_ctl: server is running (PID: 23588)

/usr/local/pgsql11.5/bin/postgres "-D" "/home/osdata/pgdata"

 6、設(shè)置開機(jī)自啟動(dòng)

配置腳本服務(wù)

在源碼包的contrib目錄中有l(wèi)inux、freebsd、macos適用的服務(wù)腳本

[root@pg11 ~]# cd /usr/local/pgsql/postgresql-11.5/contrib/start-scripts

[root@pg11 start-scripts]# ll

total 8

-rw-r--r--. 1 postgres postgres 1467 Aug  6  2019 freebsd

-rw-r--r--. 1 postgres postgres 3552 Aug  6  2019 linux

drwxrwxr-x. 2 postgres postgres   84 Aug  6  2019 macos

把名為linux的腳本拷貝到/etc/init.d目錄,并且重命名為postgresql11

[root@pg11 ~]# cp /usr/local/pgsql/postgresql-11.5/contrib/start-scripts/linux /etc/init.d/postgresql11

[root@pg11 init.d]# chmod +x postgresql-11

[root@pg11 init.d]# chkconfig postgresql-11 on

[root@pg11 init.d]# chkconfig --list |grep postgresql-11

postgresql-11   0:off   1:off   2:on    3:on    4:on    5:on    6:off

7、登錄數(shù)據(jù)庫(kù)

[postgres@pg ~]$ psql

psql (11.5)

Type "help" for help.

postgres=#

到此,關(guān)于“源碼編譯怎么安裝pg11.5”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注億速云網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)砀鄬?shí)用的文章!

向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

pg
AI