Young87

SmartCat's Blog

So happy to code my life!

游戏开发交流QQ群号60398951

当前位置:首页 >跨站数据

【SequoiaDB】5 巨杉数据库SequoiaDB基本操作

Sequoia DB巨杉数据库作为分布式数据库,由数据库存储引擎与数据库实例两大模块组成。前面介绍了Sequoia DB巨杉数据库集群的部署以及MySQL实例的安装,下面将继续就以下主题进行介绍。

1 安装目录详解

1.1 SequoiaDB安装目录

SequoiaDB巨杉数据库的默认安装目录为/opt/sequoiadb/,安装完成后可以看到目录如下:

[sdbadmin@sdbserver1 ~]$ ll -tr /opt/sequoiadb/

total 5768

-rw-r--r-- 1 sdbadmin sdbadmin_group 583 Nov 15 00:02 version.conf

-rw-r--r-- 1 sdbadmin sdbadmin_group 7528 Nov 15 00:02 sequoiadb

-rwxr-xr-x 1 sdbadmin sdbadmin_group 255 Nov 15 00:02 preUninstall.sh

-rw-r--r-- 1 sdbadmin sdbadmin_group 549 Nov 15 00:02 om_ver.conf

-rwxr-xr-x 1 sdbadmin sdbadmin_group 5156 Nov 15 00:02 install_om.sh

-rwxr-xr-x 1 sdbadmin sdbadmin_group 7078 Nov 15 00:02 compatible.sh

drwxr-xr-x 10 sdbadmin sdbadmin_group 4096 Mar 28 10:06 samples

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:06 license

drwxr-xr-x 11 sdbadmin sdbadmin_group 4096 Mar 28 10:06 www

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:06 hadoop

drwxr-xr-x 7 sdbadmin sdbadmin_group 4096 Mar 28 10:06 web

drwxr-xr-x 8 sdbadmin sdbadmin_group 4096 Mar 28 10:06 tools

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:06 java

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:06 doc

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:06 spark

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:06 postgresql

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:06 python

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:06 CSharp

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:06 bin

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:06 include

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:06 lib

drwxr-xr-x 6 sdbadmin sdbadmin_group 4096 Mar 28 10:07 conf

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:07 plugins

-rw-r--r-- 1 root root 59923 Mar 28 10:07 uninstall.dat

-rwx------ 1 sdbadmin sdbadmin_group 5725350 Mar 28 10:07 uninstall

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:07 rollback

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:07 packet

drwxr-xr-x 6 sdbadmin sdbadmin_group 4096 Mar 28 10:24 database

说明:

  • uninstall:集群卸载可执行文件;
  • bin:主要防止系统的必备可执行文件;
  • conf:配置文件目录,主要包含数据库节点的配置目录、集群管理服务进程sdbcm的配置文件和日志目录;
  • hadoop:与hadoop、hive对接的驱动连接器;
  • spark:与spark对接的驱动连接器;
  • java、CSharp、python:各自语言的驱动包;
  • samples:示例;
  • tools:存放各种工具;

1.2 SequoiaDB数据目录

SequoiaDB巨杉数据库的数据目录时在部署节点时指定的,下面以数据节点目录进行说明。

1)查找本机已部署数据节点;

[sdbadmin@sdbserver1 ~]$ sdblist -l -r data

Name SvcName Role PID GID NID PRY GroupName StartTime DBPath

sequoiadb 11820 data 2290 1000 1000 Y group1 2020-03-29-21.57.26 /opt/sequoiadb/database/data/11820/

sequoiadb 11830 data 2296 1001 1001 Y group2 2020-03-29-21.57.26 /opt/sequoiadb/database/data/11830/

sequoiadb 11840 data 2302 1002 1002 Y group3 2020-03-29-21.57.26 /opt/sequoiadb/database/data/11840/

Total: 3

2)进入其中一个数据节点并查看内容;

[sdbadmin@sdbserver1 ~]$ ll -tr /opt/sequoiadb/database/data/11820/

total 598292

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:24 tmp

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:24 diaglog

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:24 bakfile

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:24 archivelog

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:24 replicalog

