023.PGSQL-linux下的安裝教程
阿新 • • 發佈:2021-06-22
參考部落格 https://www.cnblogs.com/ningy1009/p/14467751.html
官網下載地址
https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
1.下載倉庫源
[root@s101 /root]#sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm Loaded plugins: fastestmirror Repodata is over2 weeks old. Install yum-cron? Or run: yum makecache fast pgdg-redhat-repo-latest.noarch.rpm | 7.4 kB 00:00:00 Examining /var/tmp/yum-root-Xd3oez/pgdg-redhat-repo-latest.noarch.rpm: pgdg-redhat-repo-42.0-17.1.noarch Marking /var/tmp/yum-root-Xd3oez/pgdg-redhat-repo-latest.noarch.rpm to be installed Resolving Dependencies--> Running transaction check ---> Package pgdg-redhat-repo.noarch 0:42.0-17.1 will be installed --> Finished Dependency Resolution Dependencies Resolved ===================================================================================================================================== Package Arch Version Repository Size===================================================================================================================================== Installing: pgdg-redhat-repo noarch 42.0-17.1 /pgdg-redhat-repo-latest.noarch 11 k Transaction Summary ===================================================================================================================================== Install 1 Package Total size: 11 k Installed size: 11 k Downloading packages: Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : pgdg-redhat-repo-42.0-17.1.noarch 1/1 Verifying : pgdg-redhat-repo-42.0-17.1.noarch 1/1 Installed: pgdg-redhat-repo.noarch 0:42.0-17.1 Complete! [root@s101 /root]#
2.安裝資料庫postgresql13 和 擴充套件包
[root@s101 /root]#sudo yum install -y postgresql13-server postgresql13-contrib
3.檢視安裝包和安裝地址
[root@s101 /root]#rpm -qa grep postgres
[root@s101 /root]#rpm -qal | grep postgres
4.資料庫初始化 ,初始化位置:/var/lib/pgsql/13/data
初始化前
初始化後
sudo /usr/pgsql-13/bin/postgresql-13-setup initdb
5.設定開機自啟動
sudo systemctl enable postgresql-13
6.啟動服務
sudo systemctl start postgresql-13 #重新啟動 sudo systemctl restart postgresql-13 #停止服務 sudo systemctl stop postgresql-13 #檢視服務狀態 sudo systemctl status postgresql-13
7.檢視服務狀態