当前位置:网站首页>MogDB study notes - starting from 0
MogDB study notes - starting from 0
2022-08-08 18:45:00 【Ink Sky Wheel】
MogDB学习笔记-从0开始
写在前面
MogDB是基于OpenGauss开发的、OpenGauss又是基于PostgreSql开发的,My cognitive opportunities for these three database systems are:0,So refer to it when you studyOpenGauss和PostgreSql的官方文档.
Learning environment is set up based on the previous noteMogDB主从环境,接下来从0开始学习PGfaction database.
Manually deploy the address of the master-slave note:https://www.modb.pro/db/453770
基本概念
through the basic think about itMysqlActually quite similar,只是mysqlThere is no concept of schema.
数据库(database)
数据库用于管理各类数据对象,与其他数据库隔离.创建数据对象时可以指定对应的表空间,如果不指定相应的表空间,相关的对象会默认保存在PG_DEFAULT空间中.数据库管理的对象可分布在多个表空间上.
表空间(tablespace)
在openGauss中,表空间是一个目录,可以存在多个,里面存储的是它所包含的数据库的各种物理文件.由于表空间是一个目录,仅是起到了物理隔离的作用,其管理功能依赖于文件系统.
模式(schema)
openGauss的模式是对数据库做一个逻辑分割.所有的数据库对象都建立在模式下面.openGauss的模式和用户是弱绑定的,所谓的弱绑定是指虽然创建用户的同时会自动创建一个同名模式,但用户也可以单独创建模式,并且为用户指定其他的模式.
用户和角色(user role)
openGauss使用用户和角色来控制对数据库的访问.根据角色自身的设置不同,一个角色可以看做是一个数据库用户,或者一组数据库用户.在openGauss中角色和用户之间的区别只在于角色默认是没有LOGIN权限的.在openGauss中一个用户唯一对应一个角色,不过可以使用角色叠加来更灵活地进行管理.
数据文件(Datafile Segment)
Each table usually only corresponds to a data file.If a particular data is greater than the table1GB,will be divided into multiple data file storage
数据库(block)
The basic unit of the database management,默认是8k
学习环境
NODE1(主库) | NODE2(从库) | |
Hostname | mogdb1 | mogdb2 |
IP | 10.80.9.249 | 10.80.9.250 |
磁盘 | 20G | 20G |
内存 | 2G | 2G |
MogDB初窥
1、登录主库
[[email protected] ~]$ gsql -d postgres -p 26000 |
2、创建用户
create user zkh with password "Zkh12345678"; |
3、Empower new usersdba
grant all privileges to zkh; |
4、创建数据库,并指定所有者
create database db_mogdb owner zkh; |
5、Verify that the slave library is successfully synchronized
主库
gsql -d postgres -p 26000 -l |
从库
It can be seen that the operation on the master library is also successfully synchronized from the slave library
6、Using the new user to connect the new library
gsql -d db_mogdb -p 26000 -U zkh -W Zkh12345678 |
7、创建表
CREATE TABLE mytable (firstcol int); |
Check the table information just created
select * from pg_tables where tablename='mytable'; |
By querying, you can see that this table belongs topublic模式下.这一点区别于Oracle或者DB2,Because the above two databases will be created to the current by default when the table is createduser的schema下面
8、创建模式
CREATE SCHEMA zkh AUTHORIZATION zkh; |
再次创建表
CREATE TABLE mytable1(firstcol int); |
查询表的信息
select * from pg_tables where tablename in('mytable','mytable1'); |
new table can be seenmytable1已经创建在zkh的模式下了.
9,Verify that the table is in sync from the library
登录从库
gsql -d db_mogdb -p 26000 -U zkh -W Zkh12345678 |
Whether the query table is synchronized
select * from pg_tables where tablename in('mytable','mytable1'); |
The data has been synchronized to the slave library
10、Query the physical location of data files
首先查询data目录的位置,You can use several methods such as viewingconfig文件等等,这里使用sql查询
show data_directory; |
The table data will be stored in the data directorybase目录.Each database has a correspondingid,先看一下base目录的目录结构
查询数据库对应的id
select datname,oid from pg_database; |
数据文件存放在base/16388目录下
Further query tableoid是什么
select oid,relname,relnamespace from PG_CLASS where relname like 'mytable%'; |
The two files in the picture are the tables I just created
最后
Note this timeMogDBThe first use also verified whether the built master-slave environment can be synchronized normally,continue from0开始学习MogDB,Take this opportunity to learnPG派系.
边栏推荐
- Shell脚本三剑客(grep、sed、awk)
- 为什么需要交叉编译器
- Rethinking HTAP database caused by rereading GPDB and TiDB papers
- CF633C(trie树dfs / 字符串hash + 线性dp)
- JVM内存模型和结构详解(五大模型图解)
- 做测试几年,靠业务熟悉吃老本,技术短板暴露,30岁被无情辞退...
- ABAP 报表中如何给报表的输入参数增添 F4 Value Help
- Dataworks上的ODPS spark处理数据会比直接用ODPS SQL效率高吗?
- 牛客多校第6场M(dp或者递推)
- what‘s the meaning of xenial
猜你喜欢
随机推荐
【Promise.allSettled】手写Promise.allSettled方法
hdu1042 N!(大数)
This error is reported when the shake database is started. Is there a problem with the configuration?
请问shake数据库中mongoshake同步过程中,src_mongo挂了,同步服务不会退出吗?
Shell脚本三剑客(grep、sed、awk)
数字货币永续合约交易所开发开发功能以及代码呈现
QT With OpenGL (Bloom) (Bloom)
连接工具和idea能查询出数据库数据,项目中查不到数据库数据:解决办法
内核实战教程第1期|数据库系统概述,带你走近 OceanBase 研发环境!
关于SBOM最基础元素,你需要知道的(Part I)
APICloud AVM 封装日期和时间选择组件
轻量全景查看器 pannellum初探
MySQL:Update高并发下变慢的案例及其涉及的特性
CS231n: 12 Reinforcement Learning
元宇宙三巨头Animoca Brands、Yuga Labs、Gala多维度对比,谁才是未来?
搭建DG导致归档日志量变多问题排查
数据压缩和归档(三)、tarfile
run fscript with lua
Rethinking HTAP database caused by rereading GPDB and TiDB papers
mysql5.7安装教程(附下载链接)