-rw-r----- 1 sdbadmin sdbadmin_group 151060480 Mar 29 04:15 SYSSTAT.1.idx

-rw-r----- 1 sdbadmin sdbadmin_group 155254784 Mar 29 04:15 SYSSTAT.1.data

-rw-r----- 1 sdbadmin sdbadmin_group 151060480 Mar 29 04:15 company.1.idx

-rw-r----- 1 sdbadmin sdbadmin_group 155254784 Mar 29 04:15 company.1.data

说明:

  • replicalog:存放同步日志;
  • diaglog:节点日志记录;
  • bakfile:默认的备份文件存放路径;
  • archivelog:归档日志目录;

1.3 MySQL示例安装目录

SequoiaSQL-MySQL示例默认安装目录为/opt/sequoiasql/mysql/,目录内容为:

[sdbadmin@sdbserver1 ~]$ ll /opt/sequoiasql/mysql/

total 5568

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:12 bin

-rw-r--r-- 1 sdbadmin sdbadmin_group 32 Mar 28 10:12 checksum.md5

-rwxr-xr-x 1 sdbadmin sdbadmin_group 3234 Nov 14 23:21 compatible.sh

drwxr-xr-x 6 sdbadmin sdbadmin_group 4096 Mar 28 10:24 conf

-rw-r--r-- 1 sdbadmin sdbadmin_group 17987 Dec 21 2018 COPYING

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:24 database

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:12 docs

drwxr-xr-x 3 sdbadmin sdbadmin_group 4096 Mar 28 10:12 include

drwxr-xr-x 4 sdbadmin sdbadmin_group 4096 Mar 28 10:12 lib

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:12 license

drwxr-xr-x 4 sdbadmin sdbadmin_group 4096 Mar 28 10:12 man

-rw-r--r-- 1 sdbadmin sdbadmin_group 22096 Mar 29 21:57 myinst.log

-rwxr-xr-x 1 sdbadmin sdbadmin_group 255 Nov 14 23:21 preUninstall.sh

-rw-r--r-- 1 sdbadmin sdbadmin_group 2478 Dec 21 2018 README

drwxr-xr-x 28 sdbadmin sdbadmin_group 4096 Mar 28 10:12 share

drwxr-xr-x 2 sdbadmin sdbadmin_group 4096 Mar 28 10:12 support-files

drwxr-xr-x 4 sdbadmin sdbadmin_group 4096 Mar 28 10:12 tools

-rwx------ 1 sdbadmin sdbadmin_group 5574262 Mar 28 10:12 uninstall

-rw-r--r-- 1 root root 14630 Mar 28 10:12 uninstall.dat

-rw-r--r-- 1 sdbadmin sdbadmin_group 3 Mar 28 10:12 version.info

2 命令行管理控制台

2.1 查看巨杉数据库版本

[sdbadmin@sdbserver1 ~]$ sequoiadb --version

SequoiaDB version: 3.4

Release: 32435

Git version: 485380326b0177244669df7906454a753a7fb900

2019-11-14-23.37.58

2.2 查看节点启动列表

[sdbadmin@sdbserver1 ~]$ sdblist

sequoiadb(11800) (2287) C

sequoiadb(11820) (2290) D

sequoiadb(11810) (2293) S

sequoiadb(11830) (2296) D

sequoiadb(11840) (2302) D

Total: 5

C、S、D指节点的角色,分布代表编目节点、协调节点和数据节点;

[sdbadmin@sdbserver1 ~]$ sdblist -l -m local

Name SvcName Role PID GID NID PRY GroupName StartTime DBPath

sequoiadb 11810 coord 5509 2 2 Y SYSCoord 2020-03-29-22.42.25 /opt/sequoiadb/database/coord/11810/

sequoiadb 11830 data 5513 1001 1001 Y group2 2020-03-29-22.42.25 /opt/sequoiadb/database/data/11830/

sequoiadb 11820 data 8275 1000 1000 Y group1 2020-03-29-22.44.11 /opt/sequoiadb/database/data/11820/

sequoiadb 11800 catalog 5519 1 1 Y SYSCatalogGroup 2020-03-29-22.42.25 /opt/sequoiadb/database/catalog/11800/

