YashanDB个人版体验
产品简介
崖山数据库管理系统(YashanDB)是深圳计算科学研究院在经典数据库理论基础上,融入新的原创理论,自主设计、研发的新型数据库管理系统。
部署形态
- 单机
传统的关系型数据库理论与创新的底座引擎技术相结合,适用于集中式事务业务场景,支持主备形态。 - 分布式
继承单机能力的原生分布式处理系统,适用于分布式分析业务场景,支持主备形态。 - 共享集群
基于共享存储的多活集群,提供计算/存储扩展和金融级高可用能力,适用于高端核心交易场景。
安装部署
安装前准备
下面是个人版单机形态YashanDB服务端安装部署所需的前期准备
环境如下:
操作系统 | CPU内存 | 磁盘 | IP地址 | 安装版本 |
---|---|---|---|---|
CentOS 7.9 | 2C8G | 60G | 192.168.17.62 | YashanDB Personal 23.1 (Linux X86) |
安装介质在下载页面,选择YashanDB Personal 23.1 (Linux X86)版本下载
创建安装用户
useradd yashan passwd yashan
操作如下
[root@centos7 ~]# useradd yashan
[root@centos7 ~]# passwd yashan
Changing password for user yashan.
New password:
BAD PASSWORD: The password is shorter than 8 characters
Retype new password:
passwd: all authentication tokens updated successfully.
[root@centos7 ~]#
操作系统参数调整
cat >> /etc/security/limits.conf <<EOF
* soft nofile 65536
* hard nofile 65536
* soft nproc 65536
* hard nproc 65536
* soft rss unlimited
* hard rss unlimited
* soft stack 8192
* hard stack 8192
EOF
操作如下
[root@centos7 ~]# cat >> /etc/security/limits.conf <<EOF
>
> * soft nofile 65536
> * hard nofile 65536
> * soft nproc 65536
> * hard nproc 65536
> * soft rss unlimited
> * hard rss unlimited
> * soft stack 8192
> * hard stack 8192
>
> EOF
[root@centos7 ~]#
关闭防火墙和selinux
systemctl stop firewalld
systemctl disable firewalld
sed -i 's/SELINUX\=enforcing/SELINUX\=disabled/g' /etc/selinux/config
setenforce 0
操作如下
[root@centos7 ~]# systemctl stop firewalld
[root@centos7 ~]# systemctl disable firewalld
[root@centos7 ~]# sed -i 's/SELINUX\=enforcing/SELINUX\=disabled/g' /etc/selinux/config
[root@centos7 ~]# setenforce 0
setenforce: SELinux is disabled
[root@centos7 ~]#
创建yashan数据库目录
mkdir -p /data/yashan/yasdb_data mkdir -p /data/yashan/yasdb_home chown -R yashan:yashan /data chmod -R 777 /data/yashan
操作如下
[root@centos7 ~]# mkdir -p /data/yashan/yasdb_data
[root@centos7 ~]# mkdir -p /data/yashan/yasdb_home
[root@centos7 ~]# chown -R yashan:yashan /data
[root@centos7 ~]# chmod -R 777 /data/yashan
创建安装目录解压安装文件
su - yashan
mkdir -p /home/yashan/install
cd /home/yashan/install
#将安装文件上传到/home/yashan/install目录下,并解压
ll
tar -zxf yashandb-personal-23.1.1.100-linux-x86_64.tar.gz
ll
操作如下
[root@centos7 ~]# su - yashan
Last login: Wed Nov 8 13:02:28 CST 2023 on pts/0
[yashan@centos7 ~]$ mkdir -p /home/yashan/install
[yashan@centos7 ~]$ cd /home/yashan/install
[yashan@centos7 install]$ ll
total 248120
-rw-r--r-- 1 yashan yashan 254073880 Nov 8 13:01 yashandb-personal-23.1.1.100-linux-x86_64.tar.gz
[yashan@centos7 install]$ tar -zxf yashandb-personal-23.1.1.100-linux-x86_64.tar.gz
[yashan@centos7 install]$ ll
total 248156
drwxrwxr-x 6 yashan yashan 70 Nov 1 17:04 admin
drwxrwxr-x 2 yashan yashan 188 Nov 1 17:04 bin
drwxrwxr-x 2 yashan yashan 152 Nov 1 17:04 conf
drwxrwxr-x 5 yashan yashan 60 Nov 1 17:04 ext
-rw-rw-r-- 1 yashan yashan 11632 Nov 1 17:04 gitmoduleversion.dat
drwxrwxr-x 2 yashan yashan 65 Nov 1 17:04 include
drwxrwxr-x 3 yashan yashan 17 Nov 1 17:04 java
drwxrwxr-x 2 yashan yashan 4096 Nov 1 17:04 lib
-rw-r----- 1 yashan yashan 14989 Nov 1 17:04 LICENSE
drwxrwxr-x 3 yashan yashan 21 Nov 1 17:04 plug-in
drwxrwxr-x 2 yashan yashan 170 Nov 1 17:04 scripts
-rw-r--r-- 1 yashan yashan 254073880 Nov 8 13:01 yashandb-personal-23.1.1.100-linux-x86_64.tar.gz
[yashan@centos7 install]$
生成参数文件
#注意这里的se是代表单机 -u后面是主机ssh用户名 -p后面是ssh登录密码 还有ip地址都需要相应修改
./bin/yasboot package se gen --cluster yashandb -u yashan -p yashan --ip 192.168.17.62 --port 22 --install-path /data/yashan/yasdb_home --data-path /data/yashan/yasdb_data --begin-port 1688
#当前目录下将生成yashandb.toml和hosts.toml两个配置文件
ll *.toml
#查看配置文件
cat yashandb.toml
cat hosts.toml
操作如下
[yashan@centos7 install]$ ./bin/yasboot package se gen --cluster yashandb -u yashan -p yashan --ip 192.168.17.62 --port 22 --install-path /data/yashan/yasdb_home --data-path /data/yashan/yasdb_data --begin-port 1688
hostid | group | node_type | node_name | listen_addr | replication_addr | data_path
--------------------------------------------------------------------------------------------------------------
host0001 | dbg1 | db | 1-1 | 192.168.17.62:1688 | 192.168.17.62:1689 | /data/yashan/yasdb_data
----------+-------+-----------+-----------+--------------------+--------------------+-------------------------
Generate config success
[yashan@centos7 install]$ ll *.toml
-rw------- 1 yashan yashan 492 Nov 8 13:16 hosts.toml
-rw------- 1 yashan yashan 725 Nov 8 13:16 yashandb.toml
[yashan@centos7 install]$ cat yashandb.toml
cluster = "yashandb"
create_simple_schema = false
uuid = "654b19995d57008265ebe441ee8aa64a"
yas_type = "SE"
[[group]]
group_type = "db"
name = "dbg1"
[group.config]
CHARACTER_SET = "utf8"
ISARCHIVELOG = true
REDO_FILE_NUM = 4
REDO_FILE_SIZE = "128M"
[group.create_sql]
[[group.node]]
data_path = "/data/yashan/yasdb_data"
hostid = "host0001"
role = 1
[group.node.config]
LISTEN_ADDR = "192.168.17.62:1688"
REPLICATION_ADDR = "192.168.17.62:1689"
RUN_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.1.100/log/yashandb/db-1-1/run"
RUN_LOG_LEVEL = "INFO"
SLOW_LOG_FILE_PATH = "/data/yashan/yasdb_home/yashandb/23.1.1.100/log/yashandb/db-1-1/slow"
[yashan@centos7 install]$ cat hosts.toml
uuid = "654b19995d57008265ebe441ee8aa64a"
cluster = "yashandb"
yas_type = "SE"
secret_key = "16143d4f00084201"
add_yasdba = true
[om]
hostid = "host0001"
[om.config]
LISTEN_ADDR = "192.168.17.62:1675"
[[host]]
hostid = "host0001"
group = "yashan"
user = "yashan"
password = "yashan"
ip = "192.168.17.62"
port = 22
path = "/data/yashan/yasdb_home"
jvm_path = ""
total_memory = 0
[host.yasagent]
[host.yasagent.config]
LISTEN_ADDR = "192.168.17.62:1676"
[yashan@centos7 install]$
执行安装
./bin/yasboot package install -t hosts.toml -i yashandb-personal-23.1.1.100-linux-x86_64.tar.gz
操作如下
[yashan@centos7 install]$ ./bin/yasboot package install -t hosts.toml -i yashandb-personal-23.1.1.100-linux-x86_64.tar.gz checking install package... install version: yashandb 23.1.1.100 host0001 100% [====================================================================] 3s update host to yasom... [yashan@centos7 install]$
数据库部署
#执行部署命令
./bin/yasboot cluster deploy -t yashandb.toml
#生效环境变量
cd /data/yashan/yasdb_home/yashandb/23.1.1.100/conf
cat yashandb.bashrc >> ~/.bashrc
source ~/.bashrc
操作如下
[yashan@centos7 install]$ ./bin/yasboot cluster deploy -t yashandb.toml
type | uuid | name | hostid | index | status | return_code | progress | cost
------------------------------------------------------------------------------------------------------------
task | b38ec7400697c619 | DeployYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 9
------+------------------+--------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 install]$ cd /data/yashan/yasdb_home/yashandb/23.1.1.100/conf
[yashan@centos7 conf]$ cat yashandb.bashrc >> ~/.bashrc
[yashan@centos7 conf]$ source ~/.bashrc
[yashan@centos7 conf]$修改sys用户口令
修改sys用户口令
#YashanDB不提供系统初始口令,请通过yasboot工具设置集群内所有节点sys用户的密码。
cd /home/yashan/install
#这里我们就设置密码为yashan_123
./bin/yasboot cluster password set -n yashan_123 -c yashandb
操作如下
[yashan@centos7 install]$ ./bin/yasboot cluster password set -n yashan_123 -c yashandb
type | uuid | name | hostid | index | status | return_code | progress | cost
----------------------------------------------------------------------------------------------------------
task | 881951b8f19dd2e5 | YasdbPasswordSet | - | yashandb | SUCCESS | 0 | 100 | 3
------+------------------+------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 install]$
验证安装是否成功
#执行查看数据库状态命令
./bin/yasboot cluster status -c yashandb -d
#使用yasboot工具连接数据库,查看实例状态
./bin/yasboot sql -d sys/yashan_123@192.168.17.62:1688
SELECT STATUS FROM V$INSTANCE;
SELECT DATABASE_NAME FROM V$DATABASE;
操作如下
[yashan@centos7 install]$ ./bin/yasboot cluster status -c yashandb -d
hostid | node_type | nodeid | pid | instance_status | database_status | database_role | listen_address | data_path
------------------------------------------------------------------------------------------------------------------------------------------------
host0001 | db | 1-1:1 | 2559 | open | normal | primary | 192.168.17.62:1688 | /data/yashan/yasdb_data/db-1-1
----------+-----------+--------+------+-----------------+-----------------+---------------+--------------------+--------------------------------
[yashan@centos7 install]$ ./bin/yasboot sql -d sys/yashan_123@192.168.17.62:1688
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> SELECT status FROM V$INSTANCE;
SELECT status FROM V$INSTANCE;
STATUS
-------------
OPEN
1 row fetched.
SQL> SELECT database_name FROM V$DATABASE;
SELECT database_name FROM V$DATABASE;
DATABASE_NAME
----------------------------------------------------------------
yashandb
1 row fetched.
SQL>
数据库管理
实例启停
单机及分布式部署的实例启停方式,分别为SQL命令方式及OM工具方式
关闭实例
#通过SQL命令的方式和ORACLE关闭实例命令差不多
yasql sys/yashan_123@192.168.17.62:1688
SHUTDOWN NORMAL;
SHUTDOWN IMMEDIATE;
SHUTDOWN ABORT;
#也可通过使用yasboot工具关闭数据库实例
yasboot cluster stop -c yashandb
yasboot cluster stop -c yashandb -s normal
yasboot cluster stop -c yashandb -s immediate
yasboot cluster stop -c yashandb -s abort
操作如下
[yashan@centos7 install]$ yasql sys/yashan_123@192.168.17.62:1688
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> SHUTDOWN IMMEDIATE;
Succeed.
SQL> exit
[yashan@centos7 install]$ yasboot cluster stop -c yashandb -s immediate
type | uuid | name | hostid | index | status | return_code | progress | cost
----------------------------------------------------------------------------------------------------------
task | 2485ca10acac0c32 | StopYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 2
------+------------------+------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 install]$
启动实例
#通过SQL命令的方式
yasboot cluster start -c yashandb -m nomount
yasql sys/yashan_123@192.168.17.62:1688
SELECT status FROM V$INSTANCE;
ALTER DATABASE MOUNT;
SELECT status FROM V$INSTANCE;
ALTER DATABASE OPEN;
SELECT status FROM V$INSTANCE;
#也可通过使用yasboot工具启动数据库实例
yasboot cluster start -c yashandb -m nomount
yasboot cluster start -c yashandb -m mount
yasboot cluster start -c yashandb
yasql sys/yashan_123@192.168.17.62:1688
SELECT status FROM V$INSTANCE;
操作如下
[yashan@centos7 install]$ yasboot cluster start -c yashandb -m nomount
type | uuid | name | hostid | index | status | return_code | progress | cost
-----------------------------------------------------------------------------------------------------------
task | f5d65ad1b78c38c8 | StartYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 2
------+------------------+-------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 install]$ yasql sys/yashan_123@192.168.17.62:1688
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> SELECT status FROM V$INSTANCE;
STATUS
-------------
STARTED
1 row fetched.
SQL> ALTER DATABASE MOUNT;
Succeed.
SQL> SELECT status FROM V$INSTANCE;
STATUS
-------------
MOUNTED
1 row fetched.
SQL> ALTER DATABASE OPEN;
Succeed.
SQL> SELECT status FROM V$INSTANCE;
STATUS
-------------
OPEN
1 row fetched.
SQL>
[yashan@centos7 install]$ yasboot cluster start -c yashandb
type | uuid | name | hostid | index | status | return_code | progress | cost
-----------------------------------------------------------------------------------------------------------
task | f6939d7918fc72c9 | StartYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 2
------+------------------+-------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 install]$ yasql sys/yashan_123@192.168.17.62:1688
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> SELECT status FROM V$INSTANCE;
STATUS
-------------
OPEN
1 row fetched.
SQL>
备份恢复
SQL命令方式备份
#对单机部署的数据库执行备份恢复的模拟场景
#创建备份目录
mkdir -p /data/yashan/backup
#重启数据库到MOUNT状态打开归档模式
yasboot cluster restart -c yashandb -m mount
ALTER DATABASE ARCHIVELOG;
ALTER DATABASE OPEN;
#模拟业务场景,在数据库中创建表并插入数据
CREATE TABLE t (id INT,name VARCHAR(20)) TABLESPACE USERS;
INSERT INTO t VALUES (1,'hello yashandb!');
COMMIT;
SELECT * FROM t;
#执行数据全量备份
BACKUP DATABASE FULL FORMAT '/data/yashan/backup/full_20231108';
#查看备份详情
SELECT * FROM DBA_BACKUP_SET;
#检查生成的备份集物理文件
cd /data/yashan/backup/full_20231108
ls -rlt
操作如下
[yashan@centos7 install]$ mkdir -p /data/yashan/backup
[yashan@centos7 install]$ yasboot cluster restart -c yashandb -m mount
type | uuid | name | hostid | index | status | return_code | progress | cost
-------------------------------------------------------------------------------------------------------------
task | 078b2555a23ac5cd | ReStartYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 5
------+------------------+---------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 install]$ yasql sys/yashan_123
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> ALTER DATABASE ARCHIVELOG;
Succeed.
SQL> ALTER DATABASE OPEN;
Succeed.
SQL> CREATE TABLE t (id INT,name VARCHAR(20)) TABLESPACE USERS;
Succeed.
SQL> INSERT INTO t VALUES (1,'hello yashandb!');
1 row affected.
SQL> COMMIT;
SELECT * FROM t;
Succeed.
SQL>
ID NAME
------------ ---------------------
1 hello yashandb!
1 row fetched.
SQL> BACKUP DATABASE FULL FORMAT '/data/yashan/backup/full_20231108';
Succeed.
SQL> SELECT * FROM DBA_BACKUP_SET;
RECID# START_TIME COMPLETION_TIME TYPE INCREMENT_LEVEL INCREMENT_ID# PATH TAG TRUNC_LSN COMPRESS_LEVEL INPUT_BYTES OUTPUT_BYTES RCY_BEGIN_ASN RCY_BEGIN_LFN RCY_END_ASN RCY_END_LFN COMPRESS_ALGO ENCRYPT_ALGO
--------------------- -------------------------------- -------------------------------- ------------- --------------- ------------- ---------------------------------------------------------------- ---------------------------------------------------------------- --------------------- -------------- --------------------- --------------------- ------------- --------------------- ------------ --------------------- ------------- ------------
1 2023-11-08 2023-11-08 FULL 0 0 /data/yashan/backup/full_20231108 bak_2023110814404109 4366 NONE 378462208 378462208 7 2252 7 2252 NONE NONE
1 row fetched.
SQL> exit
[yashan@centos7 install]$ cd /data/yashan/backup/full_20231108
[yashan@centos7 full_20231108]$ ls -rlt
total 369600
-rw-r----- 1 yashan yashan 25370624 Nov 8 14:40 ctrl_0_0_0.bak
-rw-r----- 1 yashan yashan 67108864 Nov 8 14:40 data_0_0_0.bak
-rw-r----- 1 yashan yashan 67108864 Nov 8 14:40 data_1_0_0.bak
-rw-r----- 1 yashan yashan 8192 Nov 8 14:40 data_2_0_0.bak
-rw-r----- 1 yashan yashan 8192 Nov 8 14:40 data_3_0_0.bak
-rw-r----- 1 yashan yashan 67108864 Nov 8 14:40 data_4_0_0.bak
-rw-r----- 1 yashan yashan 134217728 Nov 8 14:40 data_5_0_0.bak
-rw-r----- 1 yashan yashan 753664 Nov 8 14:40 arch0_0_7_0.bak
drwx------ 2 yashan yashan 6 Nov 8 14:40 bucket_4_0_0.bak
-rw-r----- 1 yashan yashan 16777216 Nov 8 14:40 backup_profile
-rw-r----- 1 yashan yashan 4608 Nov 8 14:40 backup_filelist
[yashan@centos7 full_20231108]$
SQL命令方式恢复
#模拟灾难场景,删除表,删除数据库文件
#删除表t
yasql sys/yashan_123
DROP TABLE t;
#进入数据文件目录删除数据文件
cd $YASDB_DATA/dbfiles
ls -k
rm -rf ./*
ls -rlt
#关闭实例
yasql sys/yashan_123
SHUTDOWN IMMEDIATE;
#重启实例发现控制文件找不到报错
yasboot cluster start -c yashandb
#进行SQL命令恢复,先将实例启动到nomount状态
yasboot cluster restart -c yashandb -m nomount
#进行全库恢复
yasql sys/yashan_123
RESTORE DATABASE FROM '/data/yashan/backup/full_20231108';
ALTER DATABASE OPEN;
操作如下
[yashan@centos7 ~]$ yasql sys/yashan_123
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> DROP TABLE t;
Succeed.
SQL> exit
[yashan@centos7 ~]$ cd $YASDB_DATA/dbfiles
[yashan@centos7 dbfiles]$ ls -k
ctrl1 ctrl2 ctrl3 dwf redo1 redo2 redo3 redo4 swap sysaux system temp undo users
[yashan@centos7 dbfiles]$ rm -rf ./*
[yashan@centos7 dbfiles]$ ls -rlt
total 0
[yashan@centos7 dbfiles]$ yasql sys/yashan_123
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> SHUTDOWN IMMEDIATE;
YAS-00406 connection is closed
SQL> exit
[yashan@centos7 dbfiles]$ yasboot cluster start -c yashandb
type | uuid | name | hostid | index | status | return_code | progress | cost
----------------------------------------------------------------------------------------------------------
task | 638c6ea644893f8e | StartYasdbCluster | - | yashandb | FAILED | 1 | 100 | 12
------+------------------+-------------------+--------+----------+--------+-------------+----------+------
task completed, status: FAILED
retcode: 1
stdout: node:1-1 start with ping failed
stderr: wait node 1-1 process start failed: Starting instance open
failed to open file /data/yashan/yasdb_data/db-1-1/dbfiles/ctrl1, errno 2, error message "No such file or directory"
Failed to start instance
[yashan@centos7 dbfiles]$ yasboot cluster restart -c yashandb -m nomount
type | uuid | name | hostid | index | status | return_code | progress | cost
-------------------------------------------------------------------------------------------------------------
task | 07a1a5e84e647b07 | ReStartYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 3
------+------------------+---------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 dbfiles]$ yasql sys/yashan_123
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> RESTORE DATABASE FROM '/data/yashan/backup/full_20231108';
Succeed.
SQL> ALTER DATABASE OPEN;
Succeed.
SQL> SELECT * FROM t;
ID NAME
------------ ---------------------
1 hello yashandb!
1 row fetched.
SQL>
yarman工具方式备份
#创建catalog目录
mkdir -p /home/yashan/catalog
#创建catalog文件
yasrman sys/yashan_123@127.0.0.1:1688 -c "create catalog" -D /home/yashan/catalog
#列出已有默认配置项
yasrman sys/yashan_123@127.0.0.1:1688 -c "show all" -D /home/yashan/catalog
#配置备份功能
yasrman sys/yashan_123@127.0.0.1:1688 -c "configure PARALLELISM 4" -D /home/yashan/catalog
yasrman sys/yashan_123@127.0.0.1:1688 -c "configure COMPRESSION ALGORITHM ZSTD" -D /home/yashan/catalog
yasrman sys/yashan_123@127.0.0.1:1688 -c "configure COMPRESSION LEVEL HIGH" -D /home/yashan/catalog
#列出配置项
yasrman sys/yashan_123@127.0.0.1:1688 -c "show all" -D /home/yashan/catalog
#清空压缩算法配置项
yasrman sys/yashan_123@127.0.0.1:1688 -c "configure COMPRESSION ALGORITHM CLEAR" -D /home/yashan/catalog
#执行全量备份
yasrman sys/yashan_123@192.168.17.62:1688 -c "backup database tag 'full_1' format 'full_bak_1'" -D /home/yashan/catalog
#查看备份集
yasrman sys/yashan_123@127.0.0.1:1688 -c "list backup" -D /home/yashan/catalog
#插入一条记录验证
yasql sys/yashan_123
INSERT INTO t VALUES (2,'add two!');
COMMIT;
SELECT * FROM t;
#增量备份
yasrman sys/yashan_123@192.168.17.62:1688 -c "backup database incremental level 0 tag 'incr_1' format 'incr_bak_1'" -D /home/yashan/catalog
#查看备份集
yasrman sys/yashan_123@127.0.0.1:1688 -c "list backup" -D /home/yashan/catalog
操作如下
[yashan@centos7 ~]$ mkdir -p /home/yashan/catalog
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "create catalog" -D /home/yashan/catalog
create catalog successfully
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "show all" -D /home/yashan/catalog
+---------------------------+-----------+----------------+
| NAME | DEFAULT | VALUE |
+---------------------------+-----------+----------------+
| PARALLELISM | 2 | 2 |
| SECTION SIZE | 134217728 | 134217728 |
| COMPRESSION ALGORITHM | NONE | NONE |
| COMPRESSION LEVEL | LOW | LOW |
| DEST | SERVER | SERVER |
+---------------------------+-----------+----------------+
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "configure PARALLELISM 4" -D /home/yashan/catalog
configure successfully
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "configure COMPRESSION ALGORITHM ZSTD" -D /home/yashan/catalog
configure successfully
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "configure COMPRESSION LEVEL HIGH" -D /home/yashan/catalog
configure successfully
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "show all" -D /home/yashan/catalog
+---------------------------+-----------+----------------+
| NAME | DEFAULT | VALUE |
+---------------------------+-----------+----------------+
| PARALLELISM | 2 | 4 |
| SECTION SIZE | 134217728 | 134217728 |
| COMPRESSION ALGORITHM | NONE | ZSTD |
| COMPRESSION LEVEL | LOW | HIGH |
| DEST | SERVER | SERVER |
+---------------------------+-----------+----------------+
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "configure COMPRESSION ALGORITHM CLEAR" -D /home/yashan/catalog
configure successfully
[yashan@centos7 ~]$ yasrman sys/yashan_123@192.168.17.62:1688 -c "backup database tag 'full_1' format 'full_bak_1'" -D /home/yashan/catalog
backup successfully
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "list backup" -D /home/yashan/catalog
Group: tag: full_1, format: /data/yashan/yasdb_data/db-1-1/backup/full_bak_1, connect url: 192.168.17.62:1688, nodeCount: 1, distribution: FALSE, isClient: FALSE, offset: 0
backup path: /data/yashan/yasdb_data/db-1-1/backup/full_bak_1
[yashan@centos7 ~]$ yasql sys/yashan_123
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> INSERT INTO t VALUES (2,'add two!');
1 row affected.
SQL> COMMIT;
Succeed.
SQL> SELECT * FROM t;
ID NAME
------------ ---------------------
1 hello yashandb!
2 add two!
2 rows fetched.
SQL> exit
[yashan@centos7 ~]$ yasrman sys/yashan_123@192.168.17.62:1688 -c "backup database incremental level 0 tag 'incr_1' format 'incr_bak_1'" -D /home/yashan/catalog
backup successfully
[yashan@centos7 ~]$ yasrman sys/yashan_123@127.0.0.1:1688 -c "list backup" -D /home/yashan/catalog
Group: tag: full_1, format: /data/yashan/yasdb_data/db-1-1/backup/full_bak_1, connect url: 192.168.17.62:1688, nodeCount: 1, distribution: FALSE, isClient: FALSE, offset: 0
backup path: /data/yashan/yasdb_data/db-1-1/backup/full_bak_1
Group: tag: incr_1, format: /data/yashan/yasdb_data/db-1-1/backup/incr_bak_1, connect url: 192.168.17.62:1688, nodeCount: 1, distribution: FALSE, isClient: FALSE, offset: 12288
backup path: /data/yashan/yasdb_data/db-1-1/backup/incr_bak_1
[yashan@centos7 ~]$
yarman工具方式恢复
#进入数据文件目录删除数据文件
cd $YASDB_DATA/dbfiles
ls -k
rm -rf ./*
ls -rlt
#关闭实例
yasql sys/yashan_123
SHUTDOWN IMMEDIATE;
#先将实例启动到nomount状态
yasboot cluster restart -c yashandb -m nomount
#进行全库的恢复。恢复后直接OPEN状态
yasrman sys/yashan_123@192.168.17.62:1688 -c "restore database from tag 'incr_1'" -D /home/yashan/catalog
yasql sys/yashan_123
SELECT * FROM t;
SELECT status FROM V$INSTANCE;
操作如下
[yashan@centos7 ~]$ cd $YASDB_DATA/dbfiles
[yashan@centos7 dbfiles]$ ll
total 1122904
-rw-r----- 1 yashan yashan 25370624 Nov 8 15:15 ctrl1
-rw-r----- 1 yashan yashan 25370624 Nov 8 15:15 ctrl2
-rw-r----- 1 yashan yashan 25370624 Nov 8 15:15 ctrl3
-rw-r----- 1 yashan yashan 67108864 Nov 8 15:15 dwf
-rw-r----- 1 yashan yashan 134217728 Nov 8 15:07 redo1
-rw-r----- 1 yashan yashan 134217728 Nov 8 15:15 redo2
-rw-r----- 1 yashan yashan 134217728 Nov 8 15:15 redo3
-rw-r----- 1 yashan yashan 134217728 Nov 8 14:53 redo4
-rw-r----- 1 yashan yashan 67108864 Nov 8 14:53 swap
-rw-r----- 1 yashan yashan 67108864 Nov 8 14:53 sysaux
-rw-r----- 1 yashan yashan 67108864 Nov 8 15:15 system
-rw-r----- 1 yashan yashan 67108864 Nov 8 14:53 temp
-rw-r----- 1 yashan yashan 134217728 Nov 8 15:15 undo
-rw-r----- 1 yashan yashan 67108864 Nov 8 15:13 users
[yashan@centos7 dbfiles]$ rm -rf ./*
[yashan@centos7 dbfiles]$ ls -rlt
total 0
[yashan@centos7 dbfiles]$ yasql sys/yashan_123
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> SHUTDOWN IMMEDIATE;
Succeed.
SQL> exit
[yashan@centos7 dbfiles]$
[yashan@centos7 dbfiles]$ yasboot cluster restart -c yashandb -m nomount
type | uuid | name | hostid | index | status | return_code | progress | cost
-------------------------------------------------------------------------------------------------------------
task | ba249d9b767881a2 | ReStartYasdbCluster | - | yashandb | SUCCESS | 0 | 100 | 3
------+------------------+---------------------+--------+----------+---------+-------------+----------+------
task completed, status: SUCCESS
[yashan@centos7 dbfiles]$ yasrman sys/yashan_123@192.168.17.62:1688 -c "restore database from tag 'incr_1'" -D /home/yashan/catalog
restore successfully
[yashan@centos7 dbfiles]$ yasql sys/yashan_123
YashanDB SQL Personal Edition Release 23.1.1.100 x86_64
Connected to:
YashanDB Server Personal Edition Release 23.1.1.100 x86_64 - X86 64bit Linux
SQL> SELECT * FROM t;
ID NAME
------------ ---------------------
1 hello yashandb!
2 add two!
2 rows fetched.
SQL> SELECT status FROM V$INSTANCE;
STATUS
-------------
OPEN
1 row fetched.
SQL>
最后修改时间:2023-11-13 14:25:55
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。