腾讯云 CDB for PostgreSQL Quick Start 产品文档
版权声明 2015-2016 腾讯云版权所有 本文档著作权归腾讯云单独所有, 未经腾讯云事先书面许可, 任何主体不得以任何形式复制 修改 抄袭 传 播全部或部分本文档内容 商标声明 及其它腾讯云服务相关的商标均为腾讯云计算 ( 北京 ) 有限责任公司及其关联公司所有 本文档涉及的第三方 主体的商标, 依法由权利人所有 服务声明 本文档意在向客户介绍腾讯云全部或部分产品 服务的当时的整体概况, 部分产品 服务的内容可能有所调整 您所购买的腾讯云产品 服务的种类 服务标准等应由您与腾讯云之间的商业合同约定, 除非双方另有约定, 否则, 腾讯云对本文档内容不做任何明示或模式的承诺或保证 第 2 页共 15 页
文档目录 文档声明... 2 Initialize Instance... 4 Obtain Access Address... 6 Connect Instance... 8 Data Import to PostgreSQL Instance... 12 Notes... 15 第 3 页共 15 页
Initialize Instance Initialization (batch initialization) is required for the purchased Cloud Database (PostgreSQL) instances before you can use them, as shown below: The following parameters need to be initialized: Admin user name: Case-insensitive, start with letter and end with letter or number. 16 characters at most. You cannot use: postgres Admin password: The password should be a combination of 8-16 characters comprised of at least two of the following types: letters, numbers, and special characters (!, @, #, $, %, ^, *, (, )). You can change it later in "Account Management". 第 4 页共 15 页
Supported character set: global instance character set. This cannot be changed once determined. (Under instances, global character set can be different from database. You can configure this when creating libraries) 第 5 页共 15 页
Obtain Access Address PostgreSQL provides both private and public network access addresses. 1. Obtaining the Private Network Access Address You can obtain the private network access address of an instance on the Instance Details page. Note that the private network access address refers to the VIP. The database instance is accessed by connecting to the gateway cluster rather than the database instance CPM. Therefore, the private IP does not change during CVM delivery failure or master/slave switch. From a CVM that resides in the same network as PostgreSQL, you can directly connect to the instance's private network address to access PostgreSQL services. (Note: you may need to install the client first) 2. Obtaining the Public Network Access Address You can obtain the public network access address of an instance on the Instance Details page. Note: Public network access address can only be used for daily database management. Public 第 6 页共 15 页
network traffic may incur a fee. For more information, please see Product Prices. 第 7 页共 15 页
Connect Instance You can use any standard SQL client to connect to your instance once it has been initialized. Next, we will provide an example showing how to connect to PostgreSQL instance using pgadmin. 1. Download and Install pgadmin You can download and install pgadmin from https://www.pgadmin.org/download/. 2. Add Server Click "File" menu and select "Add Server". 3. Create Database Connection In the "New Server Registry" dialog, enter name, CVM IP address, port number, user name and password. You can find the CVM IP address and port number from the PGSQL instance management page. Click "OK" once you've entered the information. 第 8 页共 15 页
In the object browser menu in the left, double-click "server groups" to expand the list. Select the connected server (database instance) and choose database name. 第 9 页共 15 页
4. Use pgadmin Launch the PSQL console. Click the icon as shown in the figure and choose PSQL CONSOLE. Now, you can work with your database in the console. 第 10 页共 15 页
第 11 页共 15 页
Data Import to PostgreSQL Instance You can restore data backup files into the target CDB for PostgreSQL by using PostgreSQL logical backup. 1. Prepare PostgreSQL Instance Purchase PostgreSQL instance, initialize instance and acquire connection address. Make sure the initialization character set is consistent with that of the original instance. 2. Logical Back-up Original Instance Data Connect to the local (source) PostgreSQL database using PostgreSQL client. Execute the following command to back up data. pg_dump -U username -h hostname -p port databasename -f filename Parameter description: username: user name of local database. hostname: host name of local database. You can use "localhost" if you're logging in from local database host. port: port number of local database. databasename: Name of local database to be backed up. filename: Name of the generated backup file. For example, the database user "pgtest" wants to back up local PostgreSQL database. The user should use the following command to back up data after logging in to PostgreSQL host. 第 12 页共 15 页
pg_dump -U pgtest -h localhost -p 4321= pg001 -f pg001.sql 3. Migrate Data Through CVM It is suggested that you upload data to CVM in a secure way (such as encrypted compression) and restore data to target PostgreSQL via private network. Log in to CVM. In the PostgreSQL client, execute the following command to import data to target PostgreSQL. psql -U username -h hostname -d desintationdb -p port -f dumpfilename.sql Parameter description: username: user name of the PostgreSQL database on RDS. hostname: PostgreSQL database address on RDS. port: port number of the PostgreSQL database on RDS. databasename: PostgreSQL database name on RDS. filename: File name of the local backup data. For example: psql -U pgtest -h 10.xxx.xxx.xxx -d pg001 -p 4321 -f pg001.sql Certain permission-related WARNING or ERROR may occur during the data import process, due to possible permission configuration differences between source and target database. These can be ignored. 4. Migrate Data Through Internet You can also import data directly through the Internet by using tools such as pgadmim, if the data volume is low (e.g. no more than 10 GB). For example: 第 13 页共 15 页
第 14 页共 15 页
Powered by TCPDF (www.tcpdf.org) Quick Start 产品文档 Notes Note 1. PostgreSQL already provides account with permissions including creating/modifying databases, creating/modifying accounts. But it does not provide super admin account. 2. It is recommended that you use public network address for routine maintenance, rather than connecting business servers. 3. The network to which the instance belongs can no longer be modified once the instance has been created. 4. Why is occupied disk capacity larger than actual data volume? Updates will cause xlog to rapidly grow in size. The logs occupy disk space if the system doesn't archive and delete them in time. Or, the query operations include large number of sort and connection operations involving huge amount of data. This process produces temporary tables which will overflow to the disk and occupy disk space for a short time. 5. Enable/Use Plug-ins Most commonly used plug-ins are supported by Tencent Cloud PostgreSQL and can be directly used. Certain plug-ins require super admin permission to be enabled. You can enable them from the Tencent Cloud console. Or you can contact Tencent personnel and describe your instance ID and name of the plug-in to enable it. 第 15 页共 15 页