国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

Linux系統(tǒng)之安裝PostgreSQL數(shù)據(jù)庫

這篇具有很好參考價值的文章主要介紹了Linux系統(tǒng)之安裝PostgreSQL數(shù)據(jù)庫。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、PostgreSQL介紹

1.PostgreSQL簡介

PostgreSQL (也叫 Postgres) 是一個自由的對象 - 關(guān)系數(shù)據(jù)庫服務器 (數(shù)據(jù)庫管理系統(tǒng)),它在靈活的 BSD - 風格許可證下發(fā)行。它提供了相對其他開放源代碼數(shù)據(jù)庫系統(tǒng) (比如 MySQL 和 Firebird),和對專有系統(tǒng)比如 Oracle、Sybase、IBM 的 DB2 和 Microsoft SQL Server 的一種選擇。

2.PostgreSQL特點

  • 它是ORDBMS(面向?qū)ο蟮年P(guān)系數(shù)據(jù)庫管理系統(tǒng))。
  • 外鍵引用完整性
  • 用戶自定義的類型
  • 表的繼承性
  • 視圖、規(guī)則、子查詢
  • 多版本并發(fā)控制(MVCC)
  • 復雜的鎖定機制
  • 異步復制
  • 流式復制(從9.0開始)
  • 嵌套事務(保存點)

二、本次實踐介紹

1.本次實踐介紹

從小白視角,以最快速度在LInux系統(tǒng)上部署一個簡單的PostgreSQL數(shù)據(jù)庫。

2.實踐環(huán)境介紹

hostname IP地址 操作系統(tǒng)版本 PostgreSQL版本
jeven 192.168.3.166 centos 7.6 13.10

三、配置PostgreSQL的yum倉庫源

1.檢查本地是否部署PostgreSQL

檢查本地環(huán)境是否部署過PostgreSQL

[root@jeven ~]# rpm -qa | grep postgres
[root@jeven ~]# 

2.配置鏡像源

配置PostgreSQL的yum倉庫源,使用的是阿里提供的鏡像源。

[root@jeven ~]# rpm -Uvh https://mirrors.aliyun.com/postgresql/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
Retrieving https://mirrors.aliyun.com/postgresql/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
warning: /var/tmp/rpm-tmp.kcnTVa: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Preparing...                          ################################# [100%]
Updating / installing...
   1:pgdg-redhat-repo-42.0-32         ################################# [100%]
[root@jeven ~]# sed -i "s@https://download.postgresql.org/pub@https://mirrors.aliyun.com/postgresql@g" /etc/yum.repos.d/pgdg-redhat-all.repo
[root@jeven ~]# 

sed -i "s@https://download.postgresql.org/pub@https://mirrors.aliyun.com/postgresql@g" /etc/yum.repos.d/pgdg-redhat-all.repo

生成緩存

yum clean cache
yum makecache

3.檢查yum倉庫鏡像源狀態(tài)

[root@jeven yum.repos.d]# yum repolist all |grep enable 
base/7/x86_64                             CentOS-7 - Base - mirr enabled: 10,072
docker-ce-stable/7/x86_64                 Docker CE Stable - x86 enabled:    211
elrepo                                    ELRepo.org Community E enabled:    157
epel/x86_64                               Extra Packages for Ent enabled: 13,770
extras/7/x86_64                           CentOS-7 - Extras - mi enabled:    515
mysql-connectors-community/x86_64         MySQL Connectors Commu enabled:    213
mysql-tools-community/x86_64              MySQL Tools Community  enabled:     96
mysql57-community/x86_64                  MySQL 5.7 Community Se enabled:    642
pgdg-common/7/x86_64                      PostgreSQL common RPMs enabled:    396
pgdg11/7/x86_64                           PostgreSQL 11 for RHEL enabled:  1,453
pgdg12/7/x86_64                           PostgreSQL 12 for RHEL enabled:  1,071
pgdg13/7/x86_64                           PostgreSQL 13 for RHEL enabled:    823
pgdg14/7/x86_64                           PostgreSQL 14 for RHEL enabled:    552
pgdg15/7/x86_64                           PostgreSQL 15 for RHEL enabled:    263
remi-safe                                 Safe Remi's RPM reposi enabled:  5,134
updates/7/x86_64                          CentOS-7 - Updates - m enabled:  4,857

