Posts

Showing posts from November, 2019

Setup distributed replicated highly available nfs server with drbd and pacemaker on centos7

-------- Setup DRBD two node cluster ---------- Importelrepo gpgkey rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org Install elrepo rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-3.el7.elrepo.noarch.rpm --Task to perform on both node Install drbd pkg yum install -y kmod-drbd84 drbd84-utils enable iptable rules firewall-cmd --permanent --add-rich-rule='rule family="ipv4" source address="192.168.122.102" port port="7789" protocol="tcp" accept' firewall-cmd --reload Take backup of original config file mv /etc/drbd.d/global_common.conf /etc/drbd.d/global_common.conf.orig create new file with your configuration vim /etc/drbd.d/global_common.conf --place bellow content in file global {  usage-count  yes; } common {  net {   protocol C;   sndbuf-size 0;  } } disk {   fencing resource-only;   } handlers {   fence-peer “/usr/lib/drbd/crm-fence-peer.sh”;   after-resync-target “/usr/lib/drbd/cr

Setup Docker containerized apache guacamole on centos 7 host.

Lets setup apache guacamole as your web based rdp vnc ssh gateway. This is helpfull in case of your corporate environment also where you need to access your intranet network using port 443 only. Install docker if you dont have already  yum install docker -y  systemctl enable docker  systemctl start docker Pull required container images  docker pull guacamole/guacamole  docker pull guacamole/guacd  docker pull mysql/mysql-server  Now run containers -  docker run --rm guacamole/guacamole /opt/guacamole/bin/initdb.sh --mysql > initdb.sql  docker run --name mysql -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_ONETIME_PASSWORD=yes -d mysql/mysql-server  docker logs mysql  docker cp initdb.sql mysql:/guac_db.sql  docker exec -it mysql bash Now setup required mysql database within container.  bash-4.2# mysql -u root -p Enter password: Welcome to the MySQL monitor.  Commands end with ; or \g. Your MySQL connection id is 11 Server version: 5.7.20 Copyright (c) 2000, 2017, Oracle a

backup , restore shrink xfs filesystem.

xfs is highly scalable filesystem introduced  in redhat 7 release as default filesystem. Due to its scalability feature, unlike ext3,4 filesystem you cannot shrink or reduce xfs filesystem. instead it can be grown / extend  online quickly using xfs_growfs command. xfs ships with a backup and restore utility also which helps to backup any xfs formated mount points such as /home  or /var very easily.  Restore is also very easy. So where you cannot directly reduce the size or shrink xfs filesystem. you can use the xfs builtin backup restore feature to backup data delete,reduce partition  and then restore data back. ( In case of bigger data volume this may be a challange, use in your own risk) in my example i wants my partition to be shrink is /home Install utility if you dont have # yum install xfsdump Backup : # xfsdump -l 0 -f /home.img /dev/myvg/lvhome in above -l is level of backup  0 means full backup. this will backup lvhome logical volume in an image /home.img no

How to shrink KVM/qemu partition and image size

This article is about shrinking a filesystem and partition of a qemu kvm supported image file. Case: VM Disk image file name is vol1.raw Image file is a raw format file, so if you have a qcow2 format image file convert first in raw format using bellow command - # qemu-img convert vol1.qcow2   vol1.raw just for info if you wish to convert back :) # qemu-img convert -p -f raw -O qcow2 vol1.raw vol2.qcow2 Now coming to shrinking part . collect the filesystem consumed with df -h command so assume in my case i have 1.2 Gb used in OS out of 10GB and rest 8.8 Gb is free. Now i want the size of  disk image to be as 3 GB only We need another kvm VM in order to attach this raw image and perform file system shrink Let assume this raw image is attached as /dev/vdb  first perform a force filesystem check # e2fsck -f /dev/vdb1 Now resize the filesystem ( which is ext4 in my case. xfs cannot be reduced ) # resize2fs /dev/vdb1 2G  ( exact size of partition/disk that you want