Create, Add, Remove LVM disk

Hi…

Kali ini kita akan coba create, add dan remove LVM disk di Ubuntu.

Pertama, kita pastikan dulu disk sudah terpasang dengan benar pada server

[email protected]:/home/ubuntu# fdisk -l

Disk /dev/vda: 17.2 GB, 17179869184 bytes
4 heads, 32 sectors/track, 262144 cylinders, total 33554432 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x0007eb44

Device Boot Start End Blocks Id System
/dev/vda1 * 2048 33554431 16776192 83 Linux

Disk /dev/vdb: 5368 MB, 5368709120 bytes
16 heads, 63 sectors/track, 10402 cylinders, total 10485760 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/vdb doesn't contain a valid partition table
Disk /dev/vdc: 12.9 GB, 12884901888 bytes
16 heads, 63 sectors/track, 24966 cylinders, total 25165824 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/vdc doesn't contain a valid partition table

Terlihat bahwa pada server ada 3 disk, yaitu vda yang berisi file-file system, kemudian vdb dan vdc yang baru saja kita tambahkan disknya. Selanjutnya, kita install dulu LVM

[email protected]:/home/ubuntu# apt-get install lvm2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
libdevmapper-event1.02.1 libreadline5 watershed
Suggested packages:
thin-provisioning-tools
The following NEW packages will be installed:
libdevmapper-event1.02.1 libreadline5 lvm2 watershed
0 upgraded, 4 newly installed, 0 to remove and 0 not upgraded.
Need to get 622 kB of archives.
After this operation, 1,797 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty/main libdevmapper-event1.02.1 amd64 2:1.02.77-6ubuntu2 [10.8 kB]
Get:2 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty/main libreadline5 amd64 5.2+dfsg-2 [130 kB]
Get:3 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty/main watershed amd64 7 [11.4 kB]
Get:4 http://nova.clouds.archive.ubuntu.com/ubuntu/ trusty/main lvm2 amd64 2.02.98-6ubuntu2 [470 kB]
Fetched 622 kB in 2s (209 kB/s)
Selecting previously unselected package libdevmapper-event1.02.1:amd64.
(Reading database ... 51163 files and directories currently installed.)
Preparing to unpack .../libdevmapper-event1.02.1_2%3a1.02.77-6ubuntu2_amd64.deb ...
Unpacking libdevmapper-event1.02.1:amd64 (2:1.02.77-6ubuntu2) ...
Selecting previously unselected package libreadline5:amd64.
Preparing to unpack .../libreadline5_5.2+dfsg-2_amd64.deb ...
Unpacking libreadline5:amd64 (5.2+dfsg-2) ...
Selecting previously unselected package watershed.
Preparing to unpack .../archives/watershed_7_amd64.deb ...
Unpacking watershed (7) ...
Selecting previously unselected package lvm2.
Preparing to unpack .../lvm2_2.02.98-6ubuntu2_amd64.deb ...
Unpacking lvm2 (2.02.98-6ubuntu2) ...
Processing triggers for man-db (2.6.7.1-1ubuntu1) ...
Setting up libdevmapper-event1.02.1:amd64 (2:1.02.77-6ubuntu2) ...
Setting up libreadline5:amd64 (5.2+dfsg-2) ...
Setting up watershed (7) ...
update-initramfs: deferring update (trigger activated)
Setting up lvm2 (2.02.98-6ubuntu2) ...
update-initramfs: deferring update (trigger activated)
Processing triggers for libc-bin (2.19-0ubuntu6.7) ...
Processing triggers for initramfs-tools (0.103ubuntu4.2) ...
update-initramfs: Generating /boot/initrd.img-3.13.0-83-generic

CREATE LVM
Kita create Physical Volume dan Volume Groupnya

[email protected]:/home/ubuntu# pvcreate /dev/vdb
Physical volume "/dev/vdb" successfully created
[email protected]:/home/ubuntu# vgcreate vgkonfigurasi /dev/vdb
Volume group "vgkonfigurasi" successfully created

Selanjutnya create Logical Volume nya

[email protected]:/home/ubuntu# lvcreate -L 4.9G -n lvkonfigurasi vgkonfigurasi
Rounding up size to full physical extent 4.90 GiB
Logical volume "lvkonfigurasi" created

Selanjutnya, kita buat filesystemnya

[email protected]:/home/ubuntu# mkfs -t ext3 /dev/vgkonfigurasi/lvkonfigurasi

mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
321280 inodes, 1285120 blocks
64256 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1317011456
40 block groups
32768 blocks per group, 32768 fragments per group
8032 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Setelah itu, bikin directory dan mount lvkonfigurasi ke directory tersebut

[email protected]:/home/ubuntu# mkdir /konfigurasi

[email protected]:/home/ubuntu# mount -t ext3 /dev/vgkonfigurasi/lvkonfigurasi /konfigurasi/

Cek lagi disknya

