当前位置: 首页 > 工具软件 > Gadmin > 使用案例 >

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

彭建业
2023-12-01

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

gadmin

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

切换数据库到在线模式

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

语法:

gadmin -m

操作演示

[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
Single-User -- Up 00:02:05 -- 333720 Kbytes

[gbasedbt@devsvr ~]$ gadmin -m
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:02:15 -- 333720 Kbytes

[gbasedbt@devsvr ~]$

切换数据库到离线模式

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

语法

gadmin -k

操作演示

[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:03:50 -- 333720 Kbytes

[gbasedbt@devsvr ~]$ gadmin -k
Your evaluation license will expire on 2022-10-14 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 ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
shared memory not initialized for GBASEDBTSERVER 'gbase8s'
[gbasedbt@devsvr ~]$

切换数据库到静态模式

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

语法

gadmin -s
gadmin -u

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

操作演示

[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:00:17 -- 333720 Kbytes

[gbasedbt@devsvr ~]$ gadmin -s
Your evaluation license will expire on 2022-10-14 00:00:00

This will perform a GRACEFUL SHUTDOWN -
Do you wish to continue (y/n)? y
[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
Quiescent -- Up 00:00:44 -- 333720 Kbytes

[gbasedbt@devsvr ~]$

[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:01:25 -- 333720 Kbytes

[gbasedbt@devsvr ~]$ gadmin -u
Your evaluation license will expire on 2022-10-14 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 ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
Quiescent -- Up 00:01:48 -- 333720 Kbytes

[gbasedbt@devsvr ~]$

切换数据库到单用户模式

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

语法

gadmin -j

操作演示

[gbasedbt@devsvr ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:03:50 -- 333720 Kbytes

[gbasedbt@devsvr ~]$ gadmin -j
Your evaluation license will expire on 2022-10-14 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 ~]$ gstat -
Your evaluation license will expire on 2022-10-14 00:00:00
Single-User -- Up 00:04:02 -- 333720 Kbytes

[gbasedbt@devsvr ~]$

切换逻辑日志文件

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

语法

gadmin -l

当前的逻辑日志被标记为C,将逻辑日志切换到下一个后,当前的逻辑日志(uniqid)由8变为9。

操作演示

[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-10-14 00:00:00
Single-User -- Up 00:04:48 -- 333720 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-1  22       1024     16         1          16.00
      phybegin         physize    phypos     phyused    %used
      3:102400         102400     2103       22         0.02

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-3  0        512      215        44         20         4.9        2.2
	Subsystem    numrecs    Log Space used
	OLDRSAM      214        62832
	HA           1          44

address          number   flags    uniqid   begin                size     used    %used
45793f88         4        U-B----  7        2:53                25600       14     0.05
45572f30         5        U---C-L  8        2:25653             25600    18003    70.32
45572f98         6        A------  0        2:51253             25600        0     0.00
45641f30         7        A------  0        2:76853             25600        0     0.00
......
45778188         12       A------  0        2:204853            25600        0     0.00
 9 active, 9 total

[gbasedbt@devsvr ~]$ gadmin -l
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$ gstat -l
Your evaluation license will expire on 2022-10-14 00:00:00
Single-User -- Up 00:05:04 -- 333720 Kbytes

Physical Logging
Buffer bufused  bufsize  numpages   numwrits   pages/io
  P-1  28       1024     16         1          16.00
      phybegin         physize    phypos     phyused    %used
      3:102400         102400     2103       28         0.03

Logical Logging
Buffer bufused  bufsize  numrecs    numpages   numwrits   recs/pages pages/io
  L-3  0        512      361        70         44         5.2        1.6
	Subsystem    numrecs    Log Space used
	OLDRSAM      360        82820
	HA           1          44

address          number   flags    uniqid   begin                size     used    %used
45793f88         4        U-B----  7        2:53                25600       14     0.05
45572f30         5        U-----L  8        2:25653             25600    18004    70.33
45572f98         6        U---C--  9        2:51253             25600        5     0.02
45641f30         7        A------  0        2:76853             25600        0     0.00
......
45778188         12       A------  0        2:204853            25600        0     0.00
 9 active, 9 total

[gbasedbt@devsvr ~]$

强制执行检查点

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

语法

gadmin -c
gadmin -c unblock
gadmin -c block <seconds>

操作演示

[gbasedbt@devsvr ~]$ gadmin -c
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$

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

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

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

语法

gadmin -r

操作演示

[gbasedbt@devsvr ~]$ gadmin -r
Your evaluation license will expire on 2022-10-14 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 ~]$

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

语法

gadmin -n

操作演示

[gbasedbt@devsvr ~]$ gadmin -n
Your evaluation license will expire on 2022-10-14 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可以根据业务运行情况,动态增加和减少虚拟处理器的数量,以适应业务变化,让数据库运行更高效。

语法

gadmin -p +num <vp_class>
gadmin -p -num <vp_class>

操作演示

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

[gbasedbt@devsvr ~]$ gstat -g glo
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:30:07 -- 333720 Kbytes

MT global info:
sessions threads  vps      lngspins time
0        42       22       1        1807

          sched calls     thread switches yield 0   yield n   yield forever
total:    42792           31199           11950     25100     1921
per sec:  12              0               12        0         0

Virtual processor summary:
 class       vps       usercpu   syscpu    total
 cpu         1         0.71      0.34      1.05
 aio         15        0.06      0.28      0.34
 lio         1         0.00      0.04      0.04
 pio         1         0.00      0.03      0.03
 adm         1         0.00      0.14      0.14
 soc         1         0.00      0.22      0.22
 msc         1         0.00      0.00      0.00
 fifo        1         0.01      0.01      0.02
 total       22        0.78      1.06      1.84

Individual virtual processors:
 vp    pid       class       usercpu   syscpu    total     Thread    Eff
 1     4251      cpu         0.71      0.34      1.05      2.64      39%
 2     4252      adm         0.00      0.14      0.14      0.00       0%
 3     4253      lio         0.00      0.04      0.04      0.04     100%
 4     4254      pio         0.00      0.03      0.03      0.03     100%
 5     4255      aio         0.00      0.06      0.06      0.10      62%
 6     4256      msc         0.00      0.00      0.00      0.00       0%
 7     4257      fifo        0.01      0.01      0.02      0.02     100%
 8     4258      soc         0.00      0.22      0.22      NA         NA
 9     4259      aio         0.00      0.02      0.02      0.02     100%
 10    4260      aio         0.00      0.02      0.02      0.02     100%
 11    4261      aio         0.00      0.02      0.02      0.02      96%
 12    4262      aio         0.00      0.02      0.02      0.02     100%
 13    4263      aio         0.00      0.02      0.02      0.02     100%
 14    4264      aio         0.00      0.02      0.02      0.02     100%
 15    4265      aio         0.00      0.02      0.02      0.02     100%
 16    4266      aio         0.01      0.01      0.02      0.02     100%
 17    4267      aio         0.01      0.01      0.02      0.02     100%
 18    4268      aio         0.01      0.01      0.02      0.02     100%
 19    4269      aio         0.00      0.02      0.02      0.02     100%
 20    4270      aio         0.01      0.01      0.02      0.02     100%
 21    4271      aio         0.02      0.00      0.02      0.02     100%
 22    4272      aio         0.00      0.02      0.02      0.02     100%
                 tot         0.78      1.06      1.84

[gbasedbt@devsvr ~]$

动态增加5个CPU VP。

[gbasedbt@devsvr ~]$ gadmin -p +5 cpu
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$

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

[gbasedbt@devsvr ~]$ gstat -g glo
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:31:51 -- 333720 Kbytes

MT global info:
sessions threads  vps      lngspins time
0        42       27       1        1911

          sched calls     thread switches yield 0   yield n   yield forever
total:    44809           32805           12360     26558     1921
per sec:  0               0               0         0         0

Virtual processor summary:
 class       vps       usercpu   syscpu    total
 cpu         6         0.72      0.34      1.06
 aio         15        0.08      0.28      0.36
 lio         1         0.00      0.04      0.04
 pio         1         0.00      0.03      0.03
 adm         1         0.00      0.15      0.15
 soc         1         0.00      0.23      0.23
 msc         1         0.00      0.00      0.00
 fifo        1         0.01      0.01      0.02
 total       27        0.81      1.08      1.89

Individual virtual processors:
 vp    pid       class       usercpu   syscpu    total     Thread    Eff
 1     4251      cpu         0.72      0.34      1.06      3.15      33%
 2     4252      adm         0.00      0.15      0.15      0.00       0%
 3     4253      lio         0.00      0.04      0.04      0.04     100%
 4     4254      pio         0.00      0.03      0.03      0.03     100%
 5     4255      aio         0.00      0.06      0.06      0.10      62%
 6     4256      msc         0.00      0.00      0.00      0.00       0%
 7     4257      fifo        0.01      0.01      0.02      0.02     100%
 8     4258      soc         0.00      0.23      0.23      NA         NA
 9     4259      aio         0.00      0.02      0.02      0.02     100%
 10    4260      aio         0.00      0.02      0.02      0.02     100%
 11    4261      aio         0.00      0.02      0.02      0.02      96%
 12    4262      aio         0.00      0.02      0.02      0.02     100%
 13    4263      aio         0.00      0.02      0.02      0.02     100%
 14    4264      aio         0.00      0.02      0.02      0.02     100%
 15    4265      aio         0.02      0.02      0.04      0.04     100%
 16    4266      aio         0.01      0.01      0.02      0.02     100%
 17    4267      aio         0.01      0.01      0.02      0.02     100%
 18    4268      aio         0.01      0.01      0.02      0.02     100%
 19    4269      aio         0.00      0.02      0.02      0.02     100%
 20    4270      aio         0.01      0.01      0.02      0.02     100%
 21    4271      aio         0.02      0.00      0.02      0.02     100%
 22    4272      aio         0.00      0.02      0.02      0.02     100%
 23    4449      cpu         0.00      0.00      0.00      0.01       0%
 24    4450      cpu         0.00      0.00      0.00      0.01       0%
 25    4451      cpu         0.00      0.00      0.00      0.00       0%
 26    4452      cpu         0.00      0.00      0.00      0.00       0%
 27    4453      cpu         0.00      0.00      0.00      0.00       0%
                 tot         0.81      1.08      1.89

[gbasedbt@devsvr ~]$

动态减少3个CPU VP。

[gbasedbt@devsvr ~]$ gadmin -p -3 cpu
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$

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

[gbasedbt@devsvr ~]$ gstat -g glo
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:32:58 -- 333720 Kbytes

MT global info:
sessions threads  vps      lngspins time
0        42       24       1        1978

          sched calls     thread switches yield 0   yield n   yield forever
total:    46219           33899           12676     27525     1921
per sec:  26              14              12        13        0

Virtual processor summary:
 class       vps       usercpu   syscpu    total
 cpu         3         0.73      0.34      1.07
 aio         15        0.08      0.28      0.36
 lio         1         0.00      0.04      0.04
 pio         1         0.00      0.03      0.03
 adm         1         0.00      0.15      0.15
 soc         1         0.00      0.24      0.24
 msc         1         0.00      0.00      0.00
 fifo        1         0.02      0.01      0.03
 total       24        0.83      1.09      1.92

Individual virtual processors:
 vp    pid       class       usercpu   syscpu    total     Thread    Eff
 1     4251      cpu         0.72      0.34      1.06      3.17      33%
 2     4252      adm         0.00      0.15      0.15      0.00       0%
 3     4253      lio         0.00      0.04      0.04      0.04     100%
 4     4254      pio         0.00      0.03      0.03      0.03     100%
 5     4255      aio         0.00      0.06      0.06      0.10      62%
 6     4256      msc         0.00      0.00      0.00      0.00       0%
 7     4257      fifo        0.02      0.01      0.03      0.03     100%
 8     4258      soc         0.00      0.24      0.24      NA         NA
 9     4259      aio         0.00      0.02      0.02      0.02     100%
 10    4260      aio         0.00      0.02      0.02      0.02     100%
 11    4261      aio         0.00      0.02      0.02      0.02      96%
 12    4262      aio         0.00      0.02      0.02      0.02     100%
 13    4263      aio         0.00      0.02      0.02      0.02     100%
 14    4264      aio         0.00      0.02      0.02      0.02     100%
 15    4265      aio         0.02      0.02      0.04      0.04     100%
 16    4266      aio         0.01      0.01      0.02      0.02     100%
 17    4267      aio         0.01      0.01      0.02      0.02     100%
 18    4268      aio         0.01      0.01      0.02      0.02     100%
 19    4269      aio         0.00      0.02      0.02      0.02     100%
 20    4270      aio         0.01      0.01      0.02      0.02     100%
 21    4271      aio         0.02      0.00      0.02      0.02     100%
 22    4272      aio         0.00      0.02      0.02      0.02     100%
 23    4449      cpu         0.01      0.00      0.01      0.01      71%
 24    4450      cpu         0.00      0.00      0.00      0.01       0%
                 tot         0.83      1.09      1.92

[gbasedbt@devsvr ~]$

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

语法

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

操作演示

停止服务监听。

[gbasedbt@devsvr ~]$ gadmin -P stop gbase8s
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$

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

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

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

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

[gbasedbt@devsvr ~]$ gadmin -P start gbase8s
Your evaluation license will expire on 2022-10-14 00:00:00
[gbasedbt@devsvr ~]$ dbaccess - -
Your evaluation license will expire on 2022-10-14 00:00:00
> database mydb;

Database selected.

>

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

语法

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

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

操作演示

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

[gbasedbt@devsvr ~]$ gstat -c | grep LISTEN_TIMEOUT
Your evaluation license will expire on 2022-10-14 00:00:00
# LISTEN_TIMEOUT             - The number of seconds that GBase
LISTEN_TIMEOUT 60
[gbasedbt@devsvr ~]$ gstat -g cfg | grep LISTEN_TIMEOUT
Your evaluation license will expire on 2022-10-14 00:00:00
LISTEN_TIMEOUT            60
[gbasedbt@devsvr ~]$ gadmin -wm LISTEN_TIMEOUT=50
Your evaluation license will expire on 2022-10-14 00:00:00
Value of LISTEN_TIMEOUT has been changed to 50 seconds.
[gbasedbt@devsvr ~]$ gstat -c | grep LISTEN_TIMEOUT
Your evaluation license will expire on 2022-10-14 00:00:00
# LISTEN_TIMEOUT             - The number of seconds that GBase
LISTEN_TIMEOUT 60
[gbasedbt@devsvr ~]$ gstat -g cfg | grep LISTEN_TIMEOUT
Your evaluation license will expire on 2022-10-14 00:00:00
LISTEN_TIMEOUT            50
[gbasedbt@devsvr ~]$

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

[gbasedbt@devsvr ~]$ gstat -c | grep TAPEDEV
Your evaluation license will expire on 2022-10-14 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 ~]$ gstat -g cfg | grep TAPEDEV
Your evaluation license will expire on 2022-10-14 00:00:00
TAPEDEV                   /dev/null
LTAPEDEV                  /dev/null
[gbasedbt@devsvr ~]$ gadmin -wf TAPEDEV=/home/gbasedbt/backup
Your evaluation license will expire on 2022-10-14 00:00:00
Value of TAPEDEV has been changed to /home/gbasedbt/backup.
[gbasedbt@devsvr ~]$ gstat -c | grep TAPEDEV
Your evaluation license will expire on 2022-10-14 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 ~]$ gstat -g cfg | grep TAPEDEV
Your evaluation license will expire on 2022-10-14 00:00:00
TAPEDEV                   /home/gbasedbt/backup
LTAPEDEV                  /dev/null
[gbasedbt@devsvr ~]$

终止数据库服务器会话

语法

gadmin -z <session_id>

操作演示

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

Database selected.

> !gstat -g ses
Your evaluation license will expire on 2022-10-14 00:00:00
On-Line -- Up 00:00:58 -- 333720 Kbytes

session                                      #RSAM    total      used       dynamic
id       user     tty      pid      hostname threads  memory     memory     explain
28       gbasedbt -        0        -        0        16384      13712      off
27       gbasedbt -        0        -        1        401408     373408     off
26       gbasedbt -        0        -        1        176128     162680     off
25       gbasedbt -        0        -        1        659456     481144     off
24       gbasedbt -        0        -        1        102400     85464      off
4        gbasedbt 7        4560     devsvr   1        106496     83592      off
3        gbasedbt -        0        -        0        20480      15328      off
2        gbasedbt -        0        -        0        16384      13712      off

> select * from t_dept;


   f_deptid f_deptname

          1 dept_1
          2 dept_2
          3 dept_3

3 row(s) retrieved.

> !gadmin -z 4
Your evaluation license will expire on 2022-10-14 00:00:00
> select * from t_dept;

25582: Network connection is broken.
Error in line 1
Near character position 1
>

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

> info tables;


Table name



25582: Network connection is broken.
Error in line 1
Near character position 97
> 
 类似资料: