You are here

Part15: Xfs Configuration. My Study Notes for Red Hat Certificate of Expertise in Clustering and Storage Management Exam (EX436)

working with XFS:

create a filesystem:
mkfs.xfs -f /dev/mapper/disk1p0 --------> with the -f option if there is a previous fs on the blockdevice it overwrites it
file system with external journal:
mkfs.xfs -l logdev=/dev/sda1 /dev/sdb
if we use and external logdevice we need to also add it to the /etc/fstab as a mount option -o logdev=/dev/sda1

XFS canot be shrunk, you can only expand the fs.

We are going to add the xfs filesystem from our nfs resource to HA LVM, we make a backup of the FS:

[root@centos-clase2 nfs-export]# tar -Zcvf backup.tar.xz /nfs-export/
[root@centos-clase2 nfs-export]# mv backup.tar.xz /root/

now we stop the resource:

[root@centos-clase2 ~]# clusvcadm -d service:hanfs
Local machine disabling service:hanfs...Success
[root@centos-clase2 ~]#

We create the lvm infrastructure:
[root@centos-clase2 ~]# pvcreate /dev/mapper/clusterhd0p3
Physical volume "/dev/mapper/clusterhd0p3" successfully created
[root@centos-clase2 ~]# vgcreate -c y /dev/vghanfs /dev/mapper/clusterhd0p3
Clustered volume group "vghanfs" successfully created
[root@centos-clase2 ~]# lvcreate -L900M -n lvnfs /dev/vghanfs
Logical volume "lvnfs" created
[root@centos-clase2 ~]# lvcreate -L60M -n lvxfslog /dev/vghanfs
Logical volume "lvxfslog" created

We install xfsprogs on all nodes:

[root@centos-clase2 ~]# yum install xfsprogs

[root@centos-clase2 ~]# mkfs.xfs -l logdev=/dev/vghanfs/lvxfslog /dev/vghanfs/lvnfs
meta-data=/dev/vghanfs/lvnfs isize=256 agcount=4, agsize=57600 blks
= sectsz=512 attr=2, projid32bit=0
data = bsize=4096 blocks=230400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =/dev/vghanfs/lvxfslog bsize=4096 blocks=15360, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

We now our going to configure our new resource, we delete our old resource:

[root@centos-clase2 ~]#ccs -h centos-clase1 --rmresource fs name=nfsfs
[root@centos-clase2 ~]# ccs -h centos-clase1 --addresource lvm name="vghanfsre" vg_name="vghanfs"
[root@centos-clase2 ~]# ccs -h centos-clase1 --addresource fs name=nfsfs force_fsck=off force_unmount=on fstype=xfs device=/dev/mapper/vghanfs-lvnfs mountpoint=/nfs-export fsid=45678 options="logdev=/dev/mapper/vghanfs-lvxfslog"
[root@centos-clase2 ~]#

We have to manually add to the cluster.conf file the lvm resource and the fs as a child:

aplicamos cambios:

[root@centos-clase2 ~]# ccs -h centos-clase1 --sync --activate

We mount the fs to restore the data:
[root@centos-clase2 ~]# mount -o "logdev=/dev/mapper/vghanfs-lvxfslog" /dev/mapper/vghanfs-lvnfs /nfs-export
[root@centos-clase2 ~]# tar -Zxvf backup.tar.xz

Now we umount,deactivate the vg and start the service:
[root@centos-clase1 ~]# clusvcadm -e service:hanfs
Local machine trying to enable service:hanfs...Success
service:hanfs is now running on centosclu1hb1

[root@centos-clase1 ~]# mount | grep -i nfs
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)
/dev/mapper/vghanfs-lvnfs on /nfs-export type xfs (rw,logdev=/dev/mapper/vghanfs-lvxfslog)
/nfs-export/.clumanager/nfs/statd on /var/lib/nfs/statd type none (rw,bind)
nfsd on /proc/fs/nfsd type nfsd (rw)

Extending a XFS filesystem:

[root@centos-clase1 ~]# vgs
VG #PV #LV #SN Attr VSize VFree
vg_rootvg 1 4 0 wz--n- 19.59g 6.88g
vg_rootvg 1 4 0 wz--n- 19.59g 6.88g
vgcluster 1 1 0 wz--nc 1016.00m 616.00m
vghanfs 1 2 0 wz--nc 1.14g 212.00m
vgsamba 2 1 0 wz--nc 864.00m 164.00m
[root@centos-clase1 ~]# lvextend -L+200M /dev/mapper/vghanfs-lvnfs
Extending logical volume lvnfs to 1.07 GiB
Logical volume lvnfs successfully resized
[root@centos-clase1 ~]# xfs_growfs -n /nfs-export -----> with the -n option you do a test no changes are made to disk
meta-data=/dev/mapper/vghanfs-lvnfs isize=256 agcount=4, agsize=57600 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=230400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =external bsize=4096 blocks=15360, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
[root@centos-clase1 ~]# xfs_growfs /nfs-export
meta-data=/dev/mapper/vghanfs-lvnfs isize=256 agcount=4, agsize=57600 blks
= sectsz=512 attr=2
data = bsize=4096 blocks=230400, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0
log =external bsize=4096 blocks=15360, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0
xfs_growfs: log growth not supported yet
data blocks changed from 230400 to 281600
[root@centos-clase1 ~]# df -h | grep -i nfs
/dev/mapper/vghanfs-lvnfs
1.1G 33M 1.1G 3% /nfs-export

Repairing a XFS filesystem:

The filesystem has to be unmounted, otherwise the command will fail, we can also use the -n option to do a read only test of the operation

[root@centos-clase1 ~]# clusvcadm -d service:hanfs
Local machine disabling service:hanfs...Success
[root@centos-clase1 ~]# vgchange -a y /dev/vghanfs
2 logical volume(s) in volume group "vghanfs" now active
[root@centos-clase1 ~]# xfs_repair -l /dev/vghanfs/lvxfslog /dev/vghanfs/lvnfs
Phase 1 - find and verify superblock...
Phase 2 - using external log on /dev/vghanfs/lvxfslog
- zero log...
- scan filesystem freespace and inode maps...
- found root inode chunk
Phase 3 - for each AG...
- scan and clear agi unlinked lists...
- process known inodes and perform inode discovery...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
- agno = 4
- process newly discovered inodes...
Phase 4 - check for duplicate blocks...
- setting up duplicate extent list...
- check for inodes claiming duplicate blocks...
- agno = 0
- agno = 1
- agno = 2
- agno = 3
- agno = 4
Phase 5 - rebuild AG headers and trees...
- reset superblock...
Phase 6 - check inode connectivity...
- resetting contents of realtime bitmap and summary inodes
- traversing filesystem ...
- traversal finished ...
- moving disconnected inodes to lost+found ...
Phase 7 - verify and correct link counts...
done

If there is no way to repair the filesystem we can use the -L option to empty the dirty log, we loose all the data that was in the dirty log:

[root@centos-clase1 ~]# xfs_repair -L -l /dev/vghanfs/lvxfslog /dev/vghanfs/lvnfs

[root@centos-clase1 ~]# vgchange -a n /dev/vghanfs
0 logical volume(s) in volume group "vghanfs" now active
[root@centos-clase1 ~]# clusvcadm -e service:hanfs
Local machine trying to enable service:hanfs...Success
service:hanfs is now running on centosclu1hb1

Defrag XFS filesystem with xfs_fsr if run without arguments it defrags all files in all xfs filesystem on the server:

[root@centos-clase1 ~]# xfs_fsr
xfs_fsr -m /etc/mtab -t 7200 -f /var/tmp/.fsrlast_xfs ...
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
/nfs-export start inode=0
Completed all 10 passes

We can also point the file or file system we want to defrag, because these are long operations, we can specify a time in seconds with the -t option (default 2 hours):

[root@centos-clase1 ~]# xfs_fsr -t 180 /nfs-export
/nfs-export start inode=0

you can interrup a defrag process with ctrl+c , and it will continue where it stoped once resumed, it saves its defrag processe in the file /var/tmp/.fsrlast_xfs

you can check file fragmentention with the linux command filefrag, here we can see after the defrag how it was able to move for example file hola-4 into one bif extentm insted of 3 like before:

[root@centos-clase1 nfs-export]# filefrag hola*
hola-1: 2 extents found
hola-2: 2 extents found
hola-3: 2 extents found
hola-4: 3 extents found
[root@centos-clase1 nfs-export]# xfs_fsr /nfs-export/
/nfs-export start inode=0
[root@centos-clase1 nfs-export]#
[root@centos-clase1 nfs-export]#
[root@centos-clase1 nfs-export]# filefrag hola*
hola-1: 1 extent found
hola-2: 2 extents found
hola-3: 2 extents found
hola-4: 1 extent found

Unix Systems: 

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.
By submitting this form, you accept the Mollom privacy policy.

Fatal error: Class CToolsCssCache contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (DrupalCacheInterface::__construct) in /homepages/37/d228974590/htdocs/sites/all/modules/ctools/includes/css-cache.inc on line 52