The running of the OceanBase Database servers relies on the data disk, the clog disk, and the installation disk of OceanBase Database. If you are an individual user, you can put all the data on a single disk and skip this topic. If you are an enterprise user, we recommend that you separately mount your data to three disks.
If you do not have three disks for a server, or if you are using a Redundant Array of Independent Disks (RAID), you need to partition the disk or the logical volume of the disk array. We recommend that you use the following partitioning scheme:
Data disk
The data disk is used to store baseline data, and its path is specified by the
data_dirparameter. When you start the OceanBase cluster for the first time,${data_dir}/{sstable,slog}will be created automatically. The size of the data disk is determined by thedatafile_disk_percentage/datafile_sizeparameters. Additionally, after deployment, you can perform dynamic expansion of disk files by using thedatafile_nextanddatafile_maxsizeparameters. For more information, see Configure automatic scale-out of disk space for data files.Note
The current version of OceanBase Database supports separating
slogfrom the data disk, meaning thatslogand data files do not need to be on the same disk. For more information about the installation directory of OceanBase Database, see Installation directory structure of an OBServer node.Clog disk
The path of the clog disk is specified by the
clog_dirparameter. We recommend that you set the size of the clog disk to three to four times or more of the memory size of OceanBase Database. When you start the OceanBase cluster for the first time,${clog_dir}will be created automatically. The clog disk contains multiple fixed-size files, and the clog files can be automatically created and cleared based on your needs. Automatic clearance is triggered when the clog reaches 80% of the total disk capacity. However, the clog files can be deleted only when the corresponding memory data has been merged into the baseline data.For a given amount of data, the size of the clog is approximately three times the size of the memory data. Therefore, the maximum space required for the clog disk is directly proportional to the total amount of data after two major compactions. Empirical formula: clog file size = 3 to 4 times the upper limit of incremental data memory.
Installation disk of OceanBase Database
The path of the installation disk of OceanBase Database is specified by the
home_pathparameter. We recommend that you reserve at least 200 GB of space for the installation disk of OceanBase Database to save logs for seven days or more. The RPM package installation directory of OceanBase Database is located under${home_path}. The baseline data files and clog files are mapped to the independent data disk and clog disk through soft links. The operational logs of OceanBase Database are located under${home_path}/log. The operational logs will keep growing, and OceanBase Database cannot automatically delete the operational logs. Therefore, you need to regularly delete the operational logs.
Mount disks
Mounting requirements
The disk mounting requirements of an OCP server are listed in the following table.
Mount pointSizePurposeFile system format/home 100 GB to 300 GB The operational log disk of each component ext4 or xfs is recommended /data/log1 3 to 4 times the memory size allocated to observer The clog disk of the OCP meta database ext4 or xfs is recommended /data/1 Depends on the size of the data to store The data disk of the OCP meta database ext4 or xfs is recommended The disk mounting requirements of an OBServer node are listed in the following table.
DirectorySizePurposeFile system format/home 100 GB to 300 GB The installation disk of observer ext4 or xfs is recommended /data/log1 3 to 4 times the memory size allocated to observer The log disk of the observer process ext4 or xfs is recommended /data/1 Depends on the size of the data to store The data disk of the observer process ext4 or xfs is recommended Note
We recommend that the root directory be at least 50 GB. If you use LVM, we recommend that you use the striping parameter when creating a volume. Example:
lvcreate -n data -L 3000G obvg --stripes=3 --stripesize=128.In the production environment, we recommend that you use different disks for the data disk, the log disk, and the installation disk to avoid performance issues.
Mounting operation
Mounting disks must be performed under the root user. There are two ways to mount disks. You can choose an appropriate one based on your actual situation:
- Mount disks by using the LVM tool (recommended).
- Mount disks by using the fdisk tool.
View the disk information
Use the
fdisk -lcommand to identify the available disks and partitions, and confirm the target device (such as/dev/sdb1).[root@test001 ~]# fdisk -l(Optional) Install the LVM tool
If LVM is not preinstalled, run the following command to install LVM. If LVM has been installed, skip this step.
Debian/Ubuntu
[root@test001 ~]# apt-get install lvm2CentOS/RHEL
[root@test001 ~]# yum install lvm2
Create a physical volume (PV)
Initialize the partition as a physical volume.
Notice
When a partition is initialized as a physical volume, the partition is reformatted, and the data will be lost. Proceed with caution.
[root@test001 ~]# pvcreate /dev/sdb1After the creation, you can run the
pvscommand to verify the physical volume creation result.Create a volume group (VG)
Merge multiple physical volumes into a VG.
[root@test001 ~]# vgcreate vg01 /dev/sdb1 /dev/sdc1After the merge, you can run the
vgscommand to view the volume group information.Create a logical volume (LV)
Divide a logical volume of 100 GB from the VG. This is only an example, and the size of the logical volume can be set based on the actual situation.
[root@test001 ~]# lvcreate -L 100G -n lv01 vg01After the creation, you can run the
lvscommand to view the logical volume information.Format and mount
Format the logical volume as an ext4 file system.
[root@test001 ~]# mkfs.ext4 /dev/vg01/lv01Create a mount point.
[root@test001 ~]# mkdir -p /data/1Mount the logical volume temporarily.
[root@test001 ~]# mount /dev/vg01/lv01 /data/1
Set automatic mounting on startup
Edit the
/etc/fstabfile and add the mounting configuration:[root@test001 ~]# vim /etc/fstabAdd the following content to the
/etc/fstabfile:/dev/vg01/lv01 /data/1 ext4 defaults,noatime,nodiratime,nodelalloc,barrier=0 0 0
View the disk information
Use the
fdisk -lcommand to identify the available disks and partitions, and confirm the target device (such as/dev/sdb1).[root@test001 ~]# fdisk -lCreate a partition
Use the fdisk tool to create a new partition. For example, run
fdisk /dev/sdb1, enternto create a primary partition, and finally save the changes (w).[root@test001 ~]# fdisk /dev/sdb1Format and mount
Format the partition as an ext4 file system.
[root@test001 ~]# mkfs.ext4 /dev/sdb1Create a mount point.
[root@test001 ~]# mkdir -p /data/1Mount the partition temporarily.
[root@test001 ~]# mount /dev/sdb1 /data/1
Set automatic mounting on startup.
Edit the
/etc/fstabfile and add the mounting configuration:[root@test001 ~]# vim /etc/fstabAdd the following content to the
/etc/fstabfile:/dev/sdb1 /data/1 ext4 defaults,noatime,nodiratime,nodelalloc,barrier=0 0 0
View the disks
After the disks are mounted, run the following command to check the disk partitioning:
[root@test001 ~]# df -h
The returned result is as follows:
Filesystem Size Used Avail Use% Mounted on
devtmpfs 31G 0 31G 0% /dev
tmpfs 31G 0 31G 0% /dev/shm
tmpfs 31G 516K 31G 1% /run
tmpfs 31G 0 31G 0% /sys/fs/cgroup
/dev/vda1 493G 171G 302G 37% /
tmpfs 6.2G 0 6.2G 0% /run/user/0
/dev/sdb1 984G 77M 934G 1% /data/1
/dev/vdc1 196G 61M 186G 1% /data/log1
/dev/vdb1 492G 73M 467G 1% /home/admin/oceanbase
Result description:
/data/1is the data disk, which is 1 TB in size./data/log1is used to store logs./home/admin/oceanbaseis used to store the binary files and operational logs of OceanBase Database.
Make sure that the disks corresponding to data_dir, redo_dir, and home_path in the configuration file have been mounted. The directories corresponding to data_dir and redo_dir must be empty, and the disk usage of the directory corresponding to data_dir must be lower than 4%.
Set directory permissions
After the disks are mounted, you need to check the permissions of the directories corresponding to the disk mounting. You can run the following command to check the directory permissions of the cluster-related files.
Taking the data directory as an example:
[root@test001 data]# ls -al
The returned result is as follows, indicating that the owner of the directory is the admin user in the admin group:
drwxr-xr-x 2 admin admin 4096 02/09 18:43 .
drwxr-xr-x 2 admin admin 4096 02/09 18:43 log1
If you find that the admin user does not have the permissions on the related files, you can run the following commands to change the file owner:
[root@test001 ~]# chown -R admin:admin /data/log1
[root@test001 ~]# chown -R admin:admin /data
Here, /data/log1 and /data are example mount directories. You need to replace them with your actual mount directories.