[email protected]:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
udev 493M 12K 493M 1% /dev
tmpfs 100M 356K 100M 1% /run
/dev/disk/by-label/cloudimg-rootfs 16G 787M 15G 6% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vgkonfigurasi-lvkonfigurasi 4.8G 10M 4.5G 1% /konfigurasi

ADD DISK

Sekarang kita coba tambahkan disk lain (vdc) ke LVM yang telah kita buat sebelumnya. Berikut command command nya

Create Physical Volume

[email protected]:/home/ubuntu# pvcreate /dev/vdc
Physical volume "/dev/vdc" successfully created

Cek LVM disk

[email protected]:/home/ubuntu# lvmdiskscan -l
WARNING: only considering LVM devices
/dev/vdb [ 5.00 GiB] LVM physical volume
/dev/vdc [ 12.00 GiB] LVM physical volume
2 LVM physical volume whole disks
0 LVM physical volumes

Tambahkan vdc ke Volume Group yang sudah dibuat, yaitu vgkonfigurasi

[email protected]:/home/ubuntu# vgextend vgkonfigurasi /dev/vdc
Volume group "vgkonfigurasi" successfully extended

Extend atau tambahkan size disk yang baru ke LVM

[email protected]:/home/ubuntu# lvm lvextend -l +100%FREE /dev/vgkonfigurasi/lvkonfigurasi
Extending logical volume lvkonfigurasi to 16.99 GiB
Logical volume lvkonfigurasi successfully resized

Cek dulu, apakah disk sizenya sudah nambah? Ternyata belum, satu langkah lagi

[email protected]:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
udev 493M 12K 493M 1% /dev
tmpfs 100M 356K 100M 1% /run
/dev/disk/by-label/cloudimg-rootfs 16G 787M 15G 6% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vgkonfigurasi-lvkonfigurasi 4.8G 10M 4.5G 1% /konfigurasi

Resize vgkonfigurasi-lvkonfigurasi

[email protected]:/home/ubuntu# resize2fs -p /dev/mapper/vgkonfigurasi-lvkonfigurasi
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/vgkonfigurasi-lvkonfigurasi is mounted on /konfigurasi; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 2
The filesystem on /dev/mapper/vgkonfigurasi-lvkonfigurasi is now 4454400 blocks long.

Cek lagi, apakah sudah nambah kapasitas disknya?

[email protected]:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
udev 493M 12K 493M 1% /dev
tmpfs 100M 356K 100M 1% /run
/dev/disk/by-label/cloudimg-rootfs 16G 787M 15G 6% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vgkonfigurasi-lvkonfigurasi 17G 14M 16G 1% /konfigurasi

REMOVE DISK FROM LVM

Sekarang kita lanjut ke remove disk yang tadi kita tambahkan

Cek Physical Volume

[email protected]:/home/ubuntu# pvs -o+pv_used
PV VG Fmt Attr PSize PFree Used
/dev/vdb vgkonfigurasi lvm2 a-- 5.00g 0 5.00g
/dev/vdc vgkonfigurasi lvm2 a-- 12.00g 0 12.00g

Sebelum diremove, umount dulu directory /konfigurasi

[email protected]:/home/ubuntu# umount /konfigurasi/

Check Volume Group dan LVM

[email protected]:/home/ubuntu# e2fsck -f /dev/mapper/vgkonfigurasi-lvkonfigurasi
e2fsck 1.42.9 (4-Feb-2014)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/mapper/vgkonfigurasi-lvkonfigurasi: 11/1092352 files (0.0% non-contiguous), 104816/4454400 blocks

Resize LVM size

[email protected]:/home/ubuntu# lvreduce -L 4.8G /dev/vgkonfigurasi/lvkonfigurasi
Rounding size to boundary between physical extents: 4.80 GiB
WARNING: Reducing active logical volume to 4.80 GiB
THIS MAY DESTROY YOUR DATA (filesystem etc.)
Do you really want to reduce lvkonfigurasi? [y/n]: y
Reducing logical volume lvkonfigurasi to 4.80 GiB
Logical volume lvkonfigurasi successfully resized

Lepas Disk pada Volume Group

[email protected]:/home/ubuntu# vgreduce vgkonfigurasi /dev/vdc
Removed "/dev/vdc" from volume group "vgkonfigurasi"

[email protected]:/home/ubuntu# pvremove /dev/vdc
Labels on physical volume "/dev/vdc" successfully wiped

Buat filesystemnya

[email protected]:/home/ubuntu# mkfs -t ext3 /dev/vgkonfigurasi/lvkonfigurasi
mke2fs 1.42.9 (4-Feb-2014)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
315120 inodes, 1258496 blocks
62924 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1291845632
39 block groups
32768 blocks per group, 32768 fragments per group
8080 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done

Selanjutnya mount kembali di directory /konfigurasi

