28 July 2020

LVM, add new partition to extend lv(logical volume)

Concept:

- has 3 logical layer
-- pv(physical volume)
       partition to be use for LVM
-- gv(group volume)
       group of partition(pv) seen as 1 big harddisk. One system/OS could have multiple gv
-- lv(logical volume)
       lv to gv, is as partition to harddisk




To extend partition(lvm), by adding new partition to be part of the lvm

1- create partition on new drive
     

2- register the partition as pv
      pvcreate /dev/sdb1
      pvdisplay



3- add the pv  to be a member of on of the gv
       use vgdisplay to check name existing volume group(vg)

       vgextend _name_of_volume_group_ /dev/sdb1



4-  extend the current lvm to utilize the free space in gv
       lvm to gv is as a partition to harddisk. At this stage, our gv size has increase. So we have oppurtunity to increase size of the lvm base on free size on the gv.

       use lvdisplay to check LV_path

      lvextend -l +100%FREE __LV_path__
        or
       lvextend -L +100G __LV_path__



5- extend filesystem
       resize2fs /dev/mapper/__LV_Name__





ref:
1- https://www.krenger.ch/blog/linux-lvm-how-to-adding-a-new-partition/

23 July 2020

redis 101


list all keys
redis-cli
> keys *




count item in keys
> llen key_name



> type key



if type is hash, then use hgetall to view
>hgetall key








19 July 2020

force client close connection tcp reset

I have ssh client connect to my server for reverse tunnel.

But sometime the connection idle(I cant ssh to the tunnel(no respond)).
So need to find a way to force client close the connection. (my script on the client will reconnect everytime connection closed)


If I just kill the process on the server, by looking the process id via 'netstat -punat', the process will terminated. But the client does not re-initiate the connection. I believe, on the client side, the process still somehow believe the connection is still on going.
Thus, this not is my attempt to find a solution how to safely force the client to close the connection, so that my script will re-connect back to the server.



First suggestion:
On linux kernel >= 4.9 you can use the ss command from iproute2 with key -K
ss -K dst 192.168.1.214 dport = 49029

  the kernel have to be compiled with CONFIG_INET_DIAG_DESTROY option enabled.
Unfortunately this method is not workable on my server, maybe the kernel no compiled with those features


2nd approach:
Using killcx
On centos:
yum --enablerepo=extras install epel-release
yum install perl-Net-IP

yum install cpanspec


ref: https://unix.stackexchange.com/questions/71940/killing-tcp-connection-in-linux

ref 2: https://superuser.com/questions/127863/manually-closing-a-port-from-commandline/668155#668155

ref3: https://www.tecmint.com/install-perl-modules-using-cpan-on-centos/

git tag



Get all tags from remote repo
$ git fetch --all --tags
List all tags:
$git tag


Checkout tag
$ git checkout tags/_tag-name_ -b __branch-name__

do some changess here... or merge with latest branch
$ git merge branch_with_new_features

Create new tag
$ git tag vX.x

Push to remote Repo
$ git push origin vX.x 





01 July 2020

auto mount smb folder on boot

1- manual mount:

sudo mount -t cifs -o username=pakAbu,password=takselamat //1.1.1.1/sharefolder  /mnt/mount_disini/



2- mount on boot

/etc/fstab:

//1.1.1.1/sharefolder /mnt/mount_disini cifs username=pakAbu,password=takselamat 0 0



3- use third file to store credential

/etc/mywinlogin.txt:
username=pakAbu
password=takselamat
domain=WORKGROUP

/etc/fstab:
//1.1.1.1/sharefolder /mnt/mount_disini cifs credential=/etc/mywinlogin.txt 0 0


This will make folder /mnt/mount_disini own by user root, and group root.


4- to change mount dir to normal user
//1.1.1.1/sharefolder /mnt/mount_disini cifs credential=/etc/mywinlogin.txt,uid=1001,guid=1001 0 0

Notice parameter uid and gid. uid number refer to /etc/passwd. gid refer to /etc/group