巨杉SequoiaDB 5.0.1日常运维使用命令汇总

本文介绍巨杉SequoiaDB 5.0.1,日常运维和使用的命令,包括启动,停止,查看版本,服务状态等。包括操作系统命令和数据库 shell 命令两大类。

集群shell可以启停所有同组节点的服务,而操作系统命令的只能启停当前节点的。如果节点较多,还是用集群的shell更简单。

测试发现,通过sheel必须协调和编目服务都正常时才可以。否则报-104 Node is not primary的错误。

如果你通过sdb将协调节点组停止后,需通过操作系统命令启动后才能进行数据库 shell 命令操作。

操作系统命令查看巨杉SequoiaDB的版本

先切换用户到数据库用户, 比如sdbadmin

[root@gbase_rh7_001 ~]# su - sdbadmin
Last login: Wed Jan 13 04:00:04 CST 2021 on pts/2
[sdbadmin@gbase_rh7_001 ~]$ sequoiadb --version
SequoiaDB version: 5.0.1
Release: 39282
Git version: 49d120b9724b64c8420df002093c6c8414402449
2020-10-16-15.09.14

操作系统命令查看存储引擎节点列表

无服务运行时,显示空。

[sdbadmin@gbase_rh7_001 ~]$ sdblist
Total: 0
[sdbadmin@gbase_rh7_001 ~]$ 

有服务运行时,结果如下。

[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (3574) C
sequoiadb(11820) (3577) D
sequoiadb(11810) (3580) S
Total: 3
[sdbadmin@gbase_rh7_001 ~]$

其中 S表示协调服务(?),D表示数据服务(Data),C表示编目服务(Catalog/Schema)

长格式,显示更详细的信息:包括PID服务启动时间,路径,分组名字等。

[sdbadmin@gbase_rh7_001 ~]$ sdblist -l
Name       SvcName       Role        PID       GID    NID    PRY  GroupName            StartTime            DBPath
sequoiadb  11810         coord       9099      2      4      Y    SYSCoord             2021-01-29-14.20.20  /opt/sequoiadb/database/coord/11810/
sequoiadb  11800         catalog     9289      1      1      N    SYSCatalogGroup      2021-01-29-14.25.50  /opt/sequoiadb/database/cata/11800/
sequoiadb  11820         data        9594      1000   1000   N    datagroup            2021-01-29-14.37.36  /opt/sequoiadb/database/data/11820/
Total: 3
[sdbadmin@gbase_rh7_001 ~]$

操作系统命令查看 MySQL 实例状态

[sdbadmin@gbase_rh7_001 ~]$ sdb_sql_ctl status
INSTANCE   PID        SVCNAME    SQLDATA                                  SQLLOG
myinst     -          -          /opt/sequoiasql/mysqldatabase/3306/      /opt/sequoiasql/mysql/myinst.log
Total: 1; Run: 0
[sdbadmin@gbase_rh7_001 ~]$

操作系统命令服务启动sdbstart

sdbstart参数列表

如下是sdbstart的命令行参数列表

[sdbadmin@gbase_rh7_001 ~]$ sdbstart --help
Command options:
  -h [ --help ]          help
  --version              version
  -c [ --confpath ] arg  configure file path,
                         eg: '/opt/sequoiadb/conf/local/20000/'
  -p [ --svcname ] arg   service name, separated by comma (',')
  -t [ --type ] arg      node type: db/om/all, default: db
  -r [ --role ] arg      role type: coord/data/catalog/om
  --force                force start when the config not exist
  -o [ --options ] arg   SequoiaDB start arguments, but not use
                         '-c/--confpath/-p/--svcname'
  -i [ --ignoreulimit ]  skip checking ulimit

[sdbadmin@gbase_rh7_001 ~]$

sdbstart启动所有服务

通过 sdbstart 命令(不带参数)启动当前服务器数据节点、编目节点和协调节点

[sdbadmin@gbase_rh7_001 ~]$ sdbstart
Success: sequoiadb(11800) is successfully started (3574)
Success: sequoiadb(11820) is successfully started (3577)
Success: sequoiadb(11810) is successfully started (3580)
Total: 3; Succeed: 3; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (3574) C
sequoiadb(11820) (3577) D
sequoiadb(11810) (3580) S
Total: 3
[sdbadmin@gbase_rh7_001 ~]$
  • sdbstart 命令默认启动数据节点、编目节点和协调节点
  • sdbstart 命令对已启动的服务节点不做任何操作

sdbstart启动指定服务名

如下通过sdbstart -p 参数,启动服务名为11800的。

[sdbadmin@gbase_rh7_001 ~]$ sdbstart -p 11800
Success: sequoiadb(11800) is successfully started (3886)
Total: 1; Succeed: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (3886) C
Total: 1
[sdbadmin@gbase_rh7_001 ~]$

一次启动多个,用逗号分割服务名

[sdbadmin@gbase_rh7_001 ~]$ sdbstart -p 11810,11820
Success: sequoiadb(11810) is successfully started (3962)
Success: sequoiadb(11820) is successfully started (3965)
Total: 2; Succeed: 2; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (3886) C
sequoiadb(11810) (3962) S
sequoiadb(11820) (3965) D
Total: 3
[sdbadmin@gbase_rh7_001 ~]$

sdbstart启动指定类型的服务

sdbstart -t 参数指定启动服务类型。db 为数据节点、编目节点和协调节点,om 为 SequoiaDB 数据库管理服务,all 为当前服务器部署的所有服务。

sdbstart启动指定角色的服务

sdbstart -r 参数指定启动服务角色。coord 为协调节点,data 为数据节点,catalog 为编目节点,om 为 Sequoiadb 数据库管理服务。

如下是启动编目角色的例子。

[sdbadmin@gbase_rh7_001 ~]$ sdbstart -r catalog
Success: sequoiadb(11800) is successfully started (4232)
Total: 1; Succeed: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (4232) C
Total: 1
[sdbadmin@gbase_rh7_001 ~]$

启动协调服务和数据服务的例子

[sdbadmin@gbase_rh7_001 ~]$ sdbstart -r coord
Success: sequoiadb(11810) is successfully started (4286)
Total: 1; Succeed: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (4232) C
sequoiadb(11810) (4286) S
Total: 2
[sdbadmin@gbase_rh7_001 ~]$ sdbstart -r data
Success: sequoiadb(11820) is successfully started (4311)
Total: 1; Succeed: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (4232) C
sequoiadb(11810) (4286) S
sequoiadb(11820) (4311) D
Total: 3
[sdbadmin@gbase_rh7_001 ~]$

操作系统命令服务停止sdbstop

参数

[sdbadmin@gbase_rh7_001 ~]$ sdbstop
Sdbstop requires at least one parameter. You maybe want to stop all nodes.
For detail, please refer to "sdbstop --all"
Invalid argument
Usage:
  sdbstop --all     # stop all nodes include db and om
  sdbstop -t db     # stop db nodes
  sdbstop -r data   # stop data nodes
  sdbstop -p 11810  # stop 11810 node
Command options:
  -h [ --help ]         help
  --version             version
  -a [ --all ]          stop all nodes include db and om
  -t [ --type ] arg     node type: db/om/all
  -r [ --role ] arg     role type: coord/data/catalog/om
  -p [ --svcname ] arg  service name, separated by comma (',')
  --force               force stop when the node can't stop normally

[sdbadmin@gbase_rh7_001 ~]$

停所有服务

[sdbadmin@gbase_rh7_001 ~]$ sdbstop -a
Terminating process 3574: sequoiadb(11800)
DONE
Terminating process 3577: sequoiadb(11820)
DONE
Terminating process 3580: sequoiadb(11810)
DONE
Total: 3; Success: 3; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$
[sdbadmin@gbase_rh7_001 ~]$ sdblist
Total: 0
[sdbadmin@gbase_rh7_001 ~]$

sdbstop停止指定服务名

sdbstop -p 参数指定停止服务名称,多个服务名称用‘,’隔开。

[sdbadmin@gbase_rh7_001 ~]$ sdbstop -p 11800
Terminating process 4232: sequoiadb(11800)
DONE
Total: 1; Success: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11810) (4286) S
sequoiadb(11820) (4311) D
Total: 2
[sdbadmin@gbase_rh7_001 ~]$

sdbstop停止指定服务类型

sdbstop -t 参数指定停止服务类型。db 为数据节点、编目节点和协调节点,om 为 SequoiaDB 数据库管理服务,all 为当前服务器部署的所有服务。

[sdbadmin@gbase_rh7_001 ~]$ sdbstop -r om
Total: 0; Success: 0; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdbstop -r data
Terminating process 4311: sequoiadb(11820)
DONE
Total: 1; Success: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11810) (4286) S
Total: 1
[sdbadmin@gbase_rh7_001 ~]$

sdbstop停止指定角色的服务

sdbstop -r 参数指定停止服务角色。coord 为协调节点,data 为数据节点,catalog 为编目节点,om 为 SequoiaDB 数据库管理服务。

如下是停止一个调度服务coord的例子。

