Cloud Lesson|Teach you how to use the RDS for PostgreSQL plugin

Abstract: This article introduces the plugins supported by RDS for PostgreSQL and how to create, delete or use different plugins.

This article is shared from HUAWEI CLOUD Community " [Cloud Lesson] [Lesson 42] RDS for PostgreSQL Plugin Introduction ", author: Xiaoyunmei from the database.

This article introduces the plugins supported by RDS for PostgreSQL and how to create, delete or use different plugins.

Introduction to the PostgreSQL plugin

PostgreSQL is one of the classic large-scale relational databases among open source databases. It not only has the functions of classic relational databases, but is also constantly developing. The development of PostgreSQL has not only been influenced by many external applications based on PostgreSQL, but also developed more applications based on PostgreSQL, such as PostGIS (an important component in the field of GIS). From a technical point of view, PostGIS is an extension, or plug-in, of PostgreSQL. Plug-ins like PostGIS have been used to varying degrees in computer-related fields, and it has become the main feature of PostgreSQL's functional scalability.

The functions of PostgreSQL plug-ins are not only reflected in the basic functions of adding complex data types, indexes and other data, these basic functions are also particularly required in the GIS field, and PostgreSQL plug-ins can complete various tasks including distributed and heterogeneous data access. an advanced feature. This makes the PostgreSQL database not only a traditional classical relational database, but also can fully meet the needs of today's Internet for big data applications through the extension functions of plug-ins.

List of RDS for PostgreSQL plugins

Like the community version of PostgreSQL, RDS for PostgreSQL also supports plug-ins to achieve more extended functions. The plugins currently supported by RDS for PostgreSQL are shown in the following table:

illustrate:

  • The data in the table comes from each version of the PostgreSQL engine, and the list of plugins supported by the latest minor version.
  • You can view the list of plugins supported by the current instance by SELECT name FROM pg_available_extensions;. If the version of the current instance does not support a plug-in, you can migrate the current instance to an instance of the new version. For the migration method, see Overview of Migration Solutions .
  • When using plug-ins that require cross-database access, such as mysql_fdw, oracle_fdw, pgsql-ogr-fdw, postgres_fdw, and tds_fdw, make sure that the server IPs of the two database instances must be in the same VPC and subnet.
  • Only users with public beta privileges can use RDS for PostgreSQL 13, and you can submit a work order .

Create RDS for PostgreSQL plugin

illustrate:

  • The RDS for PostgreSQL plugin takes effect at the database level, not globally. Therefore, when creating a plug-in, you need to manually create it on the database where the business is located.
  • The following plugins for RDS for PostgreSQL do not require manual creation or deletion:
  • auto_explain
  • passwordcheck
  • pg_profile_pro
  • pg_sql_history
  • plpgsql
  • wal2json
  • test_decoding
  • The latest minor versions of RDS for PostgreSQL 11, RDS for PostgreSQL enhanced version, RDS for PostgreSQL 12, and RDS for PostgreSQL 13 support the root user to create (create extension) and delete (drop extension) plugins through the community.

1. Run the following command to connect to the database as the root user. Take database1 as an example, and use the template library template1 to create a database that needs to support plug-ins.

# psql --host=RDS_ADDRESS --port=DB_PORT --dbname=database1 --username=root -c "create database DB_NAME template template1;"

illustrate:

  • RDS_ADDRESS is the IP address of the RDS instance.
  • DB_PORT is the port of the RDS database instance.
  • DB_NAME is the name of the database where the plug-in needs to be created.

If the following information is displayed, enter the password of the root user.

Password for user root:

Notice:

If the operation is: the database db1 created by the common user user1 , you need to log in to the database db1 as the common user user1 (refer to the above for the login method), and then run the following commands to grant the permissions of the database db1 to the root user.

GRANT ALL ON DATABASE db1 TO root;

Example: Create a database my_extension_db that needs to support plugins

# psql --host=192.168.6.141 --port=5432 --dbname=database1 --username=root -c "create database my_extension_db template template1;"

Password for user root: 
CREATE DATABASE

2. As the root user, connect to the database that needs to support the plug-in, and create the plug-in.

# psql --host=RDS_ADDRESS --port=DB_PORT --dbname=DB_NAME --username=root -c "select control_extension('create','EXTENSION_NAME');"

illustrate:

  • RDS_ADDRESS is the IP address of the RDS instance.
  • DB_PORT is the port of the RDS database instance.
  • DB_NAME is the name of the database where the plug-in needs to be created.
  • EXTENSION_NAME is the plugin name, see the table above.

If the following information is displayed, enter the password of the root user.

Password for user root:

Example: Create postgis plugin in database my_extension_db

# psql --host=192.168.6.141 --port=5432 --dbname=my_extension_db --username=root -c "select control_extension('create','postgis');"

Password for user root:  
      control_extension        
------------------------------ 
 create postgis successfully. 
(1 row)

Remove RDS for PostgreSQL plugin

illustrate:

  • The RDS for PostgreSQL plugin takes effect at the database level, not globally. Therefore, when creating a plug-in, you need to manually create it on the database where the business is located.
  • The following plugins for RDS for PostgreSQL do not require manual creation or deletion:
  • auto_explain
  • passwordcheck
  • pg_profile_pro
  • pg_sql_history
  • plpgsql
  • wal2json
  • test_decoding
  • The latest minor versions of RDS for PostgreSQL 11, RDS for PostgreSQL enhanced version, RDS for PostgreSQL 12, and RDS for PostgreSQL 13 support the root user to create (create extension) and delete (drop extension) plugins through the community.

Run the following commands to connect to the database of the created plugin as the root user and delete the plugin.

# psql --host=RDS_ADDRESS --port=DB_PORT --username=root --dbname=DB_NAME -c "select control_extension ('drop','EXTENSION_NAME');"

illustrate:

  • RDS_ADDRESS is the IP address of the RDS instance.
  • DB_PORT is the port of the RDS database instance.
  • DB_NAME is the name of the database where the plug-in needs to be created.
  • EXTENSION_NAME is the plugin name, see the table above.

If the following information is displayed, enter the password of the root user.

Password for user root:

Example:

# psql --host=192.168.6.141 --port=5432 --dbname=my_extension_db --username=root -c "select control_extension('drop','postgis');"

Password for user root: 
     control_extension      
----------------------------
 drop postgis successfully.
(1 row)

RDS for PostgreSQL plugin description

 

Click Follow to learn about HUAWEI CLOUD's new technologies for the first time~

{{o.name}}
{{m.name}}

Guess you like

Origin my.oschina.net/u/4526289/blog/5518333