[email protected]:/home/ubuntu# mount -t ext3 /dev/vgkonfigurasi/lvkonfigurasi /konfigurasi
[email protected]:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
udev 493M 12K 493M 1% /dev
tmpfs 100M 356K 100M 1% /run
/dev/disk/by-label/cloudimg-rootfs 16G 787M 15G 6% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vgkonfigurasi-lvkonfigurasi 4.7G 9.8M 4.4G 1% /konfigurasi

Terakhir resize size disknya

[email protected]:/home/ubuntu# lvm lvextend -l +100%FREE /dev/vgkonfigurasi/lvkonfigurasi
Extending logical volume lvkonfigurasi to 5.00 GiB
Logical volume lvkonfigurasi successfully resized

[email protected]:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
udev 493M 12K 493M 1% /dev
tmpfs 100M 356K 100M 1% /run
/dev/disk/by-label/cloudimg-rootfs 16G 787M 15G 6% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vgkonfigurasi-lvkonfigurasi 4.7G 9.8M 4.4G 1% /konfigurasi

[email protected]:/home/ubuntu# resize2fs -p /dev/mapper/vgkonfigurasi-lvkonfigurasi
resize2fs 1.42.9 (4-Feb-2014)
Filesystem at /dev/mapper/vgkonfigurasi-lvkonfigurasi is mounted on /konfigurasi; on-line resizing required
old_desc_blocks = 1, new_desc_blocks = 1
The filesystem on /dev/mapper/vgkonfigurasi-lvkonfigurasi is now 1309696 blocks long.

[email protected]:/home/ubuntu# df -h
Filesystem Size Used Avail Use% Mounted on
udev 493M 12K 493M 1% /dev
tmpfs 100M 356K 100M 1% /run
/dev/disk/by-label/cloudimg-rootfs 16G 787M 15G 6% /
none 4.0K 0 4.0K 0% /sys/fs/cgroup
none 5.0M 0 5.0M 0% /run/lock
none 497M 0 497M 0% /run/shm
none 100M 0 100M 0% /run/user
/dev/mapper/vgkonfigurasi-lvkonfigurasi 4.8G 9.8M 4.6G 1% /konfigurasi

Install WHM Cpanel di CentOS 7

Hi…

Kali ini kita akan mencoba untuk instalasi whm/cpanel. Apa itu whm/cpanel? Definisi nya cari sendiri ya… hehehe… Intinya, whm/cpanel merupakan panel hosting, dan saat ini banyak digunakan oleh kebanyakan hosting provider. Sayangnya, whm/cpanel ini berbayar, tapi masih ada trial nya selama 7 hari.

Ok mari kita mulai….

Langkah awal, update dulu centos 7 nya, kemudian direstart, menggunakan perintah

$ sudo yum -y update

$ sudo reboot

Setup hostname (FQDN or Fully Qualified Domain Name) dan kemudian cek

[[email protected] home]# hostname cpanel.konfigurasi.net
[[email protected] home]# hostname
cpanel.konfigurasi.net

Kemudian, install perl dan curl, 

# yum install perl curl

Kemudian, disable Network Manager, karena cpanel tidak bisa menggunakan Network Manager, dan aktifkan Network Service

[[email protected] home]# systemctl disable NetworkManager
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
[[email protected] home]# systemctl stop NetworkManager
[[email protected] home]# systemctl enable network
network.service is not a native service, redirecting to /sbin/chkconfig.
Executing /sbin/chkconfig network on
[[email protected] home]# systemctl start network

Download script untuk instalasi whm/cpanel. Script ini berisi otomasi untuk install

# curl -o latest -L https://securedownloads.cpanel.net/latest

Setelah itu baru jalan kan scriptnya

# sh latest

Nah, karena proses nya lama, ada baiknya proses menjalankan script latest, menggunakan screen, agar tidak terputus prosesnya. Jadi kita bisa melakukan kegiatan yang lain, mungkin sambil ngopi dan makan roti.

2018-02-27 19:10:52 1146 ( INFO): Congratulations! Your installation of cPanel & WHM 11.68 is now complete. The next step is to configure your server.
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): Before you configure your server, ensure that your firewall allows access on port 2087.
2018-02-27 19:10:52 1146 ( INFO): On RHEL, CentOS, and CloudLinux systems, execute /scripts/configure_firewall_for_cpanel to accomplish this.
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): After ensuring that your firewall allows access on port 2087, you can configure your server.
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): 1. Open your preferred browser
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): 2. Type https://192.168.192.111:2087 in the address bar
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): 3. Enter the word root in the Username text box
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): 4. Enter your root password in the Password text box
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): 5. Click the Login button
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): Visit https://go.cpanel.net/whminit for more information about first-time configuration of your server.
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): Visit http://support.cpanel.net or https://go.cpanel.net/whmfaq for additional support
2018-02-27 19:10:52 1146 ( INFO):
2018-02-27 19:10:52 1146 ( INFO): Thank you for installing cPanel & WHM 11.68!