四、安裝PostgreSQL

1.安裝PostgreSQL

使用yum直接PostgreSQL13的版本

[root@jeven yum.repos.d]# yum -y install postgresql13-server
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * elrepo: hkg.mirror.rackspace.com
 * remi-safe: ftp.riken.jp
Resolving Dependencies
--> Running transaction check
---> Package postgresql13-server.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Processing Dependency: postgresql13-libs(x86-64) = 13.10-1PGDG.rhel7 for package: postgresql13-server-13.10-1PGDG.rhel7.x86_64
--> Processing Dependency: postgresql13(x86-64) = 13.10-1PGDG.rhel7 for package: postgresql13-server-13.10-1PGDG.rhel7.x86_64
--> Processing Dependency: libpq.so.5()(64bit) for package: postgresql13-server-13.10-1PGDG.rhel7.x86_64
--> Running transaction check
---> Package postgresql13.x86_64 0:13.10-1PGDG.rhel7 will be installed
---> Package postgresql13-libs.x86_64 0:13.10-1PGDG.rhel7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================================
 Package                                  Arch                        Version                                   Repository                   Size
==================================================================================================================================================
Installing:
 postgresql13-server                      x86_64                      13.10-1PGDG.rhel7                         pgdg13                      5.4 M
Installing for dependencies:
 postgresql13                             x86_64                      13.10-1PGDG.rhel7                         pgdg13                      1.4 M
 postgresql13-libs                        x86_64                      13.10-1PGDG.rhel7                         pgdg13                      385 k

Transaction Summary
==================================================================================================================================================
Install  1 Package (+2 Dependent packages)

Total download size: 7.1 M
Installed size: 31 M
Downloading packages:
warning: /var/cache/yum/x86_64/7/pgdg13/packages/postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 442df0f8: NOKEY
Public key for postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm is not installed
(1/3): postgresql13-libs-13.10-1PGDG.rhel7.x86_64.rpm                                                                      | 385 kB  00:00:00     
(2/3): postgresql13-13.10-1PGDG.rhel7.x86_64.rpm                                                                           | 1.4 MB  00:00:01     
(3/3): postgresql13-server-13.10-1PGDG.rhel7.x86_64.rpm                                                                    | 5.4 MB  00:00:02     
--------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                             2.6 MB/s | 7.1 MB  00:00:02     
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Importing GPG key 0x442DF0F8:
 Userid     : "PostgreSQL RPM Building Project <pgsql-pkg-yum@postgresql.org>"
 Fingerprint: 68c9 e2b9 1a37 d136 fe74 d176 1f16 d2e1 442d f0f8
 Package    : pgdg-redhat-repo-42.0-32.noarch (installed)
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-PGDG
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
  Installing : postgresql13-libs-13.10-1PGDG.rhel7.x86_64                                                                                     1/3 
  Installing : postgresql13-13.10-1PGDG.rhel7.x86_64                                                                                          2/3 
  Installing : postgresql13-server-13.10-1PGDG.rhel7.x86_64                                                                                   3/3 
  Verifying  : postgresql13-server-13.10-1PGDG.rhel7.x86_64                                                                                   1/3 
  Verifying  : postgresql13-13.10-1PGDG.rhel7.x86_64                                                                                          2/3 
  Verifying  : postgresql13-libs-13.10-1PGDG.rhel7.x86_64                                                                                     3/3 

Installed:
  postgresql13-server.x86_64 0:13.10-1PGDG.rhel7                                                                                                  

Dependency Installed:
  postgresql13.x86_64 0:13.10-1PGDG.rhel7                               postgresql13-libs.x86_64 0:13.10-1PGDG.rhel7                              

Complete!

2.初始化數(shù)據(jù)庫

初始化PostgreSQL數(shù)據(jù)庫

[root@jeven ~]# postgresql-13-setup initdb
Initializing database ... OK

3.啟動PostgreSQL數(shù)據(jù)庫

啟動PostgreSQL數(shù)據(jù)庫,并設置開機自啟。


[root@jeven ~]# systemctl enable postgresql-13
[root@jeven ~]# systemctl start postgresql-13
[root@jeven ~]# 

4.檢查PostgreSQL數(shù)據(jù)庫狀態(tài)

檢查當前PostgreSQL服務狀態(tài)

[root@jeven ~]# systemctl status postgresql-13.service 
● postgresql-13.service - PostgreSQL 13 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-13.service; enabled; vendor preset: disabled)
   Active: active (running) since Mon 2023-03-27 21:07:33 CST; 1min 34s ago
     Docs: https://www.postgresql.org/docs/13/static/
  Process: 13256 ExecStartPre=/usr/pgsql-13/bin/postgresql-13-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
 Main PID: 13264 (postmaster)
    Tasks: 8
   Memory: 17.6M
   CGroup: /system.slice/postgresql-13.service
           ├─13264 /usr/pgsql-13/bin/postmaster -D /var/lib/pgsql/13/data/
           ├─13266 postgres: logger 
           ├─13268 postgres: checkpointer 
           ├─13269 postgres: background writer 
           ├─13270 postgres: walwriter 
           ├─13271 postgres: autovacuum launcher 
           ├─13272 postgres: stats collector 
           └─13273 postgres: logical replication launcher 

Mar 27 21:07:33 jeven systemd[1]: Starting PostgreSQL 13 database server...
Mar 27 21:07:33 jeven postmaster[13264]: 2023-03-27 21:07:33.325 CST [13264] LOG:  redirecting log output to logging collector process
Mar 27 21:07:33 jeven postmaster[13264]: 2023-03-27 21:07:33.325 CST [13264] HINT:  Future log output will appear in directory "log".
Mar 27 21:07:33 jeven systemd[1]: Started PostgreSQL 13 database server.

五、PostgreSQL的基本命令

1.查看PostgreSQL相關(guān)文件

檢查PostgreSQL服務端的所有相關(guān)文件所在目錄

rpm -ql postgresql13-server

linux安裝postgresql,PostgreSQL,數(shù)據(jù)庫,linux,postgresql

檢查PostgreSQL客戶端的所有相關(guān)文件所在目錄

rpm -ql postgresql13

linux安裝postgresql,PostgreSQL,數(shù)據(jù)庫,linux,postgresql

2.PostgreSQL的相關(guān)命令

PostgreSQL的所有相關(guān)命令文件

[root@jeven ~]# /usr/pgsql-13/bin/
clusterdb                   pg_basebackup               pg_dumpall                  pg_test_timing              postmaster
createdb                    pgbench                     pg_isready                  pg_upgrade                  psql
createuser                  pg_checksums                pg_receivewal               pg_verifybackup             reindexdb
dropdb                      pg_config                   pg_resetwal                 pg_waldump                  vacuumdb
dropuser                    pg_controldata              pg_restore                  postgres                    
initdb                      pg_ctl                      pg_rewind                   postgresql-13-check-db-dir  
pg_archivecleanup           pg_dump                     pg_test_fsync               postgresql-13-setup 

六、修改用戶密碼

1.切換postgres用戶

切換postgres用戶

[root@jeven ~]# su - postgres
-bash-4.2$ 

2.登錄PostgreSQL數(shù)據(jù)庫

登錄后,提示符變?yōu)?‘postgres=#’

[root@jeven ~]# su - postgres
-bash-4.2$ psql -U postgres
psql (13.10)
Type "help" for help.

postgres=# 

3.修改PostgreSQL數(shù)據(jù)庫用戶密碼

修改PostgreSQL數(shù)據(jù)庫用戶密碼


postgres=# ALTER USER postgres WITH PASSWORD 'postgres';
ALTER ROLE

七、配置PostgreSQL遠程訪問

1.配置遠程訪問

修改/var/lib/pgsql/13/data/postgresql.conf配置文件,開啟遠程訪問。
刪除localhost,改為監(jiān)聽所有,或者自己指定的服務器IP地址。

-bash-4.2$ grep listen /var/lib/pgsql/13/data/postgresql.conf
listen_addresses = '*'		# what IP address(es) to listen on;

修改/var/lib/pgsql/13/data/pg_hba.conf文件,新增以下兩行:

host    all            all      127.0.0.1/32      ident
host    all            all      0.0.0.0/0  md5

2.重啟PostgreSQL服務

重啟PostgreSQL服務

 systemctl restart postgresql-13.service 

3.遠程連接PostgreSQL數(shù)據(jù)庫

使用psql命令遠程連接PostgreSQL數(shù)據(jù)庫文章來源地址http://www.zghlxwxcb.cn/news/detail-734726.html

[root@jeven ~]# psql -h192.168.3.166  -Upostgres -W
Password: 
psql (13.10)
Type "help" for help.

postgres=# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges   
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
(3 rows)

postgres=# 

到了這里,關(guān)于Linux系統(tǒng)之安裝PostgreSQL數(shù)據(jù)庫的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權(quán),不承擔相關(guān)法律責任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務器費用

相關(guān)文章

  • linux系統(tǒng)--------------mysql數(shù)據(jù)庫管理

    linux系統(tǒng)--------------mysql數(shù)據(jù)庫管理

    目錄 一、SQL語句 1.1SQL語言分類 1.2查看數(shù)據(jù)庫信息? ? 1.3登錄到你想登錄的庫 1.4查看數(shù)據(jù)庫中的表信息 1.5顯示數(shù)據(jù)表的結(jié)構(gòu)(字段) 1.5.1數(shù)據(jù)表的結(jié)構(gòu) 1.5.2常用的數(shù)據(jù)類型: 二、關(guān)系型數(shù)據(jù)庫的四種語言 2.1DDL:數(shù)據(jù)定義語言,用于創(chuàng)建數(shù)據(jù)庫對象,如庫、表、索引等 2.1.1庫

    2024年03月24日
    瀏覽(22)
  • Linux系統(tǒng)下操作Oracle數(shù)據(jù)庫

    Oracle Database,又名Oracle RDBMS,或簡稱Oracle。是甲骨文公司的一款關(guān)系數(shù)據(jù)庫管理系統(tǒng)。它是在數(shù)據(jù)庫領(lǐng)域一直處于領(lǐng)先地位的產(chǎn)品??梢哉fOracle數(shù)據(jù)庫系統(tǒng)是世界上流行的關(guān)系數(shù)據(jù)庫管理系統(tǒng),系統(tǒng)可移植性好、使用方便、功能強,適用于各類大、中、小微機環(huán)境。它是一種

    2023年04月08日
    瀏覽(86)
  • Linux系統(tǒng)安裝mysql數(shù)據(jù)庫(超詳細)

    目錄 1、準備階段???????? 2、具體步驟 2.1、卸載mariadb 2.2、上傳mysql并解壓 2.3、安裝mysql 2.4、查看版本 2.5、啟動mysql服務 2.6、登錄mysql 2.7、修改密碼 2.8、配置mysql遠程訪問 2.9、修改編碼 3、卸載mysql 3.1、查看mysql的安裝情況? 3.2、刪除安裝包? 3.3、在/根目錄下查詢mysql

    2024年02月12日
    瀏覽(20)
  • Linux高級管理--安裝MySQL數(shù)據(jù)庫系統(tǒng)

    Linux高級管理--安裝MySQL數(shù)據(jù)庫系統(tǒng)

    ????????MySQL.是一個真正的多線程、多用戶的SQL數(shù)據(jù)庫服務,憑借其高性能、高可靠和易于使 用的特性,成為服務器領(lǐng)域中最受歡迎的開源數(shù)據(jù)庫系統(tǒng)。在2008年以前,MySOL項目由MySQL AB公司進行開發(fā),發(fā)布和支持,之后歷經(jīng)Sun 公司收購MySOL AB公司,Oracle公司收購Sun公司 的

    2024年02月04日
    瀏覽(49)
  • c++ mysql數(shù)據(jù)庫編程(linux系統(tǒng))

    c++ mysql數(shù)據(jù)庫編程(linux系統(tǒng))

    ubuntu安裝mysql(圖文詳解)-CSDN博客 https://blog.csdn.net/qq_58158950/article/details/135667062?spm=1001.2014.3001.5501 //打印錯誤信息? 這段代碼是一個宏定義,它定義了一個名為 LOG 的宏。 __FILE__ ?是一個預定義宏,它會在編譯時被替換為當前源文件的文件名(包括路徑)。 __LINE__ ?也是一個

    2024年01月21日
    瀏覽(26)
  • linux系統(tǒng)SQL server數(shù)據(jù)庫定時收縮

    linux系統(tǒng)SQL server數(shù)據(jù)庫定時收縮

    出現(xiàn)下圖問題,導致連接該數(shù)據(jù)庫的程序不能正常啟動 定時收縮數(shù)據(jù)庫 需要三個腳本文件 linux_sqlcmd_timing_task_shrink.sh:主腳本文件 exec_sql.sh:執(zhí)行數(shù)據(jù)庫收縮腳本文件 shrink.sql:數(shù)據(jù)庫收縮命令

    2024年02月06日
    瀏覽(23)
  • Linux系統(tǒng)MySQL數(shù)據(jù)庫的備份及應用

    Linux系統(tǒng)MySQL數(shù)據(jù)庫的備份及應用

    本節(jié)主要學習了MySQL數(shù)據(jù)庫的備份:概念,數(shù)據(jù)備份的重要性,造成數(shù)據(jù)丟失的原因,備份的類型,常見的備份方法,實例與應用等。 目錄 一、概述 二、數(shù)據(jù)備份的重要性 三、造成數(shù)據(jù)丟失的原因 四、備份類型 1、物理與邏輯角度 ①物理備份—對數(shù)據(jù)庫操作系統(tǒng)的物理文件

    2024年02月15日
    瀏覽(22)
  • 如何在Linux系統(tǒng)中安裝MySQL數(shù)據(jù)庫

    如何在Linux系統(tǒng)中安裝MySQL數(shù)據(jù)庫

    (一)、準備 1、Linux環(huán)境 視頻教程:https://www.bilibili.com/video/BV15m4y1d7ZP 2、檢查內(nèi)存 5.6及以上版本的MySQL要求Linux系統(tǒng)虛擬內(nèi)存不能小于1G,否則MySQL可能無法運行。 3、卸載mariadb (二)、安裝 1、下載 下載地址:https://mirrors.aliyun.com/mysql/MySQL-8.0,這里下載mysql-8.0.28-el7-x86_64.

    2024年02月04日
    瀏覽(21)
  • Linux系統(tǒng)中MySQL 數(shù)據(jù)庫的主從同步

    在主數(shù)據(jù)庫服務器上配置: 編輯主數(shù)據(jù)庫服務器的配置文件(my.cnf) : 打開 MySQL 配置文件,一般路徑為 /etc/my.cnf 或 /etc/mysql/my.cnf。 確保以下參數(shù)已啟用或配置正確: 注: 一定是[mysqld]代碼塊中 創(chuàng)建用于復制的用戶 : 登錄到 MySQL 控制臺: mysql -u root -p 創(chuàng)建用于復制的用戶

    2024年03月23日
    瀏覽(18)
  • 系統(tǒng)學習Linux-MySQL數(shù)據(jù)庫備份(四)

    數(shù)據(jù)庫備份是指將數(shù)據(jù)庫中的數(shù)據(jù)、表格、視圖、存儲過程、觸發(fā)器等信息備份到另一個地方,一遍在數(shù)據(jù)庫丟失或損壞時進行恢復,數(shù)據(jù)庫備份是數(shù)據(jù)庫管理中必不可少的一項工作,通過備份可以保護數(shù)據(jù)庫中的數(shù)據(jù)和業(yè)務。 備份的主要目的是災難恢復,備份還可以測試應

    2024年02月15日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包