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

openGauss每日一练第 3 天

原创 陶笑 2022-11-28
933

学习目标

学习openGauss体系结构,了解实例(集簇或服务)和数据库的关系

作业

1.创建表空间music_tbs1和多个数据库music_db、music_db1、music_db2

--创建表空间music_tbs1 openGauss=# CREATE TABLESPACE music_tbs RELATIVE LOCATION 'tablespace/test_ts1'; CREATE TABLESPACE
可以看到在pgdata 的 pg_tblspc下面生成了该表空间的ln,同时在ln对应的目录下生成了相关文件 [omm@og3 dn]$ cd pg_tblspc/ [omm@og3 pg_tblspc]$ ls -ltr total 0 lrwxrwxrwx. 1 omm dbgrp 49 Nov 28 23:21 16390 -> /datafs/ogdata/dn/pg_location/tablespace/test_ts1
--创建3个数据库 openGauss=# CREATE DATABASE musicdb WITH TABLESPACE = music_tbs; CREATE DATABASE openGauss=# CREATE DATABASE musicdb1 WITH TABLESPACE = music_tbs; CREATE DATABASE openGauss=# CREATE DATABASE musicdb2 WITH TABLESPACE = music_tbs;

2.查看数据库上的表空间
pg_default、 pg_global为默认的表空间在data目录下不显示路径

openGauss=# \db List of tablespaces Name | Owner | Location ------------+-------+--------------------- music_tbs | omm | tablespace/test_ts1 pg_default | omm | pg_global | omm | (3 rows)

3.查看openGauss实例上有哪些数据库

--通过pg_database视图查看详细的信息 openGauss=# select * from pg_database; datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | dattablespace | datcompatibility | datacl | datfro zenxid64 | datminmxid -----------+--------+----------+------------+----------+---------------+--------------+--------------+---------------+--------------+---------------+------------------+----------------------+------- ---------+------------ template1 | 10 | 0 | C | C | t | t | -1 | 15619 | 0 | 1663 | A | {=c/omm,omm=CTc/omm} | 13017 | 2 musicdb | 10 | 0 | C | C | f | t | -1 | 15619 | 12662 | 16390 | A | | 12662 | 2 musicdb1 | 10 | 0 | C | C | f | t | -1 | 15619 | 12662 | 16390 | A | | 12662 | 2 template0 | 10 | 0 | C | C | t | f | -1 | 15619 | 0 | 1663 | A | {=c/omm,omm=CTc/omm} | 12662 | 2 musicdb2 | 10 | 0 | C | C | f | t | -1 | 15619 | 12662 | 16390 | A | | 12662 | 2 postgres | 10 | 0 | C | C | f | t | -1 | 15619 | 0 | 1663 | A | | 13372 | 2 (6 rows) --也可以通过\l查看 openGauss=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+-------+-----------+---------+-------+------------------- musicdb | omm | SQL_ASCII | C | C | musicdb1 | omm | SQL_ASCII | C | C | musicdb2 | omm | SQL_ASCII | C | C | postgres | omm | 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 (6 rows)

4.使用操作系统命令,查看openGauss实例的进程、线程

[root@og3 ~]# ps -eaf|grep omm root 63760 61329 0 22:55 pts/1 00:00:00 su - omm omm 63761 63760 0 22:55 pts/1 00:00:00 -bash omm 66149 1 5 22:58 ? 00:01:48 /datafs/og3/app/bin/gaussdb -D /datafs/ogdata/dn omm 68027 63761 0 23:17 pts/1 00:00:00 gsql -p 26000 -d postgres -r root 69105 67832 0 23:34 pts/2 00:00:00 grep --color=auto omm [root@og3 ~]# ps -Tp 66149 PID SPID TTY TIME CMD 66149 66149 ? 00:00:01 gaussdb 66149 66150 ? 00:00:00 jemalloc_bg_thd 66149 66155 ? 00:00:00 gaussdb 66149 66156 ? 00:00:00 syslogger 66149 66157 ? 00:00:00 alarm 66149 66158 ? 00:00:00 reaper 66149 66183 ? 00:00:00 checkpointer 66149 66184 ? 00:00:00 Spbgwriter 66149 66185 ? 00:00:07 pagewriter 66149 66186 ? 00:00:00 pagewriter 66149 66187 ? 00:00:00 pagewriter 66149 66188 ? 00:00:00 pagewriter 66149 66189 ? 00:00:00 pagewriter 66149 66190 ? 00:00:00 WALwriter 66149 66191 ? 00:00:00 WALwriteraux 66149 66192 ? 00:00:00 AVClauncher 66149 66193 ? 00:00:00 Jobscheduler 66149 66194 ? 00:00:00 asyncundolaunch 66149 66195 ? 00:00:00 globalstats 66149 66196 ? 00:00:00 applylauncher 66149 66197 ? 00:00:00 statscollector 66149 66198 ? 00:00:00 txnsnapcapturer 66149 66199 ? 00:00:00 CfsShrinker 66149 66200 ? 00:00:05 percentworker 66149 66201 ? 00:00:56 ashworker 66149 66202 ? 00:00:16 TrackStmtWorker 66149 66203 ? 00:00:00 auditor 66149 66204 ? 00:00:00 2pccleaner 66149 66205 ? 00:00:00 faultmonitor 66149 66207 ? 00:00:04 undorecycler 66149 68028 ? 00:00:00 worker
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论