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

GBase 8s 常用管理员命令汇总-onmode

原创 manhuai 2022-05-13
807

onmode

命令说明
onmode -m将数据库服务器从静态模式或单用户模式,切换为在线模式
onmode -k使数据库服务器处于离线模式,并清除共享内存
onmode -s以优雅地方式关闭数据库服务器,切换到静态模式
onmode -u立即关闭数据库服务器,切换到静态模式
onmode -j使数据库服务器进入单用户方式
onmode -l切换逻辑日志文件
onmode -c强制执行检查点
onmode -r开始共享内存的常驻部分的强制驻留
onmode -n结束共享内存的常驻部分的强制驻留
onmode -p添加或删除虚拟管理器
onmode -P动态地启动、停止或重启监听线程
onmode -wf更新 onconfig 文件中指定配置参数的值
onmode -wm动态设置内存中指定配置参数的值
onmode -z终止数据库服务器会话

切换数据库到在线模式

当数据库处于单用户模式或静态模式时,可以通过这个命令,将数据库切换到在线模式,并对外提供数据库服务。

onmode -m

切换数据库到离线模式

使用下面的命令,可以关闭数据库。当数据库出现意外情况(如rootdbs被意外删除),需要进行冷恢复时,需要先将数据库关闭。

onmode -k

切换数据库到静态模式

当管理员在维护时,不希望有任何的SQL连接,对数据库进行操作,可以将数据库切换到静态模式。

onmode -s
onmode -u

参数
s:优雅地切换到静态模式。当有用户连接到数据库时,会等用户断开连接后再进行模式切换。
u:立即切换到静态模式。当有用户连接到数据库时,会直接杀掉用户连接,并进行模式切换。

切换数据库到单用户模式

切换到单用户模式,只允许管理员进行操作,不允许普通用户连接数据库。

onmode -j

切换逻辑日志文件

强制数据库做一次逻辑日志切换。切换后,新的逻辑日志将写入到下一个逻辑日志文件中。

onmode -l

当前的逻辑日志被标记为C,将逻辑日志切换到下一个后,当前的逻辑日志有11变为12。

[gbasedbt@devsvr ~]$ onstat -l
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:31:26 -- 597864 Kbytes

Physical Logging
......
4843bb78         10       U-B----  1033     2:30053              5000     5000   100.00
4843bbe0         11       U---C-L  1034     2:35053              5000      176     3.52
4843bc48         12       U-B----  1015     2:40053              5000     5000   100.00
......
46febf30         23       U-B----  1026     2:95053              5000     5000   100.00
 20 active, 20 total

[gbasedbt@devsvr ~]$ onmode -l
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -l
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:31:38 -- 597864 Kbytes

Physical Logging
......
4843bbe0         11       U-----L  1034     2:35053              5000      177     3.54
4843bc48         12       U---C--  1035     2:40053              5000        0     0.00
4843bcb0         13       U-B----  1016     2:45053              5000     5000   100.00
......
46febf30         23       U-B----  1026     2:95053              5000     5000   100.00
 20 active, 20 total

[gbasedbt@devsvr ~]$ 

强制执行检查点

执行检查点,会将缓冲区中的“脏”块,写入数据文件。

onmode -c
onmode -c unblock
onmode -c block <seconds>

强制执行检查点操作时,可以选择阻塞或不阻塞事务。

设置共享内存的常驻部分的强制驻留

开始共享内存的常驻部分的强制驻留

[gbasedbt@devsvr ~]$ onmode -r
Your evaluation license will expire on 2022-06-18 00:00:00

This will set the shared memory buffer cache to RESIDENT -
Do you wish to continue (y/n)? y
Note that this command will be phased out in a future release. Please use
the OpenAdmin Tool (OAT) or onmode -w[mf] for dynamic configuration tuning.
[gbasedbt@devsvr ~]$ 

取消共享内存的常驻部分的强制驻留

