1. 前言
国产数据库越来越多了,2023年11月,崖山(YashanDB)数据库开放了个人版下载。作为数据库从业者的我,当然要尝尝鲜啦。
简单介绍下,崖山数据库系统YashanDB是深圳计算科学研究院完全自主研发设计的新型数据库系统,支持单机/主备、共享集群、分布式等多种部署方式,覆盖OLTP/HTAP/OLAP交易和分析混合负载场景。由于个人版仅支持单机部署,无法体验共享集群部署,深表遗憾。管不了那么多了,开整!
2.架构介绍
YashanDB(崖山)数据库支持单机/主备、共享集群、分布式三种架构,共享集群架构在RTO/RPO上优势明显,最受企业欢迎。目前提供共享集群架构的厂家有Oracle、达梦及YashanDB(崖山)。下面一起了解下YashanDB(崖山)的三种架构。
2.1 单机架构
单机架构如下图所示:
2.2 共享集群架构
共享集群依据YashanDB内核逻辑演进而来,并在共享存储的基础上引入了Cohesive Memory核心技术,用于集群数据库各实例之间协同数据页的读写访问以及各种非数据类的并发控制,主要特点包括:
共享集群是一个单库多实例的多活数据库系统,用户连接任意实例都可以访问同一个数据库,多个数据库实例可以并发读写同一份数据,具备高可用、高扩展、高性能等特性。
共享集群的核心组件主要包括YCK(Yashan Cluster Kernel,崖山集群内核)、YCS(Yashan Cluster Service,崖山集群服务)和YFS(Yashan File System,崖山文件系统)。
共享集群支持在线故障自动切换和故障自动恢复,集群任一实例异常都不影响正常实例对外提供的服务。
通过客户端TAF技术,可以实现在故障发生时自动将连接切换到存活的集群实例,故障对业务透明无感知。
共享集群架构如下图所示:
2.3 分布式架构
YashanDB分布式部署基于Shared-Nothing 架构,由多个节点组(Coordinator Node Group、Management Node Group、Data Node Group)组成,节点组内有多个节点(Coordinator Node、Management Node、Data Node)。这些节点部署在不同主机上,有不同的安装目录、数据目录,并且通过一些网络端口进行内部通讯或对外提供服务。
分布式架构如下图所示:
3.安装前准备
在数据库安装前,我们需要获取安装介质,并提前规划部署好数据库主机操作系统,存储目录等。
3.1 软件获取
本次个人版提供了Linux(X86/ARM)两个版本供下载。
https://download.yashandb.com/download
- 软件包说明
软件包 | 说明 |
---|---|
yashandb-personal-23.1.1.100-linux-x86_64.tar.gz | 崖山数据库个人版linux安装包 |
3.2 安装规划
机器名 | 操作系统 | 软件目录 | 数据目录 |
---|---|---|---|
alldb | Centos7.6 | /yasdb/yasdb_home | /yasdb/yasdb_data |
4. 操作系统调整
4.1 关闭防火墙
# systemctl stop firewalld
# systemctl disable firewalld
4.2 关闭交换分区
# 最大限度使用物理内存
# echo " vm.swappiness = 0" >> /etc/sysctl.conf
4.3 调整自动分配本地端口范围
# echo "net.ipv4.ip_local_port_range = 32768 60999" >> /etc/sysctl.conf
4.4 调整进程的VMA上限
#该参数作用是限制一个进程可以拥有的VMA(虚拟内存区域)的数量,调整是为了让数据库进程充分使用主机资源
# echo "vm.max_map_count=2000000" >> /etc/sysctl.conf
4.5 使调整生效
# sysctl -p
4.6 调整资源限制
# vi /etc/security/limits.conf
# 表示yashan用户可以打开的最大的文件描述符数量65536个
yashan soft nofile 65536
yashan hard nofile 65536
# 表示yashan用户可以打开的最大的进程数65536个
yashan soft nproc 65536
yashan hard nproc 65536
# 表示yashan用户可以没有限制的使用常驻内存的大小
yashan soft rss unlimited
yashan hard rss unlimited
# 表示yashan用户可以使用linux的默认栈空间大小是8192kb
yashan soft stack 8192
yashan hard stack 8192
4.7 关闭透明大页
编辑/etc/default/grub,在 GRUB_CMDLINE_LINUX 中添加或修改参数 transparent_hugepage=never
# vi /etc/default/grub
GRUB_TIMEOUT=5
GRUB_DISTRIBUTOR="$(sed 's, release .*$,,g' /etc/system-release)"
GRUB_DEFAULT=saved
GRUB_DISABLE_SUBMENU=true
GRUB_TERMINAL_OUTPUT="console"
GRUB_CMDLINE_LINUX="crashkernel=auto rd.lvm.lv=rhel/root rd.lvm.lv=rhel/swap rhgb quiet transparent_hugepage=never"
GRUB_DISABLE_RECOVERY="true"
# grub2-mkconfig -o /boot/grub2/grub.cfg
5.数据库安装
5.1 创建yashan用户
# useradd -d /home/yashan -m yashan
# password yashan
5.2 软件目录创建
# mkdir -p /yasdb
# chown -R yashan:yashan /yasdb/
# chmod -R 755 /yasdb/
5.3 安装包解压
[root@alldb yasdb]# su - yashan
[yashan@alldb ~]$ cd /yasdb/
[yashan@alldb yasdb]$ mkdir ~/install
[yashan@alldb yasdb]$ cd ~/install/
[yashan@alldb install]$ tar -xf /opt/yashandb-personal-23.1.1.100-linux-x86_64.tar.gz
5.4 配置文件编辑
[yashan@alldb install]$ cd scripts/
[yashan@alldb scripts]$ vi install.ini
[install]
#软件目录
YASDB_HOME=/yasdb/yasdb_home
#数据目录
YASDB_DATA=/yasdb/yasdb_data
REDO_FILE_SIZE=100M
REDO_FILE_NUM=4
INSTALL_SIMPLE_SCHEMA_SALES=N
NLS_CHARACTERSET=UTF8
[instance]
LISTEN_ADDR=0.0.0.0:1688
DB_BLOCK_SIZE=8K
DATA_BUFFER_SIZE=256M
SHARE_POOL_SIZE=256M
WORK_AREA_POOL_SIZE=32M
LARGE_POOL_SIZE=32M
REDO_BUFFER_SIZE=8M
UNDO_RETENTION=300
OPEN_CURSORS=310
MAX_SESSIONS=1024
RUN_LOG_LEVEL=INFO
NODE_ID=1-1:1
5.5 软件安装
[yashan@alldb scripts]$ ./install.sh
5.6 数据库初始化
[yashan@alldb scripts]$ ./initDB.sh
process started!
Database open succeed !
[yashan@alldb scripts]$
5.7 生效环境变量
$ source ~/.bashrc
至此,数据库安装完成了,非常的简单吧。
6. 崖山数据库初体验
6.1 登陆数据库
$ yasql sys/yasdb_123
log:
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>
SQL> select status from v$instance;
STATUS
-------------
OPEN
1 row fetched.
SQL>
SQL> select database_name from v$database;
DATABASE_NAME
----------------------------------------------------------------
yasdb
1 row fetched.
SQL>
6.2 查看表空间及数据文件
SQL> select name,status from v$tablespace;
NAME STATUS
---------------------------------------------------------------- -----------------
SYSTEM ONLINE
SYSAUX ONLINE
TEMP ONLINE
SWAP ONLINE
USERS ONLINE
UNDO ONLINE
6 rows fetched.
SQL> select name from v$datafile;
NAME
----------------------------------------------------------------
/yasdb/yasdb_data/dbfiles/system
/yasdb/yasdb_data/dbfiles/sysaux
/yasdb/yasdb_data/dbfiles/temp
/yasdb/yasdb_data/dbfiles/swap
/yasdb/yasdb_data/dbfiles/users
/yasdb/yasdb_data/dbfiles/undo
6.3 查看参数
SQL> show parameter
NAME VALUE
---------------------------------------------------------------- ----------------------------------------------------------------
MAX_SESSIONS 1024
MAX_WORKERS 0
MAX_PARALLEL_WORKERS 32
MAX_REACTOR_CHANNELS 0
WORK_AREA_STACK_SIZE 1024K
RUN_LOG_LEVEL INFO
RUN_LOG_FILE_COUNT 10
RUN_LOG_FILE_SIZE 20M
RUN_LOG_FILE_PATH /yasdb/yasdb_data/log/run
USE_LARGE_PAGES FALSE
CONTROL_FILES ('/yasdb/yasdb_data/dbfiles/ctrl1', '/yasdb/yasdb_data/dbfiles/ctrl2', '/yasdb/yasdb_data/dbfiles/ctrl3')
DB_BLOCK_SIZE 8K
DATA_BUFFER_SIZE 256M
WORK_AREA_HEAP_SIZE 512K
WORK_AREA_POOL_SIZE 32M
HA_HEARTBEAT_INTERVAL 3
HA_ELECTION_TIMEOUT 9
HA_ELECTION_ENABLED FALSE
HA_ELECTION_LEADER_LEASE_ENABLED FALSE
REDO_BUFFER_SIZE 8M
REDO_BUFFER_PARTS 4
LARGE_POOL_SIZE 32M
MAX_PRIVATE_TEMP_TABLES 16
VM_BUFFER_SIZE 32M
DBWR_BUFFER_SIZE 4M
UNDO_RETENTION 300
UNDO_SHRINK_ENABLED TRUE
UNDO_SHRINK_INTERVAL 3600
TRANSACTION_LOCK_TIMEOUT 0
DDL_LOCK_TIMEOUT 0
STARTUP_ROLLBACK_PARALLELISM 2
ISOLATION_LEVEL READ_COMMITTED
COMMIT_WAIT WAIT
COMMIT_LOGGING IMMEDIATE
RECOVERY_PARALLELISM 16
CHECKPOINT_INTERVAL 100000
CHECKPOINT_TIMEOUT 300
LISTEN_ADDR 0.0.0.0:1688
REPLICATION_ADDR
CHARACTER_SET UTF8
NATIONAL_CHARACTER_SET UTF16
DBWR_COUNT 2
DB_FILE_NAME_CONVERT
REDO_FILE_NAME_CONVERT
DB_BUCKET_NAME_CONVERT
ARCHIVE_LOCAL_DEST ?/archive
ARCHIVE_DEST_1
ARCHIVE_DEST_2
ARCHIVE_DEST_3
ARCHIVE_DEST_4
ARCHIVE_DEST_5
ARCHIVE_DEST_6
ARCHIVE_DEST_7
ARCHIVE_DEST_8
ARCHIVE_DEST_9
ARCHIVE_DEST_10
ARCHIVE_DEST_11
ARCHIVE_DEST_12
ARCHIVE_DEST_13
ARCHIVE_DEST_14
ARCHIVE_DEST_15
ARCHIVE_DEST_16
ARCHIVE_DEST_17
ARCHIVE_DEST_18
ARCHIVE_DEST_19
ARCHIVE_DEST_20
ARCHIVE_DEST_21
ARCHIVE_DEST_22
ARCHIVE_DEST_23
ARCHIVE_DEST_24
ARCHIVE_DEST_25
ARCHIVE_DEST_26
ARCHIVE_DEST_27
ARCHIVE_DEST_28
ARCHIVE_DEST_29
ARCHIVE_DEST_30
ARCHIVE_DEST_31
ARCHIVE_DEST_32
QUORUM_SYNC_STANDBYS MAJORITY
REQUIRED_SYNC_STANDBYS
DATAFILE_IO_MODE DEFAULT
REDOFILE_IO_MODE DSYNC
DOUBLE_WRITE_ENABLED TRUE
DEFAULT_TABLE_TYPE HEAP
MMS_USE_LARGE_PAGES FALSE
MMS_DATA_LOADERS 4
ARCH_CLEAN_UPPER_THRESHOLD 16G
ARCH_CLEAN_LOWER_THRESHOLD 12G
ARCH_CLEAN_IGNORE_MODE NONE
DATE_FORMAT yyyy-mm-dd
TIME_FORMAT hh24:mi:ss.ff
TIMESTAMP_FORMAT yyyy-mm-dd hh24:mi:ss.ff
YMINTERVAL_FORMAT yy-mm
DSINTERVAL_FORMAT dd hh24:mi:ss.ff
PASSWORD_FILE ?/instance/yasdb.pwd
SQL_PLUGIN NONE
SCOL_DATA_BUFFER_SIZE 128M
SCOL_CACHEABLE_SCAN_ROWS 18446744073709551615
SCOL_DISK_CACHEABLE_SCAN_ROWS 18446744073709551615
SCOL_DATA_PRELOADERS 2
RECYCLEBIN_ENABLED OFF
COLUMNAR_VM_BUFFER_SIZE 2G
COLUMNAR_MATERIAL_PERCENT 80
COLUMNAR_WORK_AREA_HEAP_SIZE 64M
DB_BLOCK_CHECKSUM TYPICAL
BLOCK_REPAIR_ENABLED TRUE
BLOCK_REPAIR_TIMEOUT 60
COMPRESSION UNCOMPRESSED
COMPRESSION_LEVEL LOW
OPTIMIZER_DYNAMIC_SAMPLING 0
LSC_DICTIONARY_CACHE_AUTOEXTEND FALSE
BUCKET_RESERVED_SPACE 1G
DIAGNOSTIC_DEST ?/diag
DIAG_ADR_ENABLED TRUE
COLUMNAR_BULK_SIZE 1024
DEGREE_OF_PARALLEL 1
QUERY_REWRITE_ENABLED FALSE
NODE_ID 1-1:1
CM_ADDR 1-1:1/127.0.0.1:1679
DIN_ADDR 127.0.0.1:1690
DIN_RECONNECT_TIME 5000
DEFAULT_MCOL_TTL 3600
SCOL_WRITE_CACHE_POLICY WRITE_BACK
DS_SCALE_OUT_FACTOR 7
STATISTICS_LEVEL TYPICAL
UNIFIED_AUDITING FALSE
SHARE_POOL_SIZE 256M
CGROUP_FLAG 0
CGROUP_ROOT_DIR /sys/fs/cgroup
RESOURCE_MANAGER_PLAN
JOB_QUEUE_PROCESSES 16
OPEN_CURSORS 310
LSNR_LOG ON
JVM_XMS 512M
JVM_XMX 512M
CLUSTER_DATABASE FALSE
INSTANCE_NAME yasdb
CLUSTER_INTERCONNECT 127.0.0.1:1700
INTERCONNECT_LINKS 2
INTERCONNECT_MESSAGE_POOL 1024:64;512:8800;128:16800;64:32800
INTERCONNECT_RECEIVE_TIMEOUT 5
GRC_TASK_COUNT 2
GCS_TASK_COUNT 3
GLS_TASK_COUNT 2
CLUSTER_SERVICE
CLUSTER_RECONNECT_TIME 5000
YASFS_DATA_DIR +DG0
SESSION_MAX_OPEN_FILES 50
AC_MAX_SOURCE_SLICE_COUNT 20
AC_SLICE_THRESHOLD_SIZE 64M
SSL_CERT_FILE
SSL_KEY_FILE
SSL_DH_PARAM_FILE
SSL_ENABLE OFF
ENABLE_SEPARATE_DUTY FALSE
BLOOM_FILTER_FACTOR .3
ENABLE_SLOW_LOG FALSE
SLOW_LOG_TIME_THRESHOLD 1000
SLOW_LOG_FILE_NAME slow.log
SLOW_LOG_FILE_PATH ?/log/slow
SLOW_LOG_OUTPUT FILE
SLOW_LOG_SQL_MAX_LEN 2000
AUDIT_QUEUE_WRITE TRUE
AUDIT_QUEUE_SIZE 16M
AUDIT_FLUSH_INTERVAL 100
TAB_QUEUE_WINDOW_SIZE 4
DATA_RETENTION 3600
DATA_TRANSFORMER_ENABLED TRUE
SCOL_SLICE_ROWS 8M
COLUMNAR_VM_SWAP_SIZE 200G
BROADCAST_GTS_TIME 5
HA_SSL_ENABLE OFF
EXTSERVER_CONNS 64
DBWR_FLUSH_NEIGHBORS_COUNT 16
ENABLE_DISKCACHE FALSE
ENABLE_ARCH_DATA_IGNORE_BACKUP FALSE
SQL_MAP FALSE
177 rows fetched.
6.4 查看线程信息
SQL> select name,status from v$process;
NAME STATUS
--------------------------------- ---------------------------------
TIMER Working
BUFFER_POOL Working
PRELOADER Working
PRELOADER Working
SMON Working
CKPT Working
DBWR Working
DBWR Working
SCHD_TIMER Working
LISTENER_LOG Working
TCP_LSNR Working
TCP_LSNR Working
HEALTH_MONITOR Working
ROLLBACK Working
ROLLBACK Working
HOT_CACHE_RECYC Working
LOGW Working
GARBAGE_PURGE Working
MMS_PRELOAD Working
XFMR Working
XFMR_WORKER_0 Working
MMON Working
JOB_QUEUE Working
XFMR_WORKER_1 Working
XFMR_WORKER_2 Working
XFMR_WORKER_3 Working
XFMR_WORKER_4 Working
XFMR_WORKER_5 Working
XFMR_WORKER_6 Working
XFMR_WORKER_7 Working
XFMR_WORKER_8 Working
XFMR_WORKER_9 Working
XFMR_WORKER_10 Working
XFMR_WORKER_11 Working
XFMR_WORKER_12 Working
XFMR_WORKER_13 Working
XFMR_WORKER_14 Working
XFMR_WORKER_15 Working
XFMR_WORKER_16 Working
XFMR_WORKER_17 Working
XFMR_WORKER_18 Working
XFMR_WORKER_19 Working
XFMR_WORKER_20 Working
XFMR_WORKER_21 Working
XFMR_WORKER_22 Working
XFMR_WORKER_23 Working
XFMR_WORKER_24 Working
XFMR_WORKER_25 Working
XFMR_WORKER_26 Working
XFMR_WORKER_27 Working
XFMR_WORKER_28 Working
XFMR_WORKER_29 Working
XFMR_WORKER_30 Working
XFMR_WORKER_31 Working
WORKER Working
WORKER Working
WORKER Working
WORKER Working
WORKER Working
59 rows fetched.
6.5 关闭数据库
$ yasql sys/yasdb_123
SQL> shutdown immediate;
6.6 启动数据库
[yashan@alldb scripts]$ yasdb open &
[1] 17462
[yashan@alldb scripts]$ Starting instance open
Instance started
[yashan@alldb scripts]$
7. 数据库卸载
$ yasql sys/yasdb_123
SQL> shutdown immediate;
$ rm - rf /home/yashan/yashandb/yasdb_home
$ rm - rf /home/yashan/yashandb/yasdb_data
vi ~/.bashrc
#删除以下两行
# User specific aliases and functions
[ -f /yasdb/yasdb_home/conf/yasdb.bashrc ] && source /yasdb/yasdb_home/conf/yasdb.bashrc
8.体验总结
崖山(YashanDB)数据库是一个单进程多线程数据库。与Oracle近似的内存结构、存储结构,相同的V、GV、DBA、ALL_视图,对于Oracle DBA来说非常友好,非常容易上手。
崖山(YashanDB)数据库部署非常简单,对资源要求非常低,数据库开发、运维人员能轻松在普通笔记本上搭建测试环境进行开发运维测试,非常Nice。
笔者在2c,16g,ssd磁盘的虚拟机中安装了Oracle19c,YashanDB(崖山),通过benchmarksql5.0轮留进行tpcc性能测试,10仓、100并发下YashanDB(崖山)TPMC达18450.24,Oracle为12278.83,性能强劲的嘞。
总结:YashanDB(崖山)在国产数据库中非常有竞争力,易上手,值得一学。
9.附件:TPCC测试结果
注:TPCC测试受数据库参数、主机性能等影响,此结果仅代表笔者虚拟机场景的当次表现,如有不妥之处,请指正。