Updated on 2025-01-23 GMT+08:00

Deploying PoWA for an RDS for PostgreSQL Instance

To remotely deploy PoWA on Huawei Cloud, There must be an ECS with PoWA-archivist, PoWA-collector, and PoWA-web installed on it. This section describes how to install PoWA-archivist, PoWA-collector, and PoWA-web.

Architecture

The remote deployment architecture is as follows:

Figure 1 Remote deployment architecture

Preparations

  • An RDS for PostgreSQL 12.6 instance has been created.
  • An ECS has been created and bound with an EIP. In this example, the ECS uses the CentOS 8.2 64-bit image.

Installing Python3

PoWA-collector and PoWA-web must be installed in a Python3 environment. You can use pip3 to install them to facilitate the installation. In this example, Python 3.6.8 is installed on the ECS by default. The latest PoWA version fails to be installed. For details about how to install the latest version, see Installing Python 3.9.9.

Installing PoWA-archivist

  1. Run the wget command to obtain the PoWA-archivist source code.
    wget https://github.com/powa-team/powa-archivist/archive/refs/tags/REL_4_1_2.tar.gz
  2. Decompress the downloaded REL_4_1_2.tar.gz package.
  3. Install PoWA-archivist to the decompressed directory.
    make && make install

Installing PoWA-collector and PoWA-web

  1. Switch to the RDS for PostgreSQL database user. Take user postgres as an example.
    su - postgres
  2. Install PoWA-collector and PoWA-web. psycopg2 is mandatory for installing them.
    pip install psycopg2
    pip install powa-collector
    pip install powa-web

After the installation is complete, check the following path tree. If the following information is displayed, the PoWA-collector and PoWA-web have been installed.

/home/postgres/.local/bin
├── powa-collector.py
├── powa-web
└── __pycache__

Creating the PoWA Extension

  1. Log in to the powa database of the RDS for PostgreSQL instance as user root. (If the powa database does not exist, create it first.)
  2. Create the powa extension in the powa database.

    select control_extension('create', 'pg_stat_statements');
    select control_extension('create', 'btree_gist');
    select control_extension('create', 'powa');

FAQs

Q: What should I do if the error message "python setup.py build_ext --pg-config /path/to/pg_config build" is displayed when the pip install psycopg2 command is executed?

A: You need to add the bin and lib paths of RDS for PostgreSQL to environment variables and run the pip install psycopg2 command.

Installing Python 3.9.9

  1. Prepare the environment.

    Perform the following operations in sequence. Otherwise, Python 3.9.9 may fail to be installed (for example, SSL component dependency fails). As a result, PoWA-collector and PoWA-web fail to be installed.

    yum install readline* -y
    yum install zlib* -y
    yum install gcc-c++ -y
    yum install sqlite* -y
    yum install openssl-* -y
    yum install libffi* -y
  2. Install Python 3.9.9.
    1. Run the following commands as user root:
      mkdir env
      cd env
      wget https://www.python.org/ftp/python/3.9.9/Python-3.9.9.tgz
      tar -xzvf Python-3.9.9.tgz
      cd Python-3.9.9
      ./configure --prefix=/usr/local/python3.9.9
      make && make install
    2. Create a soft link.
      ln -s /usr/local/python3.9.9/bin/python3.9 /usr/bin/python
      ln -s /usr/local/python3.9.9/bin/pip3.9 /usr/bin/pip
  3. Check whether the installation is successful.
    1. Verify the installation, especially the SSL function.
      [root@ecs-ad4d Python-3.9.9]# python
      Python 3.9.9 (main, Nov 25 2021, 12:36:32)
      [GCC 8.4.1 20200928 (Red Hat 8.4.1-1)] on linux
      Type "help", "copyright", "credits" or "license" for more information.
      import ssl
      import urllib.request
      context = ssl._create_unverified_context()
      urllib.request.urlopen('https://www.example.com/',context=context).read()
    2. If any command output is displayed, the installation is successful. Run the following command to exit:
      quit()