暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

openGauss每日一练第5天 | 使用1个用户访问多一个数据库||主要线程介绍

原创 Lily 2022-11-28
1256

Table of Contents

好马配好鞍,千里马常有,伯乐不常有。前提你必须要成为千里马…
opneGaussDB21天,第5天的课程总结:
学习openGauss体系结构,使用一个用户访问多个数据库。

主要线程介绍

GaussMaster线程:

openGauss的管理线程,也称为postmaster线程。用于数据库启停、消息转发等管理工作。

bgwriter线程:

负责将脏页数据从内存刷到磁盘中。

pagewriter线程:

负责将脏页数据拷贝至双写(double-writer)区域并落盘,然后将脏页转发给bgwriter子线程进行数据下盘操作。

walwriter线程:

负责将内存中的预写日志(WAL)页数据刷新到预写日志文件中,确保已提交的事务都被永久记录,不会丢失。

walwriter线程:

负责将内存中的预写日志(WAL)页数据刷新到预写日志文件中,确保已提交的事务都被永久记录,不会丢失。

checkpoint线程:

周期性触发,每次触发会将全部脏页面刷到磁盘中

第5天作业答案:

1.创建数据库musicdb10,创建用户user10,赋予sysadmin权限

omm=# CREATE TABLESPACE music_tbs RELATIVE LOCATION 'tablespace/test_ts1';
CREATE TABLESPACE
omm=# CREATE DATABASE musicdb10  WITH TABLESPACE = music_tbs;

CREATE DATABASE
omm=# 
omm=# CREATE USER user10 IDENTIFIED BY 'kunpeng@1234';
NOTICE:  The encrypted password contains MD5 ciphertext, which is not secure.
CREATE ROLE

授予user10数据库系统的SYSADMIN权限

omm=# ALTER USER user10 SYSADMIN;
omm=# ALTER ROLE

2.用户user10访问数据库postgres,创建一个表并插入数据

创建一张t11的表,并向里插入Hello openGauss! 11的数据

omm=# \c postgres user10
Password for user user10: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "postgres" as user "user10".
openGauss=>  create table t11(col1 char(20));
CREATE TABLE
openGauss=> insert into t11 values('Hello openGaus! 11')! 11')! 11')! 11')! 11')! 11')! 11')! 11')! 11')! 11')! 11');!^C
openGauss=> insert into t11 values('Hello openGauss! 11');
INSERT 0 1
openGauss=>  select * from t11; 
         col1         
----------------------
 Hello openGauss! 11 
(1 row)

image.png

3.用户user10访问数据库omm,创建一个表并插入数据

–用户user10登录到数据库omm,创建表t22,并插入、查看数据
切换数据库

openGauss=> \c omm user10
Password for user user10: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "omm" as user "user10".
omm=>

image.png
创建t22表,插入数据

omm=> create table t22 (col1 char(20));
CREATE TABLE
omm=> insert into t22 values('Hello openGauss! 22'); 
omm=> INSERT 0 1
omm=>  select * from t22;
         col1         
----------------------
 Hello openGauss! 22 
(1 row)

image.png

4.用户user10访问数据库musicdb10,创建一个表并插入数据

使用用户user10访问数据库musicdb10,创建t33表,插入数据Hello openGauss! 33

omm=> \c musicdb10 user10
Password for user user10: 
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "musicdb10" as user "user10".
musicdb10=> create table t33  (col1 char(20));
CREATE TABLE
musicdb10=> insert into t33 values('Hello openGauss! 33'); 
INSERT 0 1
musicdb10=> select * from t33;
musicdb10=>          col1         
----------------------
 Hello openGauss! 33 
(1 row)

image.png

最后修改时间:2022-11-28 15:53:21
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论