Linux:獲取Linux離線postgresql數據庫安裝包並部署


獲取離線安裝包(方法一)

1. 進入官網:https://www.postgresql.org/

2. 下載步驟

(1)點擊Download

 (2) 選擇安裝的服務器的版本

 

 (3)更新yum源

#更新yum源

sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm

(4)開始下載postgresql數據庫

#檢索postgresql版本
yum search postgres

#創建文件夾
mkdir psql10

#下載依賴包
yum install --downloadonly --downloaddir=psql10 postgresql10 postgresql10-server

(5)查看下載的依賴包

#查看下載的依賴包
root@sdcy# ls -l

libicu-50.1.2-17.el7.x86_64.rpm postgresql10-10.10-1PGDG.rhel7.x86_64.rpm postgresql10-libs-10.10-1PGDG.rhel7.x86_64.rpm postgresql10-server-10.10-1PGDG.rhel7.x86_64.rpm

(6)壓縮打包

#進行打包
tar -zcvf pgsql10.tar.gz *

獲取離線安裝包(方法二)

1. 進入官網:https://www.postgresql.org/

2. 下載步驟

(1)點擊Download

 (2)選擇安裝的服務器的版本

(3)進入選取版本號界面下拉找到 ( Direct RPM download )

 

 

 

 

 (4)選取適配系統的版本

 

 (5)開始下載

 (6)還需pg的依賴包(libicu)

下載路徑:http://www.rpmfind.net/linux/rpm2html/search.php?query=libicu&submit=Search+...&system=&arch=

 

 

 (7)壓縮打包或者直接傳到內網服務器

#進行打包
tar -zcvf pgsql.tar.gz *

離線安裝部署

將tar.gz離線安裝包拷貝到內網服務器,進行解壓並安裝

(1)解壓tar.gz包

#解壓tar.gz包
tar -zxvf pgsql10.tar.gz -C 自定義解壓路徑(例 /home/postgres)

(2)安裝依賴包

#依賴包安裝順序
1. libicu-50.1.2-17.el7.x86_64.rpm
2. postgresql10-libs-10.10-1PGDG.rhel7.x86_64.rpm
3. postgresql10-10.10-1PGDG.rhel7.x86_64.rpm
4. postgresql10-server-10.10-1PGDG.rhel7.x86_64.rpm

#開始安裝
rpm -ivh libicu-50.1.2-17.el7.x86_64.rpm
rpm -ivh postgresql10-libs-10.10-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql10-10.10-1PGDG.rhel7.x86_64.rpm
rpm -ivh postgresql10-server-10.10-1PGDG.rhel7.x86_64.rpm
#rpm命令講解

rpm -i 需要安裝的包文件名

舉例如下:

rpm -i example.rpm (安裝 example.rpm 包;)

rpm -iv example.rpm (安裝 example.rpm 包並在安裝過程中顯示正在安裝的文件信息;)

rpm -ivh example.rpm (安裝 example.rpm 包並在安裝過程中顯示正在安裝的文件信息及安裝進度;)

(3)初始化數據庫

#初始化數據庫
/usr/pgsql-10/bin/postgresql-10-setup initdb

(4)配置開機自啟

#設置開機自啟
systemctl enable postgresql-10

#開啟數據庫
systemctl start postgresql-10

service postgresql-10 initdb

chkconfig postgresql-10 on

(5)配置/etc/hosts

 (6)添加主機ip和主機名

#編輯conf文件
vi /var/lib/pgsql/10/data/postgresql.conf

 (7)自定義開放訪問的IP

#編輯conf文件
vi /var/lib/pgsql/10/data/pg_hba.conf

 (8)重啟postgresql

#重啟postgresql數據庫
systemctl restart postgresql-10

su postgres

psql

(9)創建數據庫用戶

#創建數據庫用戶
create user postgres password ‘postgres ’;

(10)賦予賬號權限

#賦予權限
ALTER ROLE postgres SUPERUSER;

(11)新建數據庫

#新建數據庫
create database pg;

(12)測試連接

#登錄postgres
psql -U postgres -d postgres -h localhost -W
回車輸入密碼
postgres

#顯示數據庫
\l

 

安裝完成!

 

文章整合至:https://blog.csdn.net/TheDreamMaster/article/details/90318602https://blog.csdn.net/qq_36395686/article/details/100133098


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM