全部產品
Search
文件中心

PolarDB:PolarPlus

更新時間:May 13, 2025

PolarPlus是一款用於串連PolarDB PostgreSQL版(相容Oracle)叢集的用戶端串連工具。可以為PolarDB提供命令列使用者介面,同時支援SQL命令、PolarPlus命令、PL/SQL匿名塊、函數和預存程序。

下載用戶端

PolarPlus2提供免安裝的壓縮包,下載後解壓即可在Linux系統上使用。解壓得到的PolarPlus目錄結構如下所示。其中polarplus2檔案是可執行檔。如果將polarplus2_release/目錄所在的檔案路徑加入到系統PATH,那麼直接執行polarplus2命令即可運行。

polarplus2_release
├── polarplus2 -> ./polarplus2.sh
├── polarplus2.sh
├── polarplus.jar
├── login.sql
├── etc
│ └── sysconfig
├── help
└── lib

PolarPlus使用說明

簡介

PolarPlus是一個公用程式,可以為PolarDB提供命令列使用者介面。PolarPlus支援SQL命令、PolarPlus命令、PL/SQL匿名塊、函數和預存程序。該工具提供了如下功能:

  • 查詢指定資料庫物件。

  • 執行預存程序。

  • 格式化SQL命令的輸出。

  • 執行批處理指令碼。

  • 執行作業系統命令。

  • 記錄輸出內容。

與原生工具區別

PolarPlus針對PolarDB進行適配,支援Oracle的SQLPlus工具常見用法。

說明

建議使用PolarDB-Tools來管理PolarDB叢集,該工具集已針對PolarDB PostgreSQL版(相容Oracle)進行適配,其中提供的psql工具支援處理Oracle文法風格的PL/SQL匿名塊、函數和預存程序。

配置PolarPlus

說明

PolarPlus工具依賴如下:

  • Java的jdk 1.8環境(x64)。

  • OpenSSL 1.1版本(x64)。

  1. 使用wget命令下載PolarPlus並解壓。

  2. 開啟polarplus2.sh檔案。

  3. 修改export base="xxx",將base的值替換為PolarPlus的絕對路徑。例如,若您的PolarPlus檔案的絕對路徑為/home/polarplus2_release,則應修改為export base="/home/polarplus2_release"

  4. 在伺服器上使用以下命令調用PolarPlus:

    polarplus2 [ -S[ILENT ] ] [ login | /NOLOG ] [ @scriptfile[.ext ] ]

    參數

    說明

    -S[ILENT ]

    如果指定該參數,則將取消顯示PolarPlus登入橫幅以及所有提示。

    login

    用於串連到資料庫伺服器和資料庫的登入資訊。具體資訊如下:

    username[/password][@{connectstring | variable } ]
    • username:用於串連資料庫的資料庫使用者名稱。

    • password:與資料庫使用者名稱關聯的密碼。

    • connectstring:資料庫連接字串,具體資訊如下:

      host[:port][/dbname][?ssl={true | false}]
      • host:資料庫伺服器所在的主機名稱或IP地址。

        說明
        • 如果未指定connectstringvariableNOLOG,則預設主控件為本地主機。

        • 如果使用IPv6地址進行串連,則IP地址必須放在方括弧內。樣本如下:

          polarplus2 <username>/<password>@[fe80::20c:29ff:fe7c:78b2]:<port>/<database>
      • port:資料庫伺服器上接收串連的連接埠號碼。

        說明

        如果未指定,則預設值為5444。

      • dbname:需要串連的資料庫的名稱。

        說明

        如果未指定,則預設值為polardb。

      • ssl:若需要SSL串連,請在連接字串中添加?ssl=true,並確保連接字串包含host:port。如果未指定SSL參數,則預設值為false。

    • variable:在login.sql檔案中定義的變數,該檔案包含資料庫連接字串。

    /NOLOG

    如果指定/NOLOG啟動PolarPlus,則啟動PolarPlus時將不會建立資料庫連接。如果需要串連資料庫使用SQL命令或者PolarPlus命令,請勿使用該模式。

    說明

    使用/NOLOG選項啟動PolarPlus之後, 可以隨後給出CONNECT命令以串連到資料庫。

    scriptfile[.ext ]

    scriptfile是位於當前工作目錄中的檔案名稱,包含SQL命令以及PolarPlus命令。這些命令將在PolarPlus啟動後自動執行。

    .ext是副檔名。如果副檔名是.sql,可以在指定指令檔時省略.sql副檔名。建立指令碼檔案時,請使用副檔名命名該檔案, 否則PolarPlus將無法訪問該檔案。

    說明

    PolarPlus將始終對未指定副檔名的檔案名稱採用.sql副檔名。

    串連樣本如下所示:

    ./polarplus2 <username>/<password>@<host>:<port>/<dbname>