The server of OceanBase Database depends on data disks, transaction log disks, and the installation disk of OceanBase Database. For personal trial scenarios, you can place all data on one disk and skip this step. For production environments, it is recommended to mount data to three separate disks.
If your machine does not have three disks, or if you are using a RAID disk array, you need to partition the disks or the logical volumes of the disk array. It is recommended that you use the following partitioning scheme:
Data disk
The data disk is used to store baseline data. The path is specified by the configuration parameter
data_dir. When you first start an OceanBase cluster,${data_dir}/{sstable,slog}will be automatically created. The size of the data disk is determined by thedatafile_disk_percentage/datafile_sizeparameters. You can also perform dynamic expansion of disk files after deployment is complete using thedatafile_nextanddatafile_maxsizeconfiguration items. For more details, see Configure dynamic expansion of disk data files.Note
The current version of OceanBase Database supports separating
slogfrom the data disk. That is,slogand data files do not need to be on the same disk. For more information about the installation directory of OceanBase Database, see OBServer node installation directory structure.Transaction log disk
The path of the transaction log disk is specified by the configuration parameter
clog_dir. It is recommended to set the size of the transaction log disk to 3 to 4 times or more of the memory of OceanBase Database. When you first start an OceanBase cluster,${clog_dir}will be automatically created. The transaction log disk contains multiple fixed-size files, and you can automatically create and clear transaction logs as needed. Automatic clearing is triggered when transaction logs reach 80% of the total disk capacity. However, transaction logs can only be deleted after the memory data corresponding to those logs has been merged into the baseline data.For the same amount of data, the size of transaction logs is approximately three times the size of memory data. Therefore, the upper limit of space required for the transaction log disk is proportional to the total data volume after two major compactions. Empirical formula: Transaction log file size = 3 to 4 times the upper limit of incremental data memory.
OceanBase Database installation disk
The path of the OceanBase Database installation disk is specified by the configuration parameter
home_path. It is recommended to reserve at least 200 GB of space for the OceanBase Database installation disk to store logs for 7 days or more. The installation directory of the OceanBase Database RPM package is located under${home_path}. Here, baseline data files and transaction log files are linked via soft links to the independent data disk and transaction log disk, respectively. The operation logs of OceanBase Database are located under${home_path}/log. Operation logs continue to grow, and OceanBase Database cannot delete them automatically, so you need to delete them periodically.
Disk mounting
Mounting requirements
The disk mount points for the OCP server are specified in the following table.
Mount pointSizePurposeFile system format/home 100 GB to 300 GB Disk for component runtime logs ext4 or xfs recommended /data/log1 3 to 4 times the memory size allocated to observer Disk for OCP MetaDB logs ext4 or xfs recommended /data/1 Depends on the amount of data to be stored Disk for OCP MetaDB data ext4 or xfs recommended The disk mount points for the OBServer node are specified in the following table.
DirectorySizePurposeFile system format/home 100 GB to 300 GB Disk for observer database installation ext4 or xfs recommended /data/log1 3 to 4 times the memory size allocated to observer Disk for observer process logs ext4 or xfs recommended /data/1 Depends on the amount of data to be stored Disk for observer process data ext4 or xfs recommended Note
We recommend that you set the root directory size to at least 50 GB. If you use LVM, we recommend that you create it with the striped parameter. Example:
lvcreate -n data -L 3000G obvg --stripes=3 --stripesize=128.We recommend that you use different disks for the data disk, log disk, and installation disk in a production environment to avoid performance issues.
Mounting procedure
Disk mounting must be performed as the root user. You can choose one of the following two methods based on your actual situation:
- Use LVM tools to mount disks (recommended).
- Use the fdisk tool to mount disks.
View disk information
Run the
fdisk -lcommand to identify available disks and partitions, and confirm the target device (for example,/dev/sdb1).[root@test001 ~]# fdisk -l(Optional) Install LVM tools
If LVM is not pre-installed, run the following command to install it. If LVM is already installed, skip this step.
For Debian/Ubuntu systems
[root@test001 ~]# apt-get install lvm2CentOS/RHEL systems
[root@test001 ~]# yum install lvm2
Create a physical volume (PV)
Initialize the partition as a physical volume.
Notice
Initializing a partition as a physical volume will reformat the partition (data will be lost). Proceed with caution.
[root@test001 ~]# pvcreate /dev/sdb1After creation, you can run the
pvscommand to verify the physical volume creation result.Create a volume group (VG)
Combine multiple physical volumes into one VG.
[root@test001 ~]# vgcreate vg01 /dev/sdb1 /dev/sdc1After combination, you can run the
vgscommand to view the volume group information.Create a logical volume (LV)
Allocate 100 GB of logical volume space from the VG. This is just an example; you can set the logical volume size according to your actual needs.
[root@test001 ~]# lvcreate -L 100G -n lv01 vg01After creation, you can run the
lvscommand to view the logical volume information.Format and mount
Format as an ext4 file system
[root@test001 ~]# mkfs.ext4 /dev/vg01/lv01Create a mount point
[root@test001 ~]# mkdir -p /data/1Temporarily mount
[root@test001 ~]# mount /dev/vg01/lv01 /data/1
Set up automatic boot-time mounting
Edit the
/etc/fstabfile and add the following mount configuration:[root@test001 ~]# vim /etc/fstabAdd the following line to the
/etc/fstabfile:/dev/vg01/lv01 /data/1 ext4 defaults,noatime,nodiratime,nodelalloc,barrier=0 0 0
Check disk information
Run the
fdisk -lcommand to identify available disks and partitions, and confirm the target device (for example,/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 then save the changes (w).[root@test001 ~]# fdisk /dev/sdb1Format and mount
Format the disk as an ext4 filesystem.
[root@test001 ~]# mkfs.ext4 /dev/sdb1Create a mount point.
[root@test001 ~]# mkdir -p /data/1Perform a temporary mount.
[root@test001 ~]# mount /dev/sdb1 /data/1
Set up automatic boot-time mounting.
Edit the
/etc/fstabfile and add the following mount configuration:[root@test001 ~]# vim /etc/fstabAdd the following line to the
/etc/fstabfile:/dev/sdb1 /data/1 ext4 defaults,noatime,nodiratime,nodelalloc,barrier=0 0 0
Check disks
After disks are mounted, you can run the following command to check the disk partitioning:
[root@test001 ~]# df -h
The return 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
The result description is as follows:
/data/1is the data disk with a size of 1 TB./data/log1stores logs./home/admin/oceanbasestores the binary files and runtime logs of OceanBase Database.
Ensure 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 should be empty, and the disk usage of the directory corresponding to data_dir must be less than 4%.
Set directory permissions
After disks are mounted, you need to check the permissions of the directories where the disks are mounted. You can run the following command to view the permissions of the cluster-related file directories.
Here is an example using the data directory:
[root@test001 data]# ls -al
The return result is as follows, indicating that the directory owner is the admin user of the admin group:
drwxr-xr-x 2 admin admin 4096 Feb 9 18:43 .
drwxr-xr-x 2 admin admin 4096 Feb 9 18:43 log1
If you find that the admin user does not have the necessary permissions for the related files after checking the directory permissions, you can run the following command 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.
