How to open and configure the remote connection of OpenGauss database in Linux system (1)

Preface

openGauss is an open source relational database management system, released under the Mulan Permissive License v2. The openGauss kernel deeply integrates Huawei's many years of experience in the database field, combined with the needs of enterprise-level scenarios, to continuously build competitive features.

Combined with the cpolar intranet penetration tool, remote access to local openGauss can be achieved to achieve remote access. The following describes how to install from Linux to remote access.

1. Linux installation openGauss

First download the corresponding installation package from the official website: https://opengauss.org/zh/download/. Download the LInux minimalist version installation here.

image-20230912112028131

After downloading, use the root user to upload it to Linux. Here, upload it to the /usr/local/ directory,

Create the installation directory using the root user

mkdir /usr/local/openGauss

And give everyone in the directory access permissions: Next, start the installation, using the official website single-node installation method

chmod 777 /usr/local/openGauss

*Switch to log in as a normal user in Linux. Note that you cannot use the root user to install openGauss.

Unzip the openGauss compressed package to the directory created above

tar -jxf openGauss-3.1.1-CentOS-64bit.tar.bz2 -C /usr/local/openGauss

Enter simpleInstall in the unzipped directory

cd /usr/local/openGauss/simpleInstall

Execute the install.sh script to install openGauss, where-wThe following parameter is to set the database password

sh install.sh  -w "xxxx" &&source ~/.bashrc

If this error occurs after execution:

image-20230912134800117

To switch users with root permissions, execute the following command: Then execute the installation command, and the installation will be successful.

sysctl -w kernel.sem="250 85000 250 330" 

After the installation is complete, execute the ps command to check whether the process is normal.

ps ux | grep gaussdb

The following information is displayed to indicate that the installation is successful and has been running. In this way, the installation of the openGauss database on Linux is completed. Next, we install cpolar for intranet penetration to achieve remote connection.

2. Install cpolar on Linux

Above we have successfully installed the openGauss database. Next we install the cpolar intranet penetration tool on Linux and forward the http public network address mapped to the local port through cpolar. We can easily achieve remote access without having to register a domain name and purchase a cloud server ourselves. Next Here are the steps to install cpolar

cpolar official website address: https://www.cpolar.com

  • Use one-click script installation command
curl -L https://www.cpolar.com/static/downloads/install-release-cpolar.sh | sudo bash
  • Add services to the system
sudo systemctl enable cpolar
  • Start cpolar service
sudo systemctl start cpolar

After cpolar is successfully installed, access Linux port 9200 on an external browser: [http://LAN ip:9200]. Log in using your cpolar account. After logging in, you can see the cpolar web configuration interface, which is connected to the web management interface. Just configure

image-20230831171159175

3. Create the openGauss master node port number and public network address

After logging in to the cpolar web UI management interface, click Tunnel Management - Create Tunnel on the left dashboard:

  • Tunnel name: It can be customized. Be careful not to duplicate the existing tunnel name.
  • Protocol: tcp
  • Local address: 5432 (openGauss default port)
  • Domain name type: Temporary random TCP port
  • Region: Select China VIP

Click创建

Then open the online tunnel list on the left and view the TCP address generated after the tunnel was just created. This address is the public network connection address. We can use this address to connect on any device.

image-20230912145753439

4. Remote connection to openGauss

The public network address was created in cpolar above. Next we use the gsql tool to connect through the cpolar public network address. The host value is the public network address, the port value is the corresponding port number after the public network address, and then enter the database name and user name. password

gsql -d "host=3.tcp.vip.cpolar.cn port=10290 dbname=postgres user=jon password=xxxxxx"

We can see that the connection is successful, so that we have set up a remote openGauss database address. The same is true for connecting using other methods.

image-20230912170324656

5. Fixed connection TCP public network address

It should be noted that the above steps use a random temporary TCP port address, and the generated public network address is a random temporary address, which will change randomly within 24 hours. Next, we configure a fixed TCP port address for it. This address will not change. After setting it, there will be no need to modify the address repeatedly every day.

Configuring a fixed TCP port address requires upgrading cpolar to the Professional Edition package or above.

Reserve a fixed tcp address

Log incpolar official website, click Reserve on the left, find the reserved tcp address, let’s reserve a fixed tcp for Minecraft Address:

  • Region: Select China vip
  • Description: Notes, customizable

Click保留

image-20230912170840105

After the address is successfully reserved, the system will generate the corresponding fixed public address and copy it.

image-20230912171014210

Open the cpolar web ui management interface, click Tunnel Management - Tunnel List on the left dashboard, find the TCP tunnel we created above, and click on the right编辑

image-20230912171134740

Modify the tunnel information and configure the successfully reserved fixed tcp address into the tunnel.

  • Port type: modified to fixed tcp port
  • Reserved tcp address: fill in the address successfully reserved by the official website,

Click更新

image-20230912171213697

After the tunnel is successfully updated, click the status on the left dashboard - Online Tunnel List, and you can see that the public network address has been updated to a fixed TCP address.

image-20230912171235606

6. Fixed address connection test

After fixing the address, use our fixed TCP address to connectgsql. You can see that the connection is successful and a permanent fixed address is set

image-20230912171359669

Guess you like

Origin blog.csdn.net/2301_77053417/article/details/134377608