Monday, September 20, 2021

Resize disk - growpart

 This is a very useful tool to resize your disk.

See this: Enlarge a disk and partition of any Linux VM without a reboot - CodeNotary

For Redhat, use this article: https://access.redhat.com/solutions/5540131


login as: root

root@192.168.0.52's password:

Last login: Mon Sep 20 17:50:45 2021 from gateway

[root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                49301728        0  49301728   0% /dev

tmpfs                                   49318592        0  49318592   0% /dev/shm

tmpfs                                   49318592     9524  49309068   1% /run

tmpfs                                   49318592        0  49318592   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 44819440   1291284  98% /

/dev/sda1                                1038336   242192    796144  24% /boot

/dev/sdb1                               50442784 31384040  16473352  66% /data

tmpfs                                    9863720        8   9863712   1% /run/user/42

tmpfs                                    9863720        0   9863720   0% /run/user/0

[root@database-rhel79 ~]# fdisk -l


Disk /dev/sdb: 161.1 GB, 161061273600 bytes, 314572800 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 label type: dos

Disk identifier: 0x2551332d


   Device Boot      Start         End      Blocks   Id  System

/dev/sdb1            2048   102762495    51380224   83  Linux


Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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 label type: dos

Disk identifier: 0x000bbcfa


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200   104857599    51379200   8e  Linux LVM


Disk /dev/mapper/rhel_database--rhel79-root: 47.2 GB, 47240445952 bytes, 92266496 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 /dev/mapper/rhel_database--rhel79-swap: 5368 MB, 5368709120 bytes, 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


[root@database-rhel79 ~]# growpart /dev/sdb 1

bash: growpart: command not found...

[root@database-rhel79 ~]# resize2fs /dev/sdb1

resize2fs 1.42.9 (28-Dec-2013)

The filesystem is already 12845056 blocks long.  Nothing to do!


[root@database-rhel79 ~]# cat /sys/class/block/sdb/device/rescan

cat: /sys/class/block/sdb/device/rescan: Permission denied

[root@database-rhel79 ~]# id

uid=0(root) gid=0(root) groups=0(root)

[root@database-rhel79 ~]# ls -l /sys/class/block/sdb/device/rescan

--w------- 1 root root 4096 Sep 20 17:59 /sys/class/block/sdb/device/rescan

[root@database-rhel79 ~]# yum install cloud-utils

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager


No package cloud-utils available.

Error: Nothing to do

[root@database-rhel79 ~]#

[root@database-rhel79 ~]# yum install cloud-utils-growpart

Loaded plugins: langpacks, product-id, search-disabled-repos, subscription-manager

Resolving Dependencies

--> Running transaction check

---> Package cloud-utils-growpart.noarch 0:0.29-5.el7 will be installed

--> Finished Dependency Resolution


Dependencies Resolved


=======================================================================================================================================================================

 Package                                       Arch                            Version                               Repository                                   Size

=======================================================================================================================================================================

Installing:

 cloud-utils-growpart                          noarch                          0.29-5.el7                            rhel-7-server-rpms                           27 k


Transaction Summary

=======================================================================================================================================================================

Install  1 Package


Total download size: 27 k

Installed size: 61 k

Is this ok [y/d/N]: y

Downloading packages:

cloud-utils-growpart-0.29-5.el7.noarch.rpm                                                                                                      |  27 kB  00:00:06

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

  Installing : cloud-utils-growpart-0.29-5.el7.noarch                                                                                                              1/1

  Verifying  : cloud-utils-growpart-0.29-5.el7.noarch                                                                                                              1/1


Installed:

  cloud-utils-growpart.noarch 0:0.29-5.el7


Complete!

[root@database-rhel79 ~]# growpart /dev/sdb 1

CHANGED: partition=1 start=2048 old: size=102760448 end=102762496 new: size=314570719 end=314572767

[root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                49301728        0  49301728   0% /dev

tmpfs                                   49318592        0  49318592   0% /dev/shm

tmpfs                                   49318592     9496  49309096   1% /run

tmpfs                                   49318592        0  49318592   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 44821624   1289100  98% /

/dev/sda1                                1038336   242192    796144  24% /boot

/dev/sdb1                               50442784 31384040  16473352  66% /data

tmpfs                                    9863720       12   9863708   1% /run/user/42

tmpfs                                    9863720        0   9863720   0% /run/user/0

[root@database-rhel79 ~]# resize2fs /dev/sdb1

resize2fs 1.42.9 (28-Dec-2013)

Filesystem at /dev/sdb1 is mounted on /data; on-line resizing required

old_desc_blocks = 7, new_desc_blocks = 19

The filesystem on /dev/sdb1 is now 39321339 blocks long.


[root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                49301728        0  49301728   0% /dev

tmpfs                                   49318592        0  49318592   0% /dev/shm

tmpfs                                   49318592     9496  49309096   1% /run

tmpfs                                   49318592        0  49318592   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 44821568   1289156  98% /

/dev/sda1                                1038336   242192    796144  24% /boot

/dev/sdb1                              154685884 31391512 116472880  22% /data

tmpfs                                    9863720       12   9863708   1% /run/user/42

tmpfs                                    9863720        0   9863720   0% /run/user/0


Tuesday, September 14, 2021

Tomcat error: because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache

See: https://stackoverflow.com/questions/58591273/what-is-the-correct-cache-size-to-prevent-tomcat-log-from-getting-flooded-with-c



 I am running Apache Tomcat/9.0.19 and recently I have noticed a lot of warning messages on the catalina.out log.

WARNING [main] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/static/maps/scripts/app-72be477367.js.map] to the cache for web application [##01] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache

WARNING [main] org.apache.catalina.webresources.Cache.getResource Unable to add the resource at [/WEB-INF/classes/static/maps/scripts/app-f223be6846.js.map] to the cache for web application [##01] because there was insufficient free space available after evicting expired cache entries - consider increasing the maximum size of the cache

Adding the following line to the conf/context.xml solves this problem and my log is no longer flooded.

 <Resources cachingAllowed="true" cacheMaxSize="100000" />

Saturday, September 11, 2021

Add new disk to redhat

reference: https://www.tecmint.com/add-new-disk-to-an-existing-linux/


 [root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                16372740        0  16372740   0% /dev

tmpfs                                   16389744        0  16389744   0% /dev/shm

tmpfs                                   16389744    25812  16363932   1% /run

tmpfs                                   16389744        0  16389744   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 40634232   5476492  89% /

/dev/sda1                                1038336   228548    809788  23% /boot

tmpfs                                    3270168       12   3270156   1% /run/user/42

tmpfs                                    3270168        0   3270168   0% /run/user/0

[root@database-rhel79 ~]# fdisk -l


Disk /dev/sda: 53.7 GB, 53687091200 bytes, 104857600 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 label type: dos

Disk identifier: 0x000bbcfa


   Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *        2048     2099199     1048576   83  Linux

/dev/sda2         2099200   104857599    51379200   8e  Linux LVM


Disk /dev/mapper/rhel_database--rhel79-root: 47.2 GB, 47240445952 bytes, 92266496 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 /dev/mapper/rhel_database--rhel79-swap: 5368 MB, 5368709120 bytes, 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 /dev/sdb: 53.7 GB, 53687091200 bytes, 104857600 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


[root@database-rhel79 ~]# fdisk /dev/sdb

Welcome to fdisk (util-linux 2.23.2).


Changes will remain in memory only, until you decide to write them.

Be careful before using the write command.


Device does not contain a recognized partition table

Building a new DOS disklabel with disk identifier 0x2551332d.


Command (m for help): n

Partition type:

   p   primary (0 primary, 0 extended, 4 free)

   e   extended

Select (default p): p

Partition number (1-4, default 1): 1

First sector (2048-104857599, default 2048):

Using default value 2048

Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +50G

Value out of range.

Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +52G

Value out of range.

Last sector, +sectors or +size{K,M,G} (2048-104857599, default 104857599): +49G

Partition 1 of type Linux and of size 49 GiB is set


Command (m for help): w

The partition table has been altered!


Calling ioctl() to re-read partition table.

Syncing disks.

[root@database-rhel79 ~]#

[root@database-rhel79 ~]# mkfs.ext4 /dev/sdb1

mke2fs 1.42.9 (28-Dec-2013)

Discarding device blocks: done

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

3211264 inodes, 12845056 blocks

642252 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=2162163712

392 block groups

32768 blocks per group, 32768 fragments per group

8192 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,

        4096000, 7962624, 11239424


Allocating group tables: done

Writing inode tables: done

Creating journal (32768 blocks): done

Writing superblocks and filesystem accounting information: done


[root@database-rhel79 ~]# mount /dev/sdb1 '^C

[root@database-rhel79 ~]# mkdir /data

[root@database-rhel79 ~]# mount /dev/sdb1 /data

[root@database-rhel79 ~]# df -k

Filesystem                             1K-blocks     Used Available Use% Mounted on

devtmpfs                                16372740        0  16372740   0% /dev

tmpfs                                   16389744        0  16389744   0% /dev/shm

tmpfs                                   16389744    26032  16363712   1% /run

tmpfs                                   16389744        0  16389744   0% /sys/fs/cgroup

/dev/mapper/rhel_database--rhel79-root  46110724 40600652   5510072  89% /

/dev/sda1                                1038336   228548    809788  23% /boot

tmpfs                                    3270168       32   3270136   1% /run/user/0

/dev/sr0                                 4420474  4420474         0 100% /run/media/root/RHEL-7.9 Server.x86_64

/dev/sdb1                               50442784    53272  47804120   1% /data

[root@database-rhel79 ~]# chmod 777 /data


Make an entry in /etc/fstab file for permanent mount at boot time.

/dev/xvdc1	/data	ext4	defaults     0   0