Quick (one-click) installation guide for installing and deploying the openGauss3.1.1 database on the virtual machine VirtualBox7.0.6+openEuler20.03TSL

"database"

Installation and Deployment of openGauss3.1.1 Database Instruction Manual on Virtual Machine VirtualBox7.0.6+openEuler20.3-LTS

Other references:

- Detailed instruction manual for installing and deploying openGauss3.1.1 database on virtual machine VirtualBox7.0.6+openEuler20.03TSL
- Linux and database commands commonly used in openGauss learning
- Rapid deployment on x86_64 architecture + VMware16.2.3 Pro + openEuler20.3-LTS ( One-click installation) openGauss 3.1.1 Enterprise Edition Database Instruction Manual
- Use the virtual machine VMwarepro1623 image file to import and deploy openGauss3.1.1 Instruction Manual

0 Preface

Introduction

openGauss is a relational database that adopts client/server, single-process and multi-thread architecture, supports single-machine and one-master-multiple-standby deployment methods, is readable by the backup machine, and supports dual-machine high availability and read expansion.

This experiment mainly describes the stand-alone installation and deployment of the openGauss3.1.1 database on openEuler 20.03-LTS.

Content description

The main content of this experiment is to install and deploy the openGauss3.1.1 database on openEuler 20.03-LTS, and perform simple database-related operations.

Preconditions

Since this experiment mainly deploys the openGauss database on the openEuler operating system, you need to master the basic operations and system commands of the Linux system. Please see Appendix 1 for details .

Experimental environment description

  • Networking instructions

This experimental environment is virtual machine VirtualBox 6.0.7+ openEuler 20.03-LTS + openGauss 3.1.1+JDK1.8.

  • Equipment introduction

In order to meet the needs of openGauss installation and deployment experiments, it is recommended that each experimental environment adopt the following configuration:

Equipment schedule

image.png

1.OpenGauss Enterprise Edition database installation

1.1 Experiment introduction

About this experiment

This experiment mainly describes the installation and configuration of the openGauss database on the virtual machine VirtualBox+openEuler.

Purpose

  • Master the installation and configuration methods of virtual machine VirtualBox;
  • Master the installation and deployment methods of openGauss database.

1.2 Download and install virtual machine VirtualBox

Step 1 Enter the official website download page.

URL: https://www.virtualbox.org/wiki/Downloads

image.png

Click "window host" to download the windows version of VirtualBox.

Step 2 After the download is completed, double-click the execution file to install.

After downloading, the file name is: VirtualBox-7.0.6-155176-Win.exe. Double-click this executable file to install. During the installation process, you can set the storage address according to your own ideas. All other options can be defaulted. Just click Next. That's it, finally the installation was successful.

details as follows:

1.3 openEuler-20.03-LTS image file download

Step 1 Enter the download page of Huawei open source mirror site.

URL: https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/ISO/x86_64/, the details are as follows:

Step 2 Click " openEuler-20.03-LTS-x86_64-dvd.iso " to download the corresponding ISO image file.

