1.离线模式
不提供服务,不能执行任何操作。
相关报错或提示如下。
执行数据库管理员命令时:
shared memory not initialized for GBASEDBTSERVER ‘gbaseserver’
执行数据库SQL操作时:
908: Attempt to connect to database server (gbaseserver) failed.
执行dbaccess时,可以出现菜单,选择数据库出现RUNNING后,一段时间报错。
切换到离线模式时,所有进程都会被杀死。
2.在线模式
可以执行各种操作。
3.单用户模式
也称为管理员模式。
可以执行SQL操作和命令行维护操作。只能管理员(GBASEDBT / DBSA)连接,其它普通用户不能连接。
相关报错或提示如下:
27010: Only an administrative user can connect in administrative user mode.
切换成单用户模式时,所有不是超级管理员的连接将被杀死。
4.静态模式
只能执行命令行维护操作(如备份数据库)。
不能执行SQL命令。
相关报错或提示如下:
27002: No connections are allowed in quiescent mode.
GBase 8s的三种过渡状态
- 初始化(Initialization)
当数据库从离线状态过渡到其他状态时,会经历初始化过程,将磁盘数据加载到共享内存,以及其他初始化操作。 - 快速恢复(Fast Recovery)
当数据库因为意外原因重启,这时候需要处理事务从而恢复到一致性状态。 - 关闭(Shutting Down)
不允许新的连接连接到数据库。
GBase 8s的模式转换状态图

GBase 8s的模式切换演示
离线转单用户
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
[gbasedbt@devsvr ~]$ oninit -j
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Single-User -- Up 00:00:14 -- 597864 Kbytes
单用户转在线
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Single-User -- Up 00:04:33 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -m
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:04:53 -- 597864 Kbytes
离线转在线
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
[gbasedbt@devsvr ~]$ oninit
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:00:14 -- 597864 Kbytes
离线转静态
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
[gbasedbt@devsvr ~]$ oninit -s
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Quiescent -- Up 00:00:15 -- 597864 Kbytes
静态转在线
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Quiescent -- Up 00:00:15 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -m
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:00:49 -- 597864 Kbytes
在线转单用户
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:00:56 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -j
Your evaluation license will expire on 2022-06-18 00:00:00
This will change mode to single user. Only DBSA/gbasedbt can connect
in this mode.
Do you wish to continue (y/n)? y
All threads which are not owned by DBSA/gbasedbt will be killed.
Do you wish to continue (y/n)? y
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Single-User -- Up 00:01:25 -- 597864 Kbytes
单用户转离线
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Single-User -- Up 00:00:14 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -k
Your evaluation license will expire on 2022-06-18 00:00:00
This will take GBase Database Server OFF-LINE -
Do you wish to continue (y/n)? y
There are 0 user threads that will be killed.
Do you wish to continue (y/n)? y
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
在线转离线
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:04:53 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -k
Your evaluation license will expire on 2022-06-18 00:00:00
This will take GBase Database Server OFF-LINE -
Do you wish to continue (y/n)? y
There are 0 user threads that will be killed.
Do you wish to continue (y/n)? y
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
在线转静态有两种方式:
等用户执行完毕再切换
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:00:14 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -s
Your evaluation license will expire on 2022-06-18 00:00:00
This will perform a GRACEFUL SHUTDOWN -
Do you wish to continue (y/n)? y
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Quiescent -- Up 00:00:45 -- 597864 Kbytes
或立即切换
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:00:38 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -u
Your evaluation license will expire on 2022-06-18 00:00:00
This will perform an IMMEDIATE SHUTDOWN -
Do you wish to continue (y/n)? y
There are 0 user threads that will be killed.
Do you wish to continue (y/n)? y
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Quiescent -- Up 00:00:53 -- 597864 Kbytes
静态转离线
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
Quiescent -- Up 00:00:45 -- 597864 Kbytes
[gbasedbt@devsvr ~]$ onmode -k
Your evaluation license will expire on 2022-06-18 00:00:00
This will take GBase Database Server OFF-LINE -
Do you wish to continue (y/n)? y
There are 0 user threads that will be killed.
Do you wish to continue (y/n)? y
[gbasedbt@devsvr ~]$ onstat -
Your evaluation license will expire on 2022-06-18 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbaseserver'
附:GBase 8s的模式与转换状态表
| 离线 | 在线 | 单用户 | 静态 | |
|---|---|---|---|---|
| 离线 | oninit | oninit -j | oninit -s | |
| 在线 | onmode -ky | onmode -j | onmode -s 或 onmode -u | |
| 单用户 | onmode -ky | onmode -m | onmode -s 或 onmode -u | |
| 静态 | onmode -ky | onmode -m | onmode -j |
关闭数据库
onmode -k会导致数据库关闭后处于不一致状态,再启动时会恢复。
建议是先切换成静态模式onmode -s等待事务提交,再关闭。
如果窗口期不够,则onmode -u将事务回滚,再关闭。
原创文章,作者:kirin,如若转载,请注明出处:https://blog.ytso.com/tech/bigdata/318060.html