[gbasedbt@devsvr ~]$ onmode -n
Your evaluation license will expire on 2022-06-18 00:00:00

This will set the shared memory buffer cache to NON-RESIDENT -
Do you wish to continue (y/n)? y
Note that this command will be phased out in a future release. Please use
the OpenAdmin Tool (OAT) or onmode -w[mf] for dynamic configuration tuning.
[gbasedbt@devsvr ~]$ 

添加或删除虚拟管理器

GBase 8s可以根据业务运行情况,动态增加和减少虚拟处理器的数量,以适应业务变化,让数据库运行更高效。

onmode -p +num <vp_class>
onmode -p -num <vp_class>

查看当前的VP信息,当前的CPU VP共有2个。

[gbasedbt@devsvr ~]$ onstat -g glo
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:52:37 -- 597864 Kbytes

MT global info:
sessions threads  vps      lngspins time    
0        55       13       0        3156    

          sched calls     thread switches yield 0   yield n   yield forever
total:    136622          125911          223       116478    710      
per sec:  43              33              0         30        0        

Virtual processor summary:
 class       vps       usercpu   syscpu    total   
 cpu         2         0.77      2.63      3.40    
 aio         6         0.06      0.19      0.25    
 lio         1         0.00      0.05      0.05    
 pio         1         0.00      0.04      0.04    
 adm         1         0.01      0.32      0.33    
 msc         1         0.00      0.00      0.00    
 fifo        1         0.00      0.04      0.04    
 total       13        0.84      3.27      4.11    

Individual virtual processors:
 vp    pid       class       usercpu   syscpu    total     Thread    Eff  
 1     26606     cpu         0.55      2.28      2.83      3.32      85%
 2     26631     adm         0.01      0.32      0.33      0.00       0%
 3     26632     lio         0.00      0.05      0.05      0.05     100%
 4     26637     pio         0.00      0.04      0.04      0.04     100%
 5     26643     aio         0.00      0.05      0.05      0.05     100%
 6     26644     msc         0.00      0.00      0.00      0.00       0%
 7     26650     fifo        0.00      0.04      0.04      0.04     100%
 8     26656     cpu         0.22      0.35      0.57      0.57     100%
 9     26667     aio         0.01      0.03      0.04      0.04     100%
 10    26672     aio         0.00      0.04      0.04      0.04     100%
 11    26673     aio         0.02      0.02      0.04      0.04     100%
 12    26674     aio         0.01      0.03      0.04      0.04     100%
 13    26675     aio         0.02      0.02      0.04      0.04     100%
                 tot         0.84      3.27      4.11    

动态增加5个CPU VP。

[gbasedbt@devsvr ~]$ onmode -p +5 cpu
Your evaluation license will expire on 2022-06-18 00:00:00

再次查看VP信息,当前的CPU VP有7个。

[gbasedbt@devsvr ~]$ onstat -g glo
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:52:47 -- 597864 Kbytes

MT global info:
sessions threads  vps      lngspins time    
0        55       18       0        3166    

          sched calls     thread switches yield 0   yield n   yield forever
total:    137080          126335          228       116874    710      
per sec:  0               0               0         0         0        

Virtual processor summary:
 class       vps       usercpu   syscpu    total   
 cpu         7         0.78      2.63      3.41    
 aio         6         0.06      0.19      0.25    
 lio         1         0.00      0.05      0.05    
 pio         1         0.00      0.04      0.04    
 adm         1         0.01      0.32      0.33    
 msc         1         0.00      0.00      0.00    
 fifo        1         0.00      0.04      0.04    
 total       18        0.85      3.27      4.12    