[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11810) (4286) S
sequoiadb(11800) (8052) C
sequoiadb(11820) (8055) D
Total: 3

[sdbadmin@gbase_rh7_001 ~]$ sdbstop -r coord
Terminating process 4286: sequoiadb(11810)
DONE
Total: 1; Success: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11800) (8052) C
sequoiadb(11820) (8055) D
Total: 2
[sdbadmin@gbase_rh7_001 ~]$

集群shell命令查看现有全部分区组信息

通过db.listReplicaGroups获取当前的所有分区组信息

[sdbadmin@gbase_rh7_001 ~]$ sdb
Welcome to SequoiaDB shell!
help() for help, Ctrl+c or quit to exit
> sdb=new Sdb('10.0.2.101')
10.0.2.101:11810
Takes 0.006634s.

> db.listReplicaGroups()
{
  "Group": [
    {
      "dbpath": "/opt/sequoiadb/database/cata/11800",
      "HostName": "gbase_rh7_001",
      "Service": [
        {
          "Type": 0,
          "Name": "11800"
        },
        {
          "Type": 1,
          "Name": "11801"
        },
        {
          "Type": 2,
          "Name": "11802"
        },
        {
          "Type": 3,
          "Name": "11803"
        }
      ],
      "NodeID": 1,
      "Status": 1
    },
    {
      "HostName": "gbase_rh7_015",
      "Status": 1,
      "dbpath": "/opt/sequoiadb/database/cata/11800/",
      "Service": [
        {
          "Type": 0,
          "Name": "11800"
        },
        {
          "Type": 1,
          "Name": "11801"
        },
        {
          "Type": 2,
          "Name": "11802"
        },
        {
          "Type": 3,
          "Name": "11803"
        }
      ],
      "NodeID": 3
    }
  ],
  "GroupID": 1,
  "GroupName": "SYSCatalogGroup",
  "PrimaryNode": 3,
  "Role": 2,
  "SecretID": 1795011043,
  "Status": 1,
  "Version": 2,
  "_id": {
    "$oid": "5ffdd82d1b465bbeccd27b91"
  }
}
{
  "Group": [
    {
      "HostName": "gbase_rh7_001",
      "Status": 1,
      "dbpath": "/opt/sequoiadb/database/data/11820/",
      "Service": [
        {
          "Type": 0,
          "Name": "11820"
        },
        {
          "Type": 1,
          "Name": "11821"
        },
        {
          "Type": 2,
          "Name": "11822"
        }
      ],
      "NodeID": 1000
    },
    {
      "HostName": "gbase_rh7_015",
      "Status": 1,
      "dbpath": "/opt/sequoiadb/database/data/11820/",
      "Service": [
        {
          "Type": 0,
          "Name": "11820"
        },
        {
          "Type": 1,
          "Name": "11821"
        },
        {
          "Type": 2,
          "Name": "11822"
        }
      ],
      "NodeID": 1001
    }
  ],
  "GroupID": 1000,
  "GroupName": "datagroup",
  "PrimaryNode": 1001,
  "Role": 0,
  "SecretID": 800390793,
  "Status": 1,
  "Version": 5,
  "_id": {
    "$oid": "5ffddce11b465bbeccd27b95"
  }
}
{
  "Group": [
    {
      "HostName": "gbase_rh7_001",
      "Status": 1,
      "dbpath": "/opt/sequoiadb/database/coord/11810/",
      "Service": [
        {
          "Type": 0,
          "Name": "11810"
        },
        {
          "Type": 1,
          "Name": "11811"
        },
        {
          "Type": 2,
          "Name": "11812"
        }
      ],
      "NodeID": 4
    },
    {
      "HostName": "gbase_rh7_015",
      "Status": 1,
      "dbpath": "/opt/sequoiadb/database/coord/11810/",
      "Service": [
        {
          "Type": 0,
          "Name": "11810"
        },
        {
          "Type": 1,
          "Name": "11811"
        },
        {
          "Type": 2,
          "Name": "11812"
        }
      ],
      "NodeID": 5
    }
  ],
  "GroupID": 2,
  "GroupName": "SYSCoord",
  "Role": 1,
  "SecretID": 1271626230,
  "Status": 1,
  "Version": 3,
  "_id": {
    "$oid": "5ffddda81b465bbeccd27b96"
  }
}
Return 3 row(s).
Takes 0.003510s.
>

集群shell命令查看特定分区组详细信息

通过db.getRG()获取分区组,再通过rg.getDetail()获得单个分区组信息。

