2019-09-26

Increasing New LVM Volume for VPS

#10:19 2019.09.26
#################
#Increasing-New-LVM-Volume-for-VPS.sh
#OS: "Ubuntu 18.04.3 LTS" / Linux srv150 4.15.0-64-generic GNU/Linux
#################
#fdisk /dev/sdb
n
p
w

#mkfs.ext4 /dev/sdb1

#
root@srv030:/opt/lvm-informations# lsblk -o NAME,FSTYPE,SIZE,MOUNTPOINT,LABEL
NAME            FSTYPE       SIZE MOUNTPOINT      LABEL
loop0           squashfs      89M /snap/core/7713 
loop1           squashfs      91M /snap/core/6350 
sda                          100G                 
├─sda1                         1M                 
├─sda2          ext4           2G /boot           
└─sda3          LVM2_member   98G                 
  ├─vg0-lv1_os  ext4          20G /               
  └─vg0-lv2_opt ext4          78G /opt            
sdb                          130G                 
└─sdb1          ext4         130G                 


#root@srv030:/opt/lvm-informations# vgdisplay | grep "VG Size"
  VG Size               <98.00 GiB

#root@srv030:/opt/lvm-informations# vgextend vg0 /dev/sdb1
WARNING: ext4 signature detected on /dev/sdb1 at offset 1080. Wipe it? [y/n]: y
  Wiping ext4 signature on /dev/sdb1.
  Physical volume "/dev/sdb1" successfully created.
  Volume group "vg0" successfully extended

#root@srv030:/opt/lvm-informations# vgdisplay | grep "VG Size"
  VG Size               227.99 GiB

  
#Update dung lượng mới cho volume "/dev/vg0/lv2_opt": 
lvresize -L+130gb /dev/vg0/lv2_opt

#xfs_growfs /dev/vg01_hdd/lv03_opt
resize2fs  /dev/vg0/lv2_opt

#DONE:
root@srv030:/opt/lvm-informations# vgdisplay | grep "Size"
  VG Size               227.99 GiB
  PE Size               4.00 MiB
  Alloc PE / Size       58111 / <227.00 GiB
  Free  PE / Size       255 / 1020.00 MiB
  
#root@srv030:/opt/lvm-informations# df -h;date;
Filesystem               Size  Used Avail Use% Mounted on
# udev                     7.9G     0  7.9G   0% /dev
# tmpfs                    1.6G  1.1M  1.6G   1% /run
# /dev/mapper/vg0-lv1_os    20G  6.2G   13G  33% /
# tmpfs                    7.9G     0  7.9G   0% /dev/shm
# tmpfs                    5.0M     0  5.0M   0% /run/lock
# tmpfs                    7.9G     0  7.9G   0% /sys/fs/cgroup
# /dev/loop0                90M   90M     0 100% /snap/core/7713
# /dev/loop1                91M   91M     0 100% /snap/core/6350
# /dev/sda2                2.0G   80M  1.8G   5% /boot
/dev/mapper/vg0-lv2_opt  204G  223M  194G   1% /opt
# tmpfs                    1.6G     0  1.6G   0% /run/user/0
# Thu Sep 26 10:21:32 +07 2019
# root@srv030:/opt/lvm-informations# 



#DONE-DONE-DONE














2019-09-13

Make HAProxy match multiple conditions for HTTP health checking



The solution is to use to the raw tcp-check and write a health check script sequence which match all the conditions.


For example, you want to ensure the server’s response has: 
HTTP status code is 200 
absence of keyword Error


1
2
3
4
5
6
7
8
9
10
backend myapp
[...]
 option tcp-check
 tcp-check send GET\ /my/check/url\ HTTP/1.1\r\n
 tcp-check send Host:\ myhost\r\n
 tcp-check send Connection:\ close\r\n
 tcp-check send \r\n
 tcp-check expect string HTTP/1.1\ 200\ OK
 tcp-check expect ! string Error

https://alohalb.wordpress.com/2012/10/12/scalable-waf-protection-with-haproxy-and-apache-with-modsecurity/


#####
https://www.haproxy.com/documentation/aloha/10-0/traffic-management/lb-layer7/health-checks/

Equivalent of the configuration above, with all default options:
backend bk_myapp
        [...]
        option httpchk OPTIONS / HTTP/1.0
        http-check expect rstatus (2|3)[0-9][0-9]
        default-server inter 3s fall 3 rise 2
        server srv1 10.0.0.1:80 check
        server srv2 10.0.0.2:80 check