Foreword: openGauss is an open source relational database management system that deeply integrates Huawei's years of experience in the database field. We hope to attract more contributors through the charm of open source, and jointly build an enterprise-level open source database community that can integrate diversified technical architectures. Today, the seniors lead everyone to start openGauss and learn how to use it
Table of contents
Common operation commands of openGauss database
2.1 Log in to the master node of the database as the operating system user omm
2.2 Commonly used SQL language:
0 tell readers
Huawei has always adhered to the overall development strategy of "hardware openness, software open source, and enabling partners." It supports partners in building their own branded database commercial releases based on openGauss, and supports partners in continuously building their business competitiveness.
1 Initial openGauss
1.1 openGauss overview:
openGauss is a relational database , which adopts client/server, single-process and multi-threaded architecture; it supports stand-alone and one-master-multiple-standby deployment methods, and supports features such as readability of standby machines and high availability of dual machines.
The openGauss kernel is derived from PostgreSQL, and focuses on continuously building competitive features in the direction of architecture, transactions, storage engines, optimizers, etc., deeply optimized on ARM architecture chips, and compatible with X86 architecture. Achieve the following technical features:
- Concurrency control technology based on multi-core architecture, NUMA-Aware storage engine, and SQL-Bypass intelligent route selection and execution technology release the multi-core expansion capability of the processor and realize the performance of 1.5 million tpmC in the two-way Kunpeng 128-core scenario
- Support fast failover with RTO<10S, full link data protection, meeting safety and reliability requirements
- Through intelligent parameter tuning, slow SQL diagnosis, multi-dimensional performance self-monitoring, online SQL time prediction and other capabilities, the operation and maintenance can be simplified from complex to simple
1.2 Application scenarios
The main application scenarios of the openGauss database are divided into:
1. Transactional applications
with large concurrency, large data volume, and online transaction processing-based transactional applications, such as e-commerce, finance, O2O, telecom CRM/billing, etc. Different active and standby deployment modes need to be selected.
2. IoT data is used
in industrial monitoring and remote control, smart city extension, smart home, Internet of Vehicles and other IoT scenarios, where there are many sensing and monitoring devices, high sampling rate, data storage is an additional model, and both operation and analysis are emphasized .
2 openGauss usage skills
Common operation commands of openGauss database
2.1 Log in to the master node of the database as the operating system user omm
su - omm
start service
分布式openGauss:
gs_om -t start 启动服务
gs_om -t restart 重启服务
集中式openGauss:
gs_om -t stop 关闭服务
gs_om -t start 启动服务
Use the "gs_om -t status -detail" command to query the status of each instance of openGauss.
gs_om -t status --detail
- The centralized openGauss cluster is deployed as follows, and the server IP address of the database master node instance is 172.20.73.178
- The data path of the database master node is /opt/gaussdb/master1/
- Centralized without CN, access through primary DN
[omm@openGauss01 ~]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
---------------------------------------------------------------------------
2 openGauss02 172.20.73.179 1 /opt/gaussdb/cmserver/cm_server Standby
3 openGauss03 172.20.74.210 2 /opt/gaussdb/cmserver/cm_server Primary
[ ETCD State ]
node node_ip instance state
---------------------------------------------------------------------------
1 openGauss01 172.20.73.178 7001 /opt/huawei/xuanyuan/etcd StateFollower
2 openGauss02 172.20.73.179 7002 /opt/huawei/xuanyuan/etcd StateLeader
3 openGauss03 172.20.74.210 7003 /opt/huawei/xuanyuan/etcd StateFollower
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : Yes
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state | node node_ip instance state | node node_ip instance state
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
1 openGauss01 172.20.73.178 6001 /opt/gaussdb/master1 P Primary Normal | 2 openGauss02 172.20.73.179 6002 /opt/gaussdb/slave1_1 S Standby Normal | 3 openGauss03 172.20.74.210 6003 /opt/gaussdb/slave1_2 S Standby Normal
[omm@openGauss01 ~]$
Check database performance
gs_checkperf
1. 以简要格式在屏幕上显示性能统计结果。
gs_checkperf -i pmk -U omm
2. 以详细格式在屏幕上显示性能统计结果。
gs_checkperf -i pmk -U omm --detai
Confirm the port number of the database master node
Check the port number information in the postgresql.conf file under the data path of the database master node found in 1.2. An example is as follows:
cat /opt/gaussdb/master1/postgresql.conf |grep port
[omm@openGauss01 ~]$ cat /opt/gaussdb/master1/postgresql.conf |grep port
port = '36000' # (change requires restart)
#ssl_renegotiation_limit = 0 # amount of data between renegotiations, no longer supported
# supported by the operating system:
- 36000 is the port number of the database master node
- The port number will be configured in the xml file when the database is installed, and the port can also be found by viewing the xml configuration file during installation.
list all available databases
gsql -d postgres -p 36000 -l
[omm@openGauss01 ~]$ gsql -d postgres -p 36000 -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+-----------+---------+-------+-------------------
db1 | song | SQL_ASCII | C | C |
db2 | song | SQL_ASCII | C | C |
kwdb | kw | SQL_ASCII | C | C |
mydb | song | GBK | C | C |
postgres | omm | SQL_ASCII | C | C |
song_suse | song | SQL_ASCII | C | C |
template0 | omm | SQL_ASCII | C | C | =c/omm +
| | | | | omm=CTc/omm
template1 | omm | SQL_ASCII | C | C | =c/omm +
| | | | | omm=CTc/omm
(8 rows)
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.
2.2 Commonly used SQL language:
Create database user
create user 用户名 with password "密码";
create user jack password "******";
在每次创建新用户时,系统会在当前登录的数据库中为新用户创建一个同名Schema。对于其他数据库,若需要同名Schema,则需要用户手动创建。
openGauss=# create user jack password "******";
CREATE ROLE
openGauss=# \du
List of roles
Role name | Attributes | Member of
-----------+------------------------------------------------------------------------------------------------------------------+-----------
jack | | {}
kw | | {}
omm | Sysadmin, Create role, Create DB, Replication, Administer audit, Monitoradmin, Operatoradmin, Policyadmin, UseFT | {}
song | Create role, Sysadmin | {}
delete database user
drop user 用户名 cascade;
drop user jack cascade;
Create a database and specify the owner owner
create database 数据库名 owner 用户名;
create database jack_test owner jack;
delete database
drop database 数据库名;
drop database jack_test;