> rg=db.getRG('datagroup')
datagroup
Takes 0.001872s.
> rg.getDetail()
{
  "Group": [
    {
      "HostName": "gbase_rh7_001",
      "Status": 1,
      "dbpath": "/opt/sequoiadb/database/data/11820/",
      "Service": [
        {
          "Type": 0,
          "Name": "11820"
        },
        {
          "Type": 1,
          "Name": "11821"
        },
        {
          "Type": 2,
          "Name": "11822"
        }
      ],
      "NodeID": 1000
    },
    {
      "HostName": "gbase_rh7_015",
      "Status": 1,
      "dbpath": "/opt/sequoiadb/database/data/11820/",
      "Service": [
        {
          "Type": 0,
          "Name": "11820"
        },
        {
          "Type": 1,
          "Name": "11821"
        },
        {
          "Type": 2,
          "Name": "11822"
        }
      ],
      "NodeID": 1001
    }
  ],
  "GroupID": 1000,
  "GroupName": "datagroup",
  "PrimaryNode": 1001,
  "Role": 0,
  "SecretID": 800390793,
  "Status": 1,
  "Version": 5,
  "_id": {
    "$oid": "5ffddce11b465bbeccd27b95"
  }
}
Return 1 row(s).
Takes 0.001937s.
>

集群shell命令获得指定分组的Master主节点和Slave从节点信息

通过rg.getMaster()获得主节点的信息,包括主机名和服务名。getSlave是随机选择一个返回。

> rg.getMaster()
gbase_rh7_015:11820
Takes 0.001162s.
> rg.getSlave();
gbase_rh7_001:11820
Takes 0.001193s.
>

集群shell命令启动停止服务sdb

“datagroup”为数据组名称,协调节点组名称为“SYSCoord”,编目节点组名称为“SYSCatalogGroup”。

[sdbadmin@gbase_rh7_001 ~]$ sdbstart -r coord
Success: sequoiadb(11810) is successfully started (8765)
Total: 1; Succeed: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdb
Welcome to SequoiaDB shell!
help() for help, Ctrl+c or quit to exit
> db=new Sdb();
(shell):1 uncaught exception: -104
Node is not primary
Takes 0.016550s.
> db=new Sdb("localhost");
(shell):1 uncaught exception: -104
Node is not primary
Takes 0.013940s.
> exit

[sdbadmin@gbase_rh7_001 ~]$ sdbstart -r catalog
Success: sequoiadb(11800) is successfully started (8845)
Total: 1; Succeed: 1; Failed: 0
[sdbadmin@gbase_rh7_001 ~]$ sdb
Welcome to SequoiaDB shell!
help() for help, Ctrl+c or quit to exit
> db=new Sdb();
localhost:11810
Takes 8.285570s.

集群shell命令启动停止编目服务

多个节点需要在 new Sdb时指定IP或主机名。编目节点组名称为“SYSCatalogGroup”。

[sdbadmin@gbase_rh7_001 ~]$ sdb
Welcome to SequoiaDB shell!
help() for help, Ctrl+c or quit to exit
> db=new Sdb("10.0.2.101");
10.0.2.101:11810
Takes 0.005242s.
> rg=db.getRG('SYSCatalogGroup');
SYSCatalogGroup
Takes 0.001233s.
> rg.stop()
Takes 12.068688s.
> rg.start()
Takes 2.130963s.
>

集群shell命令启动停止数据服务

[sdbadmin@gbase_rh7_001 ~]$ sdb
Welcome to SequoiaDB shell!
help() for help, Ctrl+c or quit to exit
> sdb=new Sdb('10.0.2.101')
10.0.2.101:11810
Takes 0.006634s.
> db=new Sdb('10.0.2.101')
10.0.2.101:11810
Takes 0.010566s.
> rg=db.getRG('datagroup');
datagroup
Takes 0.003675s.
> dg=db.getRG('datagroup');
datagroup
Takes 0.001558s.
>
> dg.stop()
Takes 7.063539s.
> dg.start()
Takes 3.079369s.

在db.stop时,查看datagroup的2个节点,其数据服务都停了。

[sdbadmin@gbase_rh7_001 ~]$ sdblist
sequoiadb(11810) (9099) S
sequoiadb(11800) (9289) C
Total: 2
[sdbadmin@gbase_rh7_001 ~]$

。。。。
-bash-4.2$ sdblist
sequoiadb(11810) (6637) S
sequoiadb(11800) (7579) C
Total: 2
-bash-4.2$ 

db.start后,2个节点的服务也都启动了。

参考

http://doc.sequoiadb.com/cn/sequoiadb-cat_id-1561381787-edition_id-500

https://blog.csdn.net/littersister/article/details/38298663