This topic describes how to download and install polartools.

Background information

polartools is a collection of Apsara PolarDB client tools for Linux. polartools includes the following tools:

This topic describes how to use polarplus. For more information about other tools, see the PostgreSQL documentation.

Download polartools

To use polartools, click polartools to download the polartools package. After you have downloaded polartools, you must uncompress the package. You do not need to install the package. You can download and use polartools free of charge.

polartools has the following directory structure:

├── bin
├── etc
│      └── sysconfig
├── help
└── lib

All tools are located in the bin directory. If you want to use a tool, you must add the tool location to the PATH environmental variable.

├── pg_basebackup
├── pg_dump
├── pg_dumpall
├── pg_restore
└── psql


polarplus is a utility that provides a command-line interface (CLI) for Apsara PolarDB. polarplus supports SQL statements, SPL anonymous blocks, and polarplus statements.

polarplus provides the following features:

  • Queries a specified database object.
  • Executes a stored procedure.
  • Formats SQL statement output.
  • Runs multiple scripts in a query.
  • Runs operating system commands.
  • Retains output logs.

To download and configure polarplus, follow these steps:

Note polarplus is dependent on JDK 1.8.
  1. On the command line, enter wget to download polartools. For more information about the download address, see Download polartools.
  2. Uncompress the file.
    tar -zxf polartools.tar.gz
    The following figure shows the uncompressed file.Uncompressed polartools
  3. Go to the bin directory.
  4. Open the file.
  5. Modify the setting of export base="/home/adger.lj/polartools/ora" by replacing /home/adger.lj with the absolute path where the polartools folder is located.
  6. To start polarplus, on the command line, execute the following statement on the Elastic Compute Service (ECS) instance or the server that connects to a PolarDB database:
    polarplus [ -S[ILENT ] ] [ login | /NOLOG ] [ @scriptfile[.ext ] ]
    Parameter Description
    -S[ILENT ] If you set this parameter, the polarplus logon banner and all relevant messages are disabled.
    login The logon information used to connect to the database server and databases.

    Enter the logon information in the following format:

    username[/password][@{connectstring | variable } ]

    For more information, see Table 1.

    The variable parameter specifies a variable defined in the login.sql file. This file contains a database connection string.

    /NOLOG When you start polarplus, if you specify /NOLOG, no database connection is established. To connect to a database and execute SQL statements or polarplus statements, do not use this mode.
    Note After you start polarplus by specifying / NOLOG, you can execute the CONNECT statement to connect to a database.
    scriptfile[.ext ] scriptfile specifies the file name that is located in the current directory. This file contains SQL statements and polarplus statements that are automatically executed after you start polarplus.
    .ext specifies the file extension. If the file extension is .sql, when you specify a script file, you can omit the .sql extension. When you create a script file, name the file with the extension. Otherwise, polarplus cannot access the file.
    Note polarplus processes the files without extensions as .sql files.
    Table 1. Logon information
    Parameter Description
    username The username used to connect to a database.
    password The password associated with the specified username.
    connectstring The database connection string is provided in the following format:
    host[:port][/dbname][? ssl={true | false}]
    • host specifies the hostname or IP address of a database server.
      Note If you have not specified connectstring, variable, or NOLOG, the default host is the local host.
    • If you use an Internet Protocol version 6 (IPv6) address to connect to a database, you must place the IP address in brackets ([]).

      The following example shows how to use an IPv6 address to connect to a database:

      polarplus  polardb/password@[fe80::20c:29ff:fe7c:78b2]:5444/polardb
    • port specifies the port number on the database server to receive connection requests.
      Note If you have not specified a port number, the default value is 5444.
    • dbname is the name of the database to connect to.
    • If you require SSL connections, the connection string must include ? ssl = true and host:port. If you have not set the ssl parameter, the default value is false.

    The following example shows how to use polarplus to connect to a PolarDB database:

    polarplus  polardb/