Diving into Disk Management for Bitbucket Data Center on CentOS8/RHEL8

Ahmet Kasım Erbay
4 min readJan 15, 2024

--

As I delve deeper into my role, navigating the intricate world of CentOS/RHEL, I’ve realized the significance of effective disk management and mounting options — especially for Bitbucket Data Center in a cluster environment. One of the key elements in this process is the Network File System (NFS), which enables file sharing across networks in a client-server model. NFS offers the flexibility to instantly share files among systems, a critical feature for our setup. For more on NFS, you can refer to this.

Setting Up NFS for Bitbucket Data Center

Following the installation of OpenSearch for Bitbucket Data Center, the next essential step is configuring the Shared File System using NFSv3. Below are the detailed steps to set up NFS on both server and client sides. Note that some configurations might need to be adjusted according to your specific system requirements.

Server-Side Configurations

Start by creating a customized disk setup. Custom configurations often provide better manageability and a broader understanding of application systems. Here’s my current mount setup:

[atlbender@shared_file_server ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80GB 0 disk
|-sda1 8:1 0 20GB 0 disk /boot/efi
|-sda2 8:2 0 20GB 0 disk /boot
|-sda3 8:3 0 40GB 0 disk
|-vgroot-root 253:0 0 8GB 0 lvm /
|-vgroot-swap 253:1 0 8GB 0 lvm [SWAP]
|-vgroot-home 253:2 0 8GB 0 lvm /home
|-vgroot-var 253:3 0 8GB 0 lvm /var
|-vgroot-tmp 253:4 0 8GB 0 lvm /tmp
sdb 8:16 0 100GB 0 disk
|-vgappdata-lvappdata 253:2 0 100GB 0 lvm /appdata
sr0 11:0 1 1024MB 0 rom

Next, unmount and remove the old mount space to create a new directory for Bitbucket operations:

[atlbender@shared_file_server ~]# umount /appdata
[atlbender@shared_file_server ~]# lvremove lvappdata
[atlbender@shared_file_server ~]# vgremove vgappdata

Create Bitbucket shared home directory:

[atlbender@shared_file_server ~]# mkdir -p /shareddata

Create a logical volume and volume group for mounting:

[atlbender@shared_file_server ~]# vgcreate vg_shareddata /dev/sdb
[atlbender@shared_file_server ~]# lvcreate -n lv_shareddata -l 100%FREE vg_shareddata

Format the new volume with the XFS file system:

[atlbender@shared_file_server ~]# mkfs.xfs /dev/mapper/vg_shareddata-lv_shareddata

Verify the changes:

[atlbender@shared_file_server ~]# lsblk
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 80GB 0 disk
|-sda1 8:1 0 20GB 0 disk /boot/efi
|-sda2 8:2 0 20GB 0 disk /boot
|-sda3 8:3 0 40GB 0 disk
|-vgroot-root 253:0 0 8GB 0 lvm /
|-vgroot-swap 253:1 0 8GB 0 lvm [SWAP]
|-vgroot-home 253:2 0 8GB 0 lvm /home
|-vgroot-var 253:3 0 8GB 0 lvm /var
|-vgroot-tmp 253:4 0 8GB 0 lvm /tmp
sdb 8:16 0 100GB 0 disk
|-vg_shareddata-lv_shareddata 253:2 0 100GB 0 lvm /shareddata
sr0 11:0 1 1024MB 0 rom

Install and configure the NFS server:

[atlbender@shared_file_server ~]# yum install nfs-utils -y
[atlbender@shared_file_server ~]# systemctl start nfs-server rpcbind
[atlbender@shared_file_server ~]# systemctl enable nfs-server rpcbind

Update /etc/fstab for persistent mounts:

[atlbender@shared_file_server ~]# echo "/dev/mapper/vg_shareddata-lv_shareddata /shareddata xfs defaults 0 0" | sudo tee -a /etc/fstab

# Changes to /etc/fstabrequires daemon-reload
[atlbender@shared_file_server ~]# systemctl daemon-reload

Configure NFS exports:

[atlbender@shared_file_server ~]# echo "/shareddata node_1(rw,sync)" | sudo tee -a /etc/exports
[atlbender@shared_file_server ~]# echo "/shareddata node_2(rw,sync)" | sudo tee -a /etc/exports
[atlbender@shared_file_server ~]# exportfs -var

Here are the explanations for options,

  • -v: Be verbose
  • -a: Export or unexport all idrectories according to /etc/exports
  • -r: Reexport all directories, syncronize /var/lib/nfs/etab with /etc/exports . This option removes any entries from the kernel export tabel which are no longer available.

Mount on System Reboot

The export table of the server is enriched by /etc/fstab . And mount -a command takes this file into account in boot process.

This is why we use the below command to make changes persistent,

[atlbender@shared_file_server ~]# mount -a

Check for Exports

Run the below command to see the exported clients,

[atlbender@shared_file_server ~]# showmount -e localhost
Export list for localhost:
/shareddata <comma_seperated_list_of_NODES>

Ensure the atlbitbucket user exists and has appropriate permissions:

[atlbender@shared_file_server ~]# adduser -m atlbitbucket
[atlbender@shared_file_server ~]# chown -R atlbitbucket:atlbitbucket /shareddata
[atlbender@shared_file_server ~]# chmod 777 /shareddata/
[atlbender@shared_file_server ~]# su - atlbitbucket
[atlbender@shared_file_server ~]$ echo "umask 0027" > ~/.bashrc

Client Side Configurations

NOTE: You need to complete the “Install Bitbucket” section on Install and Bitbucket Data Center paper. If not, do not move on to the next section!

Firstly, make sure that nfs-client.target service is up and enabled.

We need to create a mount point on the client side. After this configuration we expect to see the changes from one node on other nodes and NFS server.

[atlbender@cluster_node ~]# mkdir -p /shareddata

We will also adopt /etc/fstab on the nodes,

[atlbender@cluster_node ~]#echo "shared_file_server:/shareddata /var/atlassian/application-data/bitbucket/shared/ nfs rw,nfsvers=3,lookupcache=pos,noatime,intr,rsize=32768,wsize=32768,_netdev 0 0" >> /etc/fstab
[atlbender@cluster_node ~]# systemctl daemon-reload
[atlbender@cluster_node ~]# mount -a

You can test your configurations by manipulating the /shareddata folder on NFS server by seeing the same changes on nodes’ /var/atlassian/applicaiton-data/bitbucket/shared folder.

Conclusion

With these configurations, your Bitbucket Data Center should be well-equipped with NFS for optimal performance. Feel free to leave comments or reach out with any questions. Happy coding!

--

--