sequoiadb 11840 data 5523 1002 1002 Y group3 2020-03-29-22.42.25 /opt/sequoiadb/database/data/11840/

Total: 5

2.3 启停资源管理节点

资源管理节点sdbcm(SequoiaDB Cluster Manager)是一个守护进程,它以服务的方式常驻系统后台。SequoiaDB的所有集群管理操作都必须有sdbcm的参与,目前每一台物理机器上只能启动一个sdbcm进程,负责执行远程的集群管理命令和监控本地的SequoiaDB数据库。sdbcm主要有两大功能:

  • 远程启动、关闭、创建和修改节点:通过SequoiaDB客户端或驱动连接器连接数据库时,可以执行启动、关闭、创建和修改节点的操作,该操作向指定节点物理机器上的sdbcm发送远程命令,并得到sdbcm的执行结果;
  • 本地监控:对于通过sdbcm启动的节点,都会维护一张节点列表,其中保存了所有本地节点的服务名和启动信息,如启动时间、运行状态等。如果某个节点是非正常终止的,如进程被强制终止,引擎易场推出等,sdbcm会尝试重启该节点。

1)停止sdbcm;

[sdbadmin@sdbserver1 ~]$ sdbcmtop

Terminating process 29893: sdbcm(11790)

DONE

Successful to stop sdbcm

2)启动sdbcm;

[sdbadmin@sdbserver1 ~]$ sdbcmart

Success: sdbcmd is successfully started (30778)

Success: sdbcm(11790) is successfully started (30780)

3 启停集群和节点

sdbcm服务启动后会自动启动该物理机中所有注册在 /opt/sequoiadb/conf/local/目录下的节点,使用命令ps -elf|grep sequoiadb或sdblist -t all能看到当前正在启动的节点与启动完毕的节点。

3.1 停止集群

[sdbadmin@sdbserver1 ~]$ sdbstop --all

Terminating process 26986: sdbom(11780)

DONE

Terminating process 26989: sequoiadb(11800)

DONE

Terminating process 26992: sequoiadb(11810)

DONE

Terminating process 26995: sequoiadb(11820)

DONE

Terminating process 26998: sequoiadb(11830)

DONE

Terminating process 27001: sequoiadb(11840)

DONE

Total: 6; Success: 6; Failed: 0

3.2 启动集群

[sdbadmin@sdbserver1 ~]$ sdbstart -t all

Success: sequoiadb(11810) is successfully started (5509)

Success: sequoiadb(11830) is successfully started (5513)

Success: sequoiadb(11820) is successfully started (5516)

Success: sequoiadb(11800) is successfully started (5519)

Success: sequoiadb(11840) is successfully started (5523)

Success: sdbom(11780) is successfully started (5527)

Total: 6; Succeed: 6; Failed: 0

3.3 停止节点

[sdbadmin@sdbserver1 ~]$ sdbstop -p 11820

Terminating process 5516: sequoiadb(11820)

DONE

Total: 1; Success: 1; Failed: 0

3.4 启动节点

[sdbadmin@sdbserver1 ~]$ sdbstart -p 11820

Success: sequoiadb(11820) is successfully started (8275)

Total: 1; Succeed: 1; Failed: 0

4 SequoiaDB Shell启停数据组

除了在Linux命令行中进行节点管理,SequoiaDB Shell交互界面同样支持管理节点。

1)进入SequoiaDB Shell交互界面;

[sdbadmin@sdbserver1 ~]$ sdb

Welcome to SequoiaDB shell!

help() for help, Ctrl+c or quit to exit

>

2)使用JavaScript连接协调节点,并获取数据库连接;

> var db=new Sdb('localhost',11810)

Takes 0.006333s.

3)停止数据组;

> db.stopRG('group1','group2')

Takes 11.051532s.

4)启动数据组;

> db.startRG('group1','group2')

Takes 4.051254s.

 

除特别声明,本站所有文章均为原创,如需转载请以超级链接形式注明出处:SmartCat's Blog

上一篇: vue watch数据的方法被调用了两次的问题

下一篇: 【SequoiaDB】4 巨杉数据库SequoiaDB整体架构

精华推荐