课后作业 1.创建表空间newtbs1 2.创建3个数据库newdb1、newdb2、newdb3,默认表空间为newtbs1 3.使用sql查看表空间newtbs1上有几个数据库 4.在文件系统中查看表空间newtbs1中的多个数据库
复制
0、虚拟机关机了,重启后GaussDB服务没了,看了下重启及状态检查的操作,记录如下(后续补充开机自启动,先写作业):
[omm@Test-GaussDB-VM ~]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Unavailable
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip port instance state
------------------------------------------------------------------------------------------------------
1 Test-GaussDB-VM 192.168.11.101 15400 6001 /opt/huawei/install/data/dn P Primary Manually stopped
[omm@Test-GaussDB-VM ~]$
[omm@Test-GaussDB-VM ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : Jeff_Test_CL
cluster_state : Unavailable
redistributing : No
-----------------------------------------------------------------------
[omm@Test-GaussDB-VM ~]$ gs_om -t start
Starting cluster.
=========================================
[SUCCESS] Test-GaussDB-VM
2022-12-08 16:56:37.875 6391a6c5.1 [unknown] 139633641919616 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-12-08 16:56:37.875 6391a6c5.1 [unknown] 139633641919616 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-12-08 16:56:37.879 6391a6c5.1 [unknown] 139633641919616 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (1024 Mbytes) or shared memory (3436 Mbytes) is larger.
=========================================
Successfully started.
[omm@Test-GaussDB-VM ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : Jeff_Test_CL
cluster_state : Normal
redistributing : No
-----------------------------------------------------------------------
[omm@Test-GaussDB-VM ~]$ gs_om -t status --detail
[ Cluster State ]
cluster_state : Normal
redistributing : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip port instance state
------------------------------------------------------------------------------------------------------
1 Test-GaussDB-VM 192.168.11.101 15400 6001 /opt/huawei/install/data/dn P Primary Normal
[omm@Test-GaussDB-VM ~]$ gs_om -t stop
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
[omm@Test-GaussDB-VM ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : Jeff_Test_CL
cluster_state : Unavailable
redistributing : No
-----------------------------------------------------------------------
[omm@Test-GaussDB-VM ~]$ gs_om -t start
Starting cluster.
=========================================
[SUCCESS] Test-GaussDB-VM
2022-12-08 16:57:19.289 6391a6ef.1 [unknown] 139796638413952 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-12-08 16:57:19.289 6391a6ef.1 [unknown] 139796638413952 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-12-08 16:57:19.290 6391a6ef.1 [unknown] 139796638413952 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (1024 Mbytes) or shared memory (3436 Mbytes) is larger.
=========================================
Successfully started.
[omm@Test-GaussDB-VM ~]$
[omm@Test-GaussDB-VM ~]$ gs_om -t restart
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
Starting cluster.
=========================================
[SUCCESS] Test-GaussDB-VM
2022-12-08 17:08:45.691 6391a99d.1 [unknown] 139926319395968 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-12-08 17:08:45.691 6391a99d.1 [unknown] 139926319395968 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: could not create any HA TCP/IP sockets
2022-12-08 17:08:45.692 6391a99d.1 [unknown] 139926319395968 [unknown] 0 dn_6001 01000 0 [BACKEND] WARNING: Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (1024 Mbytes) or shared memory (3436 Mbytes) is larger.
=========================================
Successfully started.
[omm@Test-GaussDB-VM ~]$ gs_om -t status
-----------------------------------------------------------------------
cluster_name : Jeff_Test_CL
cluster_state : Normal
redistributing : No
-----------------------------------------------------------------------
[omm@Test-GaussDB-VM ~]$ gsql -d omm -p 15400 -r
gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
omm=#
复制
1、环境准备
-- 进入数据库omm,创建表空间、测试数据库 [omm@Test-GaussDB-VM ~]$ gsql -d omm -p 15400 -r gsql ((openGauss 3.1.0 build 4e931f9a) compiled at 2022-09-29 14:19:24 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. omm=# drop DATABASE IF EXISTS musicdb; drop DATABASE IF EXISTS musicdb1; drop DATABASE IF EXISTS musicdb2; drop DATABASE IF EXISTS musicdb3; drop DATABASE IF EXISTS newdb1; drop tablespace IF EXISTS music_tbs; drop tablespace IF EXISTS newtbs1; revoke all on database omm from user5; drop owned by user5 cascade; drop user user5; \c postgres revoke all on database postgres from user1; drop owned by user1 cascade; drop user user1;
复制
2、创建表空间、数据库
CREATE TABLESPACE newtbs1 RELATIVE LOCATION 'tablespace/newtbs1';
CREATE DATABASE newdb1 WITH TABLESPACE = newtbs1 ;
CREATE DATABASE newdb2 WITH TABLESPACE = newtbs1 ;
CREATE DATABASE newdb3 WITH TABLESPACE = newtbs1 ;
复制
3、查看表空间中的多个数据库
--查看数据库、表空间的oid
select oid,datname from pg_database;
select oid,* from pg_tablespace;
select datname,dattablespace,spcname from pg_database d, pg_tablespace t where d.dattablespace=t.oid;
--从文件系统,查看music_tbs表空间oid,可以看到一个表空间可以有多个数据库
cd /var/lib/opengauss/data/pg_tblspc/xxxxx/
cd PG_9.2*
ls
#说明:xxxxx是表空间 music_tbs的oid
复制
4、查询表空间中有多少数据库
select datname,dattablespace,spcname from pg_database d, pg_tablespace t where d.dattablespace=t.oid;
复制
最后修改时间:2022-12-09 08:31:23
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论

2年前

评论
相关阅读
2025年3月国产数据库大事记
墨天轮编辑部
812次阅读
2025-04-03 15:21:16
MogDB 发布更新,解决 openGauss 数据库在长事务情况下Ustore表膨胀问题
MogDB
279次阅读
2025-04-17 10:41:41
内蒙古公司成功完成新一代BOSS云原生系统割接上线
openGauss
219次阅读
2025-03-24 09:40:40
openGauss 7.0.0-RC1 版本正式发布!
Gauss松鼠会
184次阅读
2025-04-01 12:27:03
MogDB 发布更新,解决 openGauss 数据库在长事务情况下Ustore表膨胀问题
云和恩墨
174次阅读
2025-04-16 09:52:02
openGauss 7.0.0-RC1 版本体验:一主一备快速安装指南
孙莹
168次阅读
2025-04-01 10:30:07
从数据库源码比较 PostgreSql和OpenGauss的启动过程
maozicb
102次阅读
2025-03-24 15:55:04
一文快速上手openGauss
进击的CJR
102次阅读
2025-03-26 16:12:54
鲲鹏RAG一体机解决方案正式发布 openGauss DataVec向量数据库助力DeepSeek行业应用
Gauss松鼠会
82次阅读
2025-03-31 10:00:29
openGauss6.0.0适配操作系统自带的软件,不依赖三方库
来杯拿铁
64次阅读
2025-04-18 10:49:53