Individual virtual processors:
 vp    pid       class       usercpu   syscpu    total     Thread    Eff  
 1     26606     cpu         0.55      2.28      2.83      3.82      74%
 2     26631     adm         0.01      0.32      0.33      0.00       0%
 3     26632     lio         0.00      0.05      0.05      0.05     100%
 4     26637     pio         0.00      0.04      0.04      0.04     100%
 5     26643     aio         0.00      0.05      0.05      0.05     100%
 6     26644     msc         0.00      0.00      0.00      0.00       0%
 7     26650     fifo        0.00      0.04      0.04      0.04     100%
 8     26656     cpu         0.23      0.35      0.58      0.58     100%
 9     26667     aio         0.01      0.03      0.04      0.04     100%
 10    26672     aio         0.00      0.04      0.04      0.04     100%
 11    26673     aio         0.02      0.02      0.04      0.04     100%
 12    26674     aio         0.01      0.03      0.04      0.04     100%
 13    26675     aio         0.02      0.02      0.04      0.04     100%
 14    39853     cpu         0.00      0.00      0.00      0.00       0%
 15    39854     cpu         0.00      0.00      0.00      0.00       0%
 16    39855     cpu         0.00      0.00      0.00      0.00       0%
 17    39856     cpu         0.00      0.00      0.00      0.00       0%
 18    39857     cpu         0.00      0.00      0.00      0.00       0%
                 tot         0.85      3.27      4.12    

动态减少3个CPU VP。

[gbasedbt@devsvr ~]$ onmode -p -3 cpu
Your evaluation license will expire on 2022-06-18 00:00:00

查看VP信息。CPU VP变为4个。

[gbasedbt@devsvr ~]$ onstat -g glo
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 00:53:35 -- 597864 Kbytes

MT global info:
sessions threads  vps      lngspins time    
0        55       15       0        3214    

          sched calls     thread switches yield 0   yield n   yield forever
total:    139105          128195          230       118615    710      
per sec:  0               0               0         0         0        

Virtual processor summary:
 class       vps       usercpu   syscpu    total   
 cpu         4         0.78      2.64      3.42    
 aio         6         0.06      0.19      0.25    
 lio         1         0.00      0.05      0.05    
 pio         1         0.00      0.04      0.04    
 adm         1         0.01      0.33      0.34    
 msc         1         0.00      0.00      0.00    
 fifo        1         0.00      0.04      0.04    
 total       15        0.85      3.29      4.14    

Individual virtual processors:
 vp    pid       class       usercpu   syscpu    total     Thread    Eff  
 1     26606     cpu         0.55      2.29      2.84      3.84      74%
 2     26631     adm         0.01      0.33      0.34      0.00       0%
 3     26632     lio         0.00      0.05      0.05      0.05     100%
 4     26637     pio         0.00      0.04      0.04      0.04     100%
 5     26643     aio         0.00      0.05      0.05      0.05     100%
 6     26644     msc         0.00      0.00      0.00      0.00       0%
 7     26650     fifo        0.00      0.04      0.04      0.04     100%
 8     26656     cpu         0.23      0.35      0.58      0.58     100%
 9     26667     aio         0.01      0.03      0.04      0.04     100%
 10    26672     aio         0.00      0.04      0.04      0.04     100%
 11    26673     aio         0.02      0.02      0.04      0.04     100%
 12    26674     aio         0.01      0.03      0.04      0.04     100%
 13    26675     aio         0.02      0.02      0.04      0.04     100%
 14    39853     cpu         0.00      0.00      0.00      0.00       0%
 15    39854     cpu         0.00      0.00      0.00      0.00       0%
                 tot         0.85      3.29      4.14    

[gbasedbt@devsvr ~]$ 

动态地启动、停止或重启监听线程

onmode -P <start|stop|restart> <instance_name>

停止服务监听。

[gbasedbt@devsvr ~]$ onmode -P stop gbaseserver
Your evaluation license will expire on 2022-06-18 00:00:00

使用dbaccess连接数据库。由于监听已经停止,dbaccess会在选择数据库执行一段时间后报错。

[gbasedbt@devsvr ~]$ dbaccess - -
Your evaluation license will expire on 2022-06-18 00:00:00
> database mydb;

  908: Attempt to connect to database server (gbaseserver) failed.