The downloaded file name is as follows: [openEuler-20.03-LTS-x86_64-dvd.iso](https://mirrors.huaweicloud.com/openeuler/openEuler-20.03-LTS/ISO/x86_64/openEuler-20.03-LTS-x86_64- dvd.iso" \o "openEuler-20.03-LTS-x86_64-dvd.iso)

1.4 Install openEuler-20.03-LTS operating system under VirtualBox


Step 1 Create a new virtual computer.

Open the VirtualBox software and click "New" on the VirtualBox control menu, as follows:
image.png

Click "Wizard Mode" in the lower right corner, as follows:

image.png

Then enter the following interface:

image.png

On this page, fill in the corresponding name (for example: VirtualBox607Euler203Gauss311db1), file storage address (for example: D:\Program Files\VMwork\VirtualBoxEuler), and then click "next".

image.png

Set the memory to 4096MB (indicating that the entire system only has 4G of memory), CPU to 2, and click "next".

image.png

Fill in the virtual hard disk 10G and click "next".

image.png

Enter "Summary" and click "Finish"

The new virtual computer has been completed. Next, set up the virtual computer.

Step 2 Set up a virtual computer and install it.

Click "Settings" on the VirtualBox manager, as follows:

image.png

Click "System" on the settings page to perform system settings. In the startup sequence, move "Optical Drive" and "Hard Disk" to the first and second startup, and uncheck "Floppy Drive", as follows:
image.png

Click the "Storage" setting item, select the CD and click the load button after assigning the CD-ROM drive to load the openEuler-20.03-LTS-x86_64-dvd.iso file downloaded earlier into the CD-ROM drive, as follows:

image.png

Click the "Network" setting item. Two network cards are used here. The connection mode of network card 1 is selected as "Host-Only Network" in the drop-down menu. It is mainly used to connect the local computer to the virtual computer. The details are as follows:

Network card 2 settings, check "Enable network connection", and the "Connection method selection" drop-down selection is "Network Address Translation (NAT)", which is mainly used to connect the virtual computer to the Internet, as follows:

Finally, click the "OK" button to complete the setting. The setting completion page is as follows: Click the "Start" button to start system installation. (Note: Use right Ctrl to switch mouse operations between the virtual machine and the host.)

Finally click the "OK" button to complete the setting. The setting completion page is as follows:

(1) Click the Start button to start system installation. Start the first installation interface and directly press the "Enter" key to enter the self-test interface.

(2), Installation guide interface

The boot menu appears after the system has finished booting using the boot media. The boot menu provides some options in addition to launching the installer. When installing the system, the default installation method is "Test this media & install openEuler20.03-LTS". If you want to select an option other than the default, use the "↑" and "↓" arrow keys on your keyboard to select and press "Enter" when the option is highlighted. The installation boot options are explained as follows: ●Install openEuler 20.03-LTS - Install using the graphical user interface mode on your server. ●Test this media & install openEuler 20.03-LTS - The default option, install using the graphical user interface mode on your server, but the integrity of the installation media will be checked before starting the installation program. ●Troubleshooting - problem locating mode, used when the system cannot be installed normally. After entering the problem locating mode, there are the following two options. ※Install openEuler 20.03-LTS in basic graphics mode - simple graphics installation mode, in which the video driver is not started before the system is up and running. ※Rescue the openEuler system——Rescue mode, used to repair the system. In this mode, the output is directed to the VNC or BMC (Baseboard Management Controller) end, and the serial port is unavailable. In the installation boot interface, press "e" to enter the parameter editing interface of the selected option, and press "c" to enter the command line mode.

(3) Set the installer language

Select Chinese----"Simplified Chinese (China) for language, and then click "Continue" to enter the main interface of installation settings.

(4), installation location

On the "Installation Information Summary" page, select "Installation Location" and set the installation disk and partition of the operating system. In the "Device Selection" interface, you need to configure storage to partition the system. You can configure the partitions manually or choose to have the installer partition them automatically. Note: When partitioning, for the sake of system performance and security, it is recommended that you divide the following separate partitions: /boot, /var, /var/log, /var/log/audit, /home, /tmp. If the system is configured with a swap partition, the swap partition will be used when the system's physical memory is not enough. Although the swap partition can increase the physical memory size limit, if the swap partition is used due to insufficient memory, the system's response time will be increased and the performance will be deteriorated. Therefore, in systems with sufficient physical memory or performance-sensitive systems, it is not recommended to configure swap partitions.

If you need to split a logical volume group, you need to select "Custom" for manual partitioning, and click the "Modify" button in the "Volume Group" area on the "Manual Partitioning" interface to reconfigure the volume group.

●Auto: If you are performing a new installation on an unused storage device, or do not need to retain any data in the storage device, it is recommended to select "Auto" for automatic partitioning. After the setup is complete, click Finish to return to the Installation Information Summary page. ●Customize: If the user needs to perform manual partitioning, select the "Customize" button and click "Finish" in the upper left corner. The manual partitioning interface appears.

Select the "Customize" button and click "Done" in the upper left corner. Scroll down to select "Standard Partitions" and click "Click here to create them automatically". Click "Finish" to enter the next step of settings. Click "Accept Changes" to complete the partition settings, and then proceed to the network and host name settings.

(5), Set the network and host name

On the "Installation Information Summary" page, click "Network and Host Name" to set the network and host name. Set up the
image.png
two network cards respectively, such as the Ethernet (enpOs3) network card. First click the button next to "Close" to turn on the network card. .
image.png
Then set the host name (for example: db1), and click "Apply (A)", then click "Configure".
Note: Be sure to pay attention when setting the host name. If there are multiple students in the same network segment to install according to this document, please try to set the host name to be different.
image.png
In the configuration page, select "General", then check "Automatically connect to this network when available", and then click "Save".
image.png
Parameter setting steps for the first network card To set up the second network card, first open the network card, and then configure it, as follows:
image.png
Click "Save".
image.png
Click "Finish" to complete the network and host name settings.

(6), software selection

On the installation information summary page, click "Software Selection" to perform software installation settings, as follows: Then select "Virtualization Host" on the following page, and check "Linux Remote Management", "Development Tools", and "Security" on the right "Sex Tools", "System Management Tools". Then click Done.

(7) Start installation

After completing the configuration of the above three options on the "Installation Information Summary" page, the warning on the interface will disappear. At this time, the user can click "Start Installation" to install the system, as follows: In user settings, click "ROOT Password". Set a password for the ROOT user (for example: openGauss@123), enter the password according to the password complexity and re-enter the password to confirm, and click "Finish". Password complexity The root user password set by the user or the password of the newly created user must meet the password complexity requirements, otherwise the password setting or user creation will fail. The requirements for setting the complexity of the password are as follows: ※The password must be at least 8 characters long. ※The password must contain at least three types of uppercase letters, lowercase letters, numbers, and special characters. ※The password cannot be the same as the account number. ※The password cannot use dictionary words. Click "Create User" (for example: user test, password openGauss@123) and click "Finish". After the installation process starts, a progress page will appear, showing the installation progress and the progress of the selected software package being written to the system. If the system installation process is interrupted, the system will be unavailable and needs to be reinstalled. The system is being installed. After waiting for a few minutes, the following interface will appear. Click "End Configuration". This interface appears to indicate that the system installation is complete, then click "Restart".

(8) Log in and view kernel and system version information

After restarting, you are required to enter the user name and password. Here, log in as the root user. The password is such as: openGauss @123 . Note: The password is not displayed when entering. After logging in, you can see the welcome interface. The Linux kernel version of the openEuler system is 4.19.20. Use uname -a to check the system kernel version, and use cat /etc/os-release to check the openEuler version information.

Authorized users only. All activities may be monitored and reported.
Activate the web console with: systemctl enable --now cockpit.socket
nodeA login: root
Password:
Authorized users only. All activities may be monitored and reported.
Last login: Mon Jan 16 12:29:46 2023
Welcome to 4.19.90-2003.4.0.0036.oe1.x86_64
System information as of time: 	2023年 01月 16日 星期一 12:33:19 CST
System load: 	0.00
Processes: 	137
Memory used: 	7.5%
Swap used: 	0.0%
Usage On: 	46%
IP address: 	192.168.138.152
Users online: 	1
[root@host1 ~]# uname -a
Linux host1 4.19.90-2003.4.0.0036.oe1.x86_64 #1 SMP Mon Mar 23 19:10:41 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
[root@host1 ~]# cat /etc/os-release
NAME="openEuler"
VERSION="20.03 (LTS)"
ID="openEuler"
VERSION_ID="20.03"
PRETTY_NAME="openEuler 20.03 (LTS)"
ANSI_COLOR="0;31"
[root@host1 ~]#


Step 3. Confirm the network.

On the Linux operating system, use ifconfig to check whether both network cards start normally, as follows:

[root@db1 ~]# ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.56.5  netmask 255.255.255.0  broadcast 192.168.56.255
        inet6 fe80::dfdb:ff96:1933:461a  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:a9:06:47  txqueuelen 1000  (Ethernet)
        RX packets 48  bytes 8503 (8.3 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 7853 (7.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.3.15  netmask 255.255.255.0  broadcast 10.0.3.255
        inet6 fe80::446d:7580:4a87:2563  prefixlen 64  scopeid 0x20<link>
        ether 08:00:27:0b:75:c4  txqueuelen 1000  (Ethernet)
        RX packets 57  bytes 5943 (5.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 76  bytes 6950 (6.7 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
…….
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Confirm whether you can access the Internet by pinging baidu.com, as follows:

[root@db1 ~]# ping baidu.com
PING baidu.com (39.156.69.79) 56(84) bytes of data.
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=47 time=48.1 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=47 time=46.5 ms
64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=3 ttl=47 time=49.2 ms

Use the ctrl+c key combination to end the output.

1.5 Preparation of common network tools

Step 1. Application of XSHELL

For ease of operation, you can use SSH tools (such as XSHELL or PuTTY, etc.) to connect to the virtual machine from the local computer by configuring the IP address of the enp0s3 network card (such as: 192.168.56.5), and use the ROOT user to log in.
image.png
image.png
Step 2. Application of XFTP

For ease of operation, you can use the file transfer tool FTP (such as XFTP or WinSCP, etc.) to connect to the virtual machine from the local computer by configuring the IP address of the enp0s3 network card (such as: 192.168.56.5 ), and use the ROOT user to log in.

image.png
image.png
###1.6 OpenGauss installation process

(1)openGauss installation process

as the picture shows

(2)Installation flow chart description

The flow chart is as follows

1.7 OpenGauss installation

Step 1. Software and hardware environment requirements.

(1)Hardware environment requirements

(2)Software environment requirements

●openEuler-20.03-LTS operating system

For ease of operation, you can use SSH tools (such as XSHELL or PuTTY, etc.) to connect to the virtual machine from your local computer by configuring the IP address of the enp0s3 network card (such as 192.168.56.5), and log in as the ROOT user. In the Xshell tool, use uname -r to check the system kernel version, use cat /etc/os-release to check the openEuler version information, execute "hostname" to confirm the server user name (db1 in this case), and execute "ifconfig" or "ip addr" to confirm IP address (in this case, enp0s3 is 192.168.56.4; enp0s8 is 10.0.3.15).

[root@host1 ~\]# cat /etc/os-release

NAME="openEuler"

VERSION="20.03 (LTS)"

ID="openEuler"

VERSION\_ID="20.03"

PRETTY\_NAME="openEuler 20.03 (LTS)"

ANSI\_COLOR="0;31"

root@host1 ~\]# uname -r

4.19.90-2003.4.0.0036.oe1.x86\_64

[root@host1 ~\]# hostname

db1

[root@host1 ~\]# ip addr

1: lo: <LOOPBACK,UP,LOWER\_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000

link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00

inet 127.0.0.1/8 scope host lo

valid\_lft forever preferred\_lft forever

inet6 ::1/128 scope host

valid\_lft forever preferred\_lft forever

2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER\_UP> mtu 1500 qdisc fq\_codel state UP group default qlen 1000

link/ether 08:00:27:a9:06:47 brd ff:ff:ff:ff:ff:ff

inet 192.168.56.5/24 brd 192.168.56.255 scope global dynamic noprefixroute enp0s3

valid\_lft 519sec preferred\_lft 519sec

inet6 fe80::dfdb:ff96:1933:461a/64 scope link noprefixroute

valid\_lft forever preferred\_lft forever

3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER\_UP> mtu 1500 qdisc fq\_codel state UP group default qlen 1000

link/ether 08:00:27:0b:75:c4 brd ff:ff:ff:ff:ff:ff

inet 10.0.3.15/24 brd 10.0.3.255 scope global dynamic noprefixroute enp0s8

valid\_lft 85284sec preferred\_lft 85284sec

inet6 fe80::446d:7580:4a87:2563/64 scope link noprefixroute

valid\_lft forever preferred\_lft forever……

●Get the openGauss installation package

Get the openGaussServer enterprise version openGauss-3.1.1-openEuler-64bit-all.tar.gz from https://opengauss.org/zh/download/ , that is, https://opengauss.obs.cn-south-1.myhuaweicloud. com/3.1.1/x86_openEuler/openGauss-3.1.1-openEuler-64bit-all.tar.gz

image.png

**Step 2. ** Create the autoinstall.sh file.

Open Vbox706openEuler203LTSGaussXXX Enterprise Edition_install.sh in the Windows operating system as follows:
image.png

Use Vi to create the autoinstall.sh file in the /root directory

Open the file Vbox706openEuler203LTSGaussXXX Enterprise Edition_install.sh in the Windows operating system , then execute "vi /root/autoinstall.sh" in the Xshell tool, enter "i" to switch to INSERT mode, and copy the contents of the openEuler203LTSGaussXXX Enterprise Edition_install.sh file After that, right-click and paste it into the terminal. After the pasting is completed, press the host name and IP found in the previous step [ use the IP address of the second network card enp0s8 ] and the openGauss version you want to install [such as changing 2.1.0 to 3.1. 1] Make three modifications, then press the ESC key to exit INSERT mode, enter ":wq" to save and exit the document.

[root@host1 ~\]#vi /root/autoinstall.sh

…….

##一、安装前的准备

##准备软硬件安装环境

##硬件要求最小配置:2\*CPU (1 core)2.0GHz/4G内存/10G硬盘\];

##软件要求:操作系统 openEuler-20.03-LTS准备;获取openGauss安装包。

………

##1.定义主机信息、安装的openGauss、位置、配置文件、版本以及要安装的openGauss下载URL【请根据实际情况修改】

export MY\_HOSTNAME=**db1**

export MY\_HOSTIP=**10.0.3.15**

##**用第二张网卡enp0s8的IP地址**

export MY\_SOFTWARE\_DIRECTORY=/opt/software

export MY\_openGauss\_DIRECTORY=/opt/software/openGauss

export MY\_openGauss\_XML=/opt/software/openGauss/clusterconfig.xml

export MY\_openGauss\_Version=**3.1.1**

export openGauss\_Download\_url=https://opengauss.obs.cn-south-1.myhuaweicloud.com/$MY\_openGauss\_Version/x86\_openEuler/openGauss-$MY\_openGauss\_Version-openEuler-64bit-all.tar.gz

echo "1.Define Host info completed."

echo -e "\\n"

##2. 设置主机名、IP并配置hosts文件

hostnamectl set-hostname $MY\_HOSTNAME

sed -i '/$MY\_HOSTIP/d' /etc/hosts

echo "$MY\_HOSTIP $MY\_HOSTNAME #Gauss OM IP Hosts Mapping" >> /etc/hosts

cat /etc/hosts

echo "2.Configure /etc/hosts ,Gauss OM IP Hosts Mapping completed."

echo -e "\\n"

\## 3. 关闭SELINUX及关闭防火墙

##目前仅支持在防火墙关闭的状态下进行安装。

sed -i '/^SELINUX=/d' /etc/selinux/config

echo "SELINUX=disabled">>/etc/selinux/config

cat /etc/selinux/config|grep "SELINUX=disabled"

systemctl disable firewalld.service

systemctl stop firewalld.service

echo "Firewalld"\`systemctl status firewalld|grep Active\`

echo "3.Disable SELINUX and firewalld service completed."

echo -e "\\n"

## 4. 检查主机信息

##root登录到openEuler,查看系统Linux内核版本和openEuler 20.03 LTS的版本信息为确保成功安装

##检查主机名,hostname与/etc/hostname是否一致。

##预安装过程中,会对hostname进行检查。

uname -r

……..

**Step 3. ** Deploy openGaussX.XX with one click.

Run the "autoinstall.sh" file to complete the one-click deployment of openGaussX.XX. During the execution process, the user chooses whether to create mutual trust according to the prompts , and enters the password of the omm user of the operating system.

[root@ host1 ~\]# sh /root/autoinstall.sh

…..

Parsing the configuration file.

Successfully parsed the configuration file.

Installing the tools on the local node.

Successfully installed the tools on the local node.

Setting pssh path

Successfully set core path.

Are you sure you want to create the user\[omm\] and create trust for it (yes/no)? **yes**

Password:

Password:

Successfully created \[omm\] user on all nodes.

Preparing SSH service.


please enter password for database:

Please repeat for database:

………..

25.Clear the openGauss installation package completed.

openGauss Install completed congratulations

Congratulations!!!"

During this period, you need to create an operating system omm user and set a password (for example, password: openGauss@123), and enter the omm password for the operation database (for example, password: openGauss@123).

Step 4. Turn on swap to swap memory.

[For devices with 2G memory, it is recommended to open SWAP after the installation is completed to indirectly "expand the memory capacity"]

Turning off swap memory is to ensure the access performance of the database and avoid eliminating the buffer memory of the database to the disk. If the server memory is relatively small and the memory is overloaded, swap can be turned on to ensure normal operation.

[root@host1 ~\]# swapon -a

The database installation is completed.

2. gsql client tool uses database

This section describes basic operations for working with the database. Through this section you can complete operations such as creating a database, creating a table, inserting data into the table, and querying data in the table.

2.1 Prerequisites

  1. openGauss runs normally.
  2. Since this experiment is a basic use of the openGauss database, you need to master the basic operations and SQL syntax of the openGauss database. The openGauss database supports SQL2003 standard syntax.

2.2 Operation steps

Step 1. Log in using SSH tool

For ease of operation, you can use SSH tools (such as XSHELL or PuTTY, etc.) to connect to the virtual machine from your local computer by configuring the IP address of the ens33 network card (such as 192.168.138.136), and log in as the ROOT user. See 1.5 Preparation of Common Network Tools

Step 2. Database master node.

[root@host1 ~]# su - omm

If you are not sure which server the database master node is deployed on, please confirm the connection information.

Step 3. Start the service.

Start service command:

[omm@host1 ~]$ gs_om -t start

The results are shown below:

Starting cluster.
=========================================
=========================================
Successfully started.

Step 4. Connect to the database.

[omm@host1 ~]$ gsql -d postgres -p 26000 -r

When the result is displayed as the following information, it means the connection is successful.

gsql ((openGauss 3.1.1 build 70980198) compiled at 2023-01-06 09:27:09 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=#

Among them, postgres is the database generated by default after the openGauss installation is completed. You can initially connect to this database to create a new database. 26000 is the port number of the database master node. It needs to be replaced according to the actual situation of openGauss. Please confirm to obtain the connection information.

Extended information:

  • Before using the database, you need to use a client program or tool to connect to the database, and then you can use the database by executing SQL through the client program or tool.
  • gsql is a command line database connection tool provided by openGauss database.

Step 5. Create a database user and authorize it to create a new database.

By default, only the administrator user created during openGauss installation can access the initial database. You can also create other database user accounts.

postgres=# CREATE USER mygaussuser WITH PASSWORD "Bigdata@123"; 

When the result is displayed as the following information, the creation is successful.

CREATE ROLE 

As above, a user named mygaussuser and password Bigdata@123 is created. The following authorizes the mygaussuser user to be the system administrator user:

postgres=# alter user mygaussuser sysadmin;
ALTER ROLE

Step 6. Create the database myuniversity.

postgres=# CREATE DATABASE myuniversity OWNER mygaussuser; 

When the result is displayed as the following information, the creation is successful.

CREATE DATABASE 

After creating the myuniversity database, you can press the \q method to exit the myuniversity database, and use a new user to connect to the database to perform subsequent table creation and other operations. Of course, you can also choose to continue the subsequent experience under the myuniversity database. Exit the myuniversity database.

postgres=# \q

Step 7. Connect to this database using a new user.

[omm@host1 ~]$ gsql -d myuniversity -p 26000 -U mygaussuser -W Bigdata@123  -r

When the result is displayed as the following information, it means the connection is successful.

gsql ((openGauss 3.1.1 build 70980198) compiled at 2023-01-06 09:27:09 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

myuniversity=>  

Step 8. Create SCHEMA.

myuniversity=> CREATE SCHEMA mygaussuser AUTHORIZATION mygaussuser;

When the result is displayed as the following information, it means that SCHEMA is created successfully.

CREATE SCHEMA  

Step 9. Create the table.

Create a table named mytable with only one column. The field name is firstcol and the field type is integer.

myuniversity=> CREATE TABLE mytable (firstcol int); 
CREATE TABLE

Step 10. Insert data into the table:

myuniversity=> INSERT INTO mytable values (100); 

When the result is displayed as the following information, it means the data was inserted successfully.

INSERT 0 1   

View the data in the table:

myuniversity=> SELECT * from mytable; 
 firstcol 
----------
      100
(1 row)

myuniversity=>

Step 11. Use the \l metacommand to view the database list of the database system.

myuniversity=> \l
myuniversity=>

Step 12. Change the password of user mygaussuser to openGauss@123, and then exit the myuniversity database.

myuniversity=>alter user mygaussuser identified by 'openGauss@123’ replace 'Bigdata@123';
myuniversity=>\q
[omm@host1 ~]$exit
[root@host1 ~]#

This experiment is over.

Choose one installation of Navicat and Data Studio, and only one of them can be used at the same time. It is recommended to use Navicat, which is more stable.

3. Navicat Premium client tool uses database

This section describes the basic operations of using Navicat Premium client tool. Through this section you can complete operations such as creating a database, creating a table, inserting data into the table, and querying data in the table.

3.1 Introduction to Navicat Premium

Navicat Premium is a set of database development tools that can create multiple connections, allowing you to connect to MySQL, MariaDB, MongoDB, SQL Server, Oracle, PostgreSQL and SQLite simultaneously from a single application. It is compatible with OceanBase database and cloud databases such as Amazon RDS, Amazon Aurora, Amazon Redshift, Microsoft Azure, Oracle Cloud, MongoDB Atlas, Alibaba Cloud, Tencent Cloud and Huawei Cloud. You can create, manage and maintain databases quickly and easily.

Database developers require only minimal programming knowledge to use this tool for database object manipulation. Navicat Premium provides a rich variety of features.

Main Window | Object Designer | Data Operations (RDBMS) | Data Operations (MongoDB) | Models | Charts | Data Synchronization | Structure Synchronization | Data Generation | Schema Analysis (MongoDB) | Auto Complete Code | Code Snippets | Auto Run | Navicat Collaboration cooperate

The functions are:

Data viewer

Add, modify, and delete records using tree view, JSON view, datasheet-style grid view, and a range of data editing tools to make it easy for you to edit your data. Navicat gives you the tools you need to manage your data effectively and ensure a smooth process.

object designer

Our object designer lets you manage database objects quickly and easily. Navicat is also equipped with a convenient user interface that divides query writing into several tabs. Allowing you to be more confident and accurate in every step of writing complex SQL.

SQL editor/debugger

Visual query builder helps you create, edit, and run queries without worrying about syntax and correct command usage. Code auto-completion and custom code snippets make coding faster with keyword suggestions and the ability to reduce retyping the same code. Our debugging component can quickly find and correct errors in PL/SQL and PL/PGSQL coding. You can set breakpoints, step through the program, view and modify variable values, and inspect the call stack.

migrate

Data transfer, data synchronization, and structure synchronization let you migrate data quickly and easily at low cost. Provides detailed guidance for transferring data between various database management systems. Compare and synchronize database data and structures. Set up and deploy alignments in seconds and get detailed scripts for the changes you want to run.

Model

Create, modify and manage all database objects using our professional object designer. Sophisticated database design and modeling tools transform databases into graphical representations, allowing you to easily model, build, and understand complex databases.

chart

The charting feature lets you create visual representations of large data sets and helps you gain deeper insights from your data. Explore and uncover patterns, trends, and relationships between data and create effective visual outputs of your findings displayed on dashboards for sharing.

Import and Export

The Import Wizard can transfer data in different formats to the database, or set up a data source connection and use ODBC transfer. Data from tables, views or query results can be exported to Excel, Access, CSV and other formats.

data generator

Provides comprehensive functionality to generate large amounts of high-quality test data. You can quickly create true data sets with referential integrity based on business rules and constraints.

Improve work efficiency

Powerful local backup or restore solutions and intuitive interfaces for MongoDump, Oracle Data Pump or SQL Server backup utilities guide you through the entire backup process and reduce the chance of errors. Set repeatable deployment sequences (such as database backups, MapReduce jobs, and script runs) to run automatically at specific times or dates. No matter where you are, you can always get things done.

pattern analyzer

Explore your MongoDB schema using built-in visualization tools. Analyze documents and reveal rich structure in collections so you can understand patterns in your data, detect pattern anomalies and examine outliers.

Collaboration

Sync your connection settings, queries, models, code snippets, diagram workspaces, and virtual group information to the cloud service so you can access them in real time and share them with colleagues anywhere, anytime.

Secure connection

Create secure connections through SSH tunnels and SSL to ensure that every connection is safe, stable and reliable. We support different authentication methods for database servers, such as PAM authentication for MySQL and MariaDB, Kerberos and X.509 authentication for MongoDB, and GSSAPI authentication for PostgreSQL. Navicat provides more authentication mechanisms and a high-performance environment, so you no longer have to worry about using unsecured networks to connect.

dark mode

Set a dark background theme to protect your eyes from your computer’s traditional blinding white. In dark mode, the appearance of the page does not change any behavior.

Cross-platform license

Now you can use cross-platform licenses in Navicat. Whether running on Windows, macOS, or Linux, you purchase once and choose the platform you want to activate, and you can later transfer the license to other platforms.

3.2 openGauss server (DB Server) configuration

Step 1. Log in using SSH tool

For ease of operation, you can use SSH tools (such as XSHELL or PuTTY, etc.) to connect to the virtual machine from your local computer by configuring the IP address of the ens33 network card (such as 192.168.138.152), log in as the ROOT user, and then log in as omm.

[root@host1 ~]# su - omm

Step 2. Modify the pg_hba.conf file of the database and specify the client access mode to change the encryption to md5.

Add host all all 0.0.0.0/0 md5 to the /gaussdb/data/host1/pg_hba.conf file.

[omm@db1 ~]$gs_guc set -N all -I all -h "host all all 0.0.0.0/0 md5"  

Step 3. Modify the database listening address and default encryption method.

(1) Modify the value of listen_addresses.

Modify the value of listen_addresses in the /gaussdb/data/host1/postgresql.conf file to *.

[omm@db1 ~]$ gs_guc set -I all -c "listen_addresses='*'"

(2) Change the default password encryption method to md5 (default sha256).

Change the value of password_encryption_type in the /gaussdb/data/host1/postgresql.conf file to 0.

[omm@db1 ~]$ gs_guc set -I all -c "password_encryption_type=0"

Tips: • When the parameter password_encryption_type is set to 0, it means that the password is encrypted using md5. md5 is an unsafe encryption algorithm and is not recommended. • When the parameter password_encryption_type is set to 1, it means that the password is encrypted using sha256 and md5. It contains md5, which is an unsafe encryption algorithm and is not recommended. • When the parameter password_encryption_type is set to 2, it means that the password is encrypted using sha256, which is the default configuration.

Step 4. Restart the service.

Start service command:

[omm@host1 ~]$ gs_om -t restart

The results are shown below:

Starting cluster.
=========================================
Successfully started.

Step 5. Connect to the database.

[omm@host1 ~]$ gsql -d postgres -p 26000 -r

When the result is displayed as the following information, it means the connection is successful.

gsql ((openGauss3.1.1 build 70980198) compiled at 2023-01-06 09:27:09 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=#

Among them, postgres is the database generated by default after the openGauss installation is completed. You can initially connect to this database to create a new database. 26000 is the port number of the database master node. It needs to be replaced according to the actual situation of openGauss. Please confirm to obtain the connection information.

Extended information:

  • Before using the database, you need to use a client program or tool to connect to the database, and then you can use the database by executing SQL through the client program or tool.
  • gsql is a command line database connection tool provided by openGauss database.
Step 6. Create a new database user and authorize it to create a new database.

By default, only the administrator user created during openGauss installation can access the initial database. You can also create other system administrator user accounts opengaussuser.

postgres=# CREATE USER opengaussuser WITH PASSWORD "Bigdata@123" sysadmin;  
CREATE ROLE
postgres =# CREATE DATABASE dbopengauss OWNER opengaussuser;

Exit the postgres database.

postgres=# \q

Step 7. Connect to this database using a new user.

[omm@host1 ~]$ gsql -d dbopengauss -p 26000 -U opengaussuser -W Bigdata@123  -r

When the result is displayed as the following information, it means the connection is successful.

gsql ((openGauss3.1.1 build 70980198) compiled at 2023-01-06 09:27:09 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.


Step 8. Create SCHEMA.

dbopengauss=> CREATE SCHEMA opengaussuser AUTHORIZATION opengaussuser;

When the result is displayed as the following information, it means that SCHEMA is created successfully.

CREATE SCHEMA  

Step 9. Change the user password and exit the dbopengauss database.

dbopengauss=# alter user opengaussuser identified by 'openGauss@123' replace 'Bigdata@123';
dbopengauss=# \q

3.3 Navicat Premium client tool installation and environment confirmation

Step 1. Download Navicat Premium (if you have prepared it in advance, skip this part)

https://www.navicat.com.cn/download/direct-download?product=navicat_premium_cs_x64.exe&location=1

Step 2. The downloaded file name is: navicat161_premium_cs_x64.exe and install it.

Double-click navicat161_premium_cs_x64.exe and install it to the location you specify. The best installation location is the d: drive, not the c: drive, such as: D:\Program Files\PremiumSoft\Navicat Premium 16

Step 3. Start Navicat Premium 16 client. After startup, the interface is as follows:

3.4 Navicat Premium client tool configuration.

On the Navicat Premium tool interface, click "File" => "New Connection" => "PostgreSQL..." to enter the following setting interface:

Name: Custom

Host: 192.168.138.153

Port: 26000

Database: postgres (you can also connect to an existing database on openGauss, such as dbopengauss)

Username: The user created in the step of preparing to connect to the environment (opengaussuser)

Password: The user password created in the step of preparing to connect to the environment (openGauss@123)

After the setting is completed, click "Test Connection" => "OK" if the connection is successful; then click the "OK" button to connect. After the connection is successful, the interface is as follows:

3.5 Navicat Premium User Interface

The main interface of Navicat Premium includes (for details, please refer to the help on the main menu of the main interface of Navicat Premium, namely Navicat User Guide):

①Main toolbar

The main toolbar gives you access to basic objects and functionality such as connections, users, tables, collections, backups, autoruns, and more. To use thin icons or hide icon titles, right-click the toolbar and disable Use Large Icons or Show Titles.

②Navigation pane

The navigation pane is the basic way to browse connections, databases, and database objects. If the navigation pane is hidden, select View -> Navigation Pane -> Show Navigation Pane from the menu bar.

③Tab bar

The tab bar lets you switch between windows with tabs within the object pane. You can also choose to display the popup in a new tab or in a new window. If you have multiple tabs open, you can use the CTRL+TAB keys to easily switch to other tabs. See options.

④Object toolbar

The Object toolbar provides additional controls for manipulating objects.

⑤Object window

The Object Pane displays a list of objects (for example: tables, collections, views, queries, etc.), and a window form with tabs. Switch the view of the object tab using different icons for the "List", "Details" and "ER Diagram" buttons.

⑥Information pane

The information pane displays object details, project activity logs, DDL for database objects, object dependencies, user or role membership, and previews. If the information pane is hidden, select View->Information Pane->Show Information Pane from the menu bar.

⑦Status bar

The status bar displays status information about the window currently in use.

3.6 Obtain Navicat Premium tool manual

Click on the User Manual under Help on the main menu of the Navicat Premium main interface, as follows:

4. Data Studio tool uses database

This section describes basic operations using the Data Studio client tool. Through this section you can complete operations such as creating a database, creating a table, inserting data into the table, and querying data in the table.

4.1 Introduction to Data Studio

Data Studio is an integrated development environment (IDE) that helps database developers easily build applications and provides key database features in the form of a graphical interface. Database developers require only minimal programming knowledge to use this tool for database object manipulation. Data Studio provides a rich variety of features, such as:

Create and manage database objects

Execute SQL statements/scripts

Edit and execute PL/SQL statements

Graphically view execution plans and overhead

Export table data, etc.

Creating and managing database objects includes:

database

model

function

process

surface

sequence

index

view

table space

synonyms

Data Studio also provides SQL Assistant for executing various queries/procedures/functions in "SQL Terminal" and "PL/SQLViewer".

4.2 openGauss server (DB Server) configuration

Step 1. Log in using SSH tool

For ease of operation, you can use SSH tools (such as XSHELL or PuTTY, etc.) to connect to the virtual machine from your local computer by configuring the IP address of the ens33 network card (such as 192.168.138.153), log in as the ROOT user, and then log in as omm.

[root@host1 ~]# su - omm

Step 2. Modify the pg_hba.conf file of the database, specify the client access method, and change the encryption to sha256.

Add host all all 0.0.0.0/0 sha256 to the /gaussdb/data/host1/pg_hba.conf file.

[omm@db1 ~]$gs_guc set -N all -I all -h "host all all 0.0.0.0/0 sha256"  

Step 3. Modify the database listening address and default encryption method.

(1) Modify the value of listen_addresses.

Modify the value of listen_addresses in the /gaussdb/data/host1/postgresql.conf file to *.

[omm@db1 ~]$ gs_guc set -I all -c "listen_addresses='*'"

(2) Change the default password encryption method to sha256 (default sha256).

Change the value of password_encryption_type in the /gaussdb/data/host1/postgresql.conf file to 2.

[omm@db1 ~]$ gs_guc set -I all -c "password_encryption_type=2"

Tips: • When the parameter password_encryption_type is set to 0, it means that the password is encrypted using md5. md5 is an unsafe encryption algorithm and is not recommended. • When the parameter password_encryption_type is set to 1, it means that the password is encrypted using sha256 and md5. It contains md5, which is an unsafe encryption algorithm and is not recommended. • When the parameter password_encryption_type is set to 2, it means that the password is encrypted using sha256, which is the default configuration.

Step 4. Restart the service.

Start service command:

[omm@host1 ~]$ gs_om -t restart

The results are shown below:

Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
Starting cluster.
=========================================
[SUCCESS] db1
……
=========================================
Successfully started.

Step 5. Connect to the database.

[omm@host1 ~]$ gsql -d postgres -p 26000 -r

When the result is displayed as the following information, it means the connection is successful.

gsql ((openGauss 2.1.0 build 70980198) compiled at 2023-01-06 09:27:09 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
openGauss=#

Among them, postgres is the database generated by default after the openGauss installation is completed. You can initially connect to this database to create a new database. 26000 is the port number of the database master node. It needs to be replaced according to the actual situation of openGauss. Please confirm to obtain the connection information.
Step 6. Create a new database user and authorize it to create a new database.
By default, only the administrator user created during openGauss installation can access the initial database. You can also create other system administrator user accounts gaussuser.

postgres=# CREATE USER gaussuser WITH PASSWORD "Bigdata@123" sysadmin;  
CREATE ROLE
postgres =# CREATE DATABASE dbgauss OWNER gaussuser;

Exit the postgres database.

postgres=# \q

Step 7. Connect to this database using a new user.

[omm@host1 ~]$ gsql -d dbgauss -p 26000 -U gaussuser -W Bigdata@123  -r

When the result is displayed as the following information, it means the connection is successful.

gsql ((openGauss 2.1.0 build 70980198) compiled at 2023-01-06 09:27:09 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

Step 8. Create SCHEMA.

dbgauss=> CREATE SCHEMA gaussuser AUTHORIZATION gaussuser;

When the result is displayed as the following information, it means that SCHEMA is created successfully.

CREATE SCHEMA  

Step 9. Exit the database.

dbgauss=\q

4.3 Data Studio client tool installation and environment confirmation

Step 1. JDK environment confirmation

(1) DataStudio_win_64 (2.1.0) is recommended to be installed and configured based on Open JDK 1.8.0_181, JavaFx or higher version corresponding to the operating system bitness, in order to avoid software incompatibility. Please install and configure. Before DataStudio_win_64 (2.1.0), uninstall other versions of JDK and install jdk-8u261-windows-x64. (2) DataStudio_win_64 (3.1.1) is recommended to be installed and configured based on Open JDK11, JavaFx or higher versions corresponding to the operating system bit number.

Step 2. Download the Data Studio client tool software package (if you have prepared it in advance, skip this part directly)

Get the reference address: https://opengauss.obs.cn-south-1.myhuaweicloud.com/2.1.0/DataStudio_win_64.zip

Step 3. The downloaded file name is: DataStudio_win_64.zip, unzip and install.

Unzip the downloaded software package (DataStudio_win_64.zip) to a location you specify, such as to drive D, as follows:

Step 4. Locate and double-click Data Studio.exe to start the Data Studio client. The interface after startup is as follows:

4.4 Data Studio client tool configuration

On the Data Studio tool interface, click "New Connection" under "File" to enter the following setting interface:

Name: Custom

Host: 192.168.138.136

Port: 26000

Database: postgres (you can also connect to an existing database on openGauss, such as dbgauss)

Username: The user created in the step of preparing to connect to the environment (gaussuser)

Password: The user password created in the step of preparing to connect to the environment (Bigdata@123)

Enable SSL: Disable

Note: ① The openGauss password uses sha256 encryption by default. Mismatching encryption methods may cause login failure.

② If you enable SSL parameters, you need to configure the client SSL certificate, otherwise the connection will fail.

③ Before connecting, please ensure that the network IP is reachable and the port is open

After the setting is completed, click the "OK" button to connect. After the connection is successful, the interface is as follows:

4.5 Data Studio User Interface

The main interface of Data Studio includes:

  1. Main menu: Provides basic operations for using Data Studio;
  2. Toolbar: Provides access to frequently used operations;
  3. "SQL Terminal" tab: In this window, you can execute SQL statements and functions/procedures;
  4. "PL/SQL Viewer" tab: displays function/procedure information;
  5. The editing area is used for editing operations;
  6. "Call Stack" pane: displays the execution stack; 7. "Breakpoint" pane: displays breakpoint information;
  7. "Variables" pane: displays variables and their variable values;
  8. "SQL Assistant" tab: Displays suggestions or references for information entered in the "SQL Terminal" and "PL/SQL Viewer" tabs;
  9. "Results" tab: displays the results of executed functions/procedures or SQL statements;
  10. "Message" tab: displays process output. Display standard input, standard output, and standard error;
  11. "Object Browser" pane: Displays the hierarchical tree structure of the database connection and the related database objects that the user has access to; except for the public schema, all default-created schemas are grouped under "System Schema", and user schemas are grouped under the corresponding In the "user mode" of the database;
  12. Minimize Window Pane: Used to open the Call Stack and Variables panes. This pane only appears when one or more panes in the Call Stack, Variables pane are minimized.
  13. Search toolbar: Used to search for objects in the Object Browser pane. Some items are not visible unless a specific function is triggered. The following figure takes the openGauss interface as an example:

4.6 Obtain tool manual

Click on the User Manual under Help on the main menu of the Data Studio main interface, as follows:

Click to get the user manual, as follows:

This experiment is over.

Guess you like

Origin blog.csdn.net/flydreamfish/article/details/129239490