Error in line 1
Near character position 1
> 

启动监听。再次使用dbaccess连接数据库会立即成功。

[gbasedbt@devsvr ~]$ onmode -P start gbaseserver
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ dbaccess - -
Your evaluation license will expire on 2022-06-18 00:00:00
> database mydb;

Database selected.

> 

更新 onconfig 文件中指定配置参数的值

onmode -wm <key=value>
onmode -wf <key=value>

说明:只有部分参数支持动态更改。

只更新内存中的参数值,但不更新配置文件中的参数值。

[gbasedbt@devsvr gbaseserver_dbs]$ onmode -wm LISTEN_TIMEOUT=50
Your evaluation license will expire on 2022-06-18 00:00:00
Value of LISTEN_TIMEOUT has been changed to 50 seconds.
[gbasedbt@devsvr gbaseserver_dbs]$ onstat -g cfg LISTEN_TIMEOUT
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 01:33:54 -- 597864 Kbytes

name                      current value
LISTEN_TIMEOUT            50

[gbasedbt@devsvr gbaseserver_dbs]$ onstat -c | grep LISTEN_TIMEOUT
Your evaluation license will expire on 2022-06-18 00:00:00
# LISTEN_TIMEOUT             - The number of seconds that GBase
LISTEN_TIMEOUT 60
[gbasedbt@devsvr gbaseserver_dbs]$ 

更新内存和配置文件中的参数值。

[gbasedbt@devsvr gbaseserver_dbs]$ onstat -c | grep TAPEDEV
Your evaluation license will expire on 2022-06-18 00:00:00
# TAPEDEV      - The tape device path for backups. To use standard
TAPEDEV         /dev/null       
# LTAPEDEV     - The tape device path for logical logs
LTAPEDEV        /dev/null       
[gbasedbt@devsvr gbaseserver_dbs]$ onmode -wf TAPEDEV=/home/gbasedbt/backup
Your evaluation license will expire on 2022-06-18 00:00:00
Value of TAPEDEV has been changed to /home/gbasedbt/backup.
[gbasedbt@devsvr gbaseserver_dbs]$ onstat -c | grep TAPEDEV
Your evaluation license will expire on 2022-06-18 00:00:00
# TAPEDEV      - The tape device path for backups. To use standard
TAPEDEV         /home/gbasedbt/backup 
# LTAPEDEV     - The tape device path for logical logs
LTAPEDEV        /dev/null       
[gbasedbt@devsvr gbaseserver_dbs]$ 

终止数据库服务器会话

onmode -z <session_id>
[gbasedbt@devsvr ~]$ onstat -g ses
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 1 days 02:46:43 -- 597864 Kbytes

session                                      #RSAM    total      used       dynamic 
id       user     tty      pid      hostname threads  memory     memory     explain 
29       gbasedbt -        0        -        0        16384      13712      off 
26       gbasedbt 11       27021    devsvr   1        237568     150144     off 
24       gbasedbt -        0        -        0        20480      15328      off 
2        gbasedbt -        0        -        0        16384      13712      off 

[gbasedbt@devsvr ~]$ onmode -z 26
Your evaluation license will expire on 2022-06-18 00:00:00
[gbasedbt@devsvr ~]$ onstat -g ses
Your evaluation license will expire on 2022-06-18 00:00:00
On-Line -- Up 1 days 02:47:17 -- 597864 Kbytes

session                                      #RSAM    total      used       dynamic 
id       user     tty      pid      hostname threads  memory     memory     explain 
29       gbasedbt -        0        -        0        16384      13712      off 
24       gbasedbt -        0        -        0        20480      15328      off 
2        gbasedbt -        0        -        0        16384      13712      off 

[gbasedbt@devsvr ~]$ 

在dbaccess中执行SQL时,由于Session被杀死,执行报错。

> info tables;


Table name



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

评论