Posts

Showing posts with the label linux

How to monitor disk performance on RHEL or CentOS 7 ?

Image
How to monitor disk performance on RHEL or CentOS 7 ? iotop : Watches I/O usage information output by the Linux kernel (requires 2.6.20 or later) and displays a table of current I/O usage by processes or threads on the system. At least the CONFIG_TASK_DELAY_ACCT, CONFIG_TASK_IO_ACCOUNTING, CONFIG_TASKSTATS and CONFIG_VM_EVENT_COUNTERS options need to be enabled in your Linux kernel build configuration. iotop displays columns for the I/O bandwidth read and written by each process/thread during the sampling period. It also displays the percentage of time the thread/process spent while swapping in and while waiting on I/O. For each process, its I/O priority (class/level) is shown. [root@localhost ~]# iotop Total DISK READ :       0.00 B/s | Total DISK WRITE :       0.00 B/s Actual DISK READ:       0.00 B/s | Actual DISK WRITE:       0.00 B/s    TID  PRIO  USER  ...

How to add more swap space by adding new swap partition in RHEL or CentOS 7 ?

How to add more swap space by adding new swap partition in RHEL or CentOS 7 What is swap? Swap space on a disk is used when the amount of physical RAM is full in the Linux system. When the system runs out of RAM, inactive pages are moved from the RAM to the swap space. Swap space can be either a dedicated swap partition or a swap file. So here we will see how you can add more swap space as a swap file. In this article we will see how we can add more swap space using a new swap partition. Steps : Let's check how much swap is available on the system currently: [root@localhost ~]# swapon --show [root@localhost ~]# free -h I have a new 10GB disk named "/dev/sdb" and i want to use it as a swap space. [root@localhost ~]# fdisk -l Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 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 Step 1 : Create a...

Monitoring Memory, CPU and swap on RHEL or CentOS 7

Image
top : The top provides a dynamic real-time view of running processes, CPU, Memory and SWAP utilization on a system. It can display system summary information as well as a list of processes or threads currently being managed by the Linux kernel. [root@localhost ~]# top In case as a root you want to check it for some particular user then : [root@localhost ~]# top -u hpe pmap : This command report memory map of a process or processes. [root@localhost ~]# pmap -d 22745 vmstat : This command reports information about processes, memory, paging, block IO, traps, disks and cpu activity. [root@localhost ~]# vmstat -w [root@localhost ~]# vmstat -as [root@localhost ~]# vmstat -dw [root@localhost ~]# vmstat -D             5 disks             2 partitions         48470 total reads           104 merged reads     ...

Space reclamation / UNMAP on RHEL or CentOS 7

What is Space Reclamation? This feature supports Thin Provisioned environment, and it is the process of freeing space from the storage system that has already been freed from the host file system. A host file system contains metadata to keep track to know which blocks are available to store new data and which blocks contain actual data and must not be overwritten. This metadata is stored within the LUN. When a file is deleted in the host file system, the file system metadata is updated to mark that file's blocks as free space. Total file system free space is then recalculated to include the newly-freed blocks. To the storage system, these metadata updates appear no different than any other writes being performed by the host. Therefore, the storage system is unaware that any deletions have occurred. What is Unmapping? Unmapping is a process which de-allocates relationship between LBA and a physical block in a logical unit. Reclamation within RHEL and CentOS: RHEL / Ce...

What are /dev/random and /dev/urandom files?

/dev/random will block after the entropy pool is exhausted. It will remain blocked until additional data has been collected from the sources of entropy that are available. This can slow down random data generation. Randomness is critical to the security of cryptography in your application – one-time pads, key generation. [root@localhost ~]# dd if=/dev/random of=random.txt bs=2048 count=2048 dd: warning: partial read (82 bytes); suggest iflag=fullblock 0+2048 records in 0+2048 records out 150665 bytes (151 kB) copied, 21.6704 s, 7.0 kB/s /dev/urandom will not block. Instead it will reuse the internal pool to produce more pseudo-random bits. It's best when we have to a large file with random data. Also if you are using "dd" command to wipe data of a disk by replacing it with random data. [root@localhost ~]# dd if=/dev/urandom of=urandom.txt bs=2048 count=2048 2048+0 records in 2048+0 records out 4194304 bytes (4.2 MB) copied, 0.0361976 s, 116 MB/s

Difference between /var/log/messages and /var/log/dmesg log files

/var/log/messages – This file contains global system messages, including the messages that are logged during system startup. There are several things that are logged in /var/log/messages including mail, cron, daemon, kern, auth, etc. [root@localhost ~]# cat /var/log/messages Apr 17 20:30:03 localhost rsyslogd: [origin software="rsyslogd" swVersion="8.24.0-34.el7" x-pid="9423" x-info="http://www.rsyslog.com"] rsyslogd was HUPed Apr 17 20:40:02 localhost systemd: Started Session 9 of user root. Apr 17 20:40:32 localhost dhclient[9217]: DHCPREQUEST on ens33 to 192.168.189.254 port 67 (xid=0xde4e9a7) Apr 17 20:40:32 localhost dhclient[9217]: DHCPACK from 192.168.189.254 (xid=0xde4e9a7) Apr 17 20:40:32 localhost NetworkManager[8908]: <info>  [1555513832.8097] dhcp4 (ens33):   address 192.168.189.128 Apr 17 20:40:32 localhost NetworkManager[8908]: <info>  [1555513832.8107] dhcp4 (ens33):   plen 24 (255.255.255.0) Apr 17 20:40:32 ...

What are /dev/zero and /dev/null files ?

"/dev/zero" and "/dev/null" are two dummy devices files which are useful for creating empty files. "/dev/zero":   It is used to create a file with no data but with required size(A file with all zero’s written on it). Let's create file with /dev/zero [root@localhost ~]# dd if=/dev/zero of=/opt/zero.txt bs=2048 count=2048 2048+0 records in 2048+0 records out 4194304 bytes (4.2 MB) copied, 0.150465 s, 27.9 MB/s it creates a file that has continuous zeros in it. So we can say that /dev/zero is a file which is used to create a new file with some required size without any meaning to the data. "/dev/null": This file is useful in cases like redirecting unwanted output/error etc to this file. Actually it acts as a black hole which absorbs this unwanted input. So whenever you feed some data to this file, you can not retrieve the data which is fed to it. This file even useful for creating files with zero size. e.g. If you see i h...

Identifying major and minor numbers for a block device in Linux

One of the basic features of the Linux kernel is that it abstracts the handling of devices. All hardware devices look like regular files; they can be opened, closed, read and written using the same, standard, system calls that are used to manipulate files. Every device in the system is represented by a file. For block (disk) and character devices, these device files are created by the mknod command and they describe the device using major and minor device numbers. The kernel needs to be told how to access the device. Not only does the kernel need to be told what kind of device is being accessed but also any special information, such as the partition number if it's a hard disk or density if it's a floppy, for example. This is accomplished by the major number and minor number of that device. Major Numbers : All devices controlled by the same device driver have a common major device number. The major number is actually the offset into the kernel's device driver table, whi...

How to Enable/Generate/Debug Core Dump In Linux?

Today while browsing i came across to something interesting so thought to share with you all. Thanks to Gordon . What is Core Dump? If the running programs were terminated abnormal or crashed, the memory status of the program will be recorded by OS and saved in a file, this file is called “Core Dump” . We also can think of core dump as “memory snapshots”, but in fact, in addition to the memory core dump information, some crucial state of program will also be dump down, such as register information (including the program pointer, the stack pointer etc.), memory management information, other processor state. Core dump is very helpful for programmers to diagnose and debug the program, since some bugs are difficult to reproduce, such as pointer exception, and we can analyze the core dump file to reproduce that program bugs. How to generate Core Dump? Under what circumstances the program terminates abnormally or crashes would happen, if we use the command ...

How to run filesystem and RAW I/O's on RHEL / CentOS (Testing Purpose)

"dd" Command is used to monitor write performance of a disk on the Linux OS. Typical DD syntex: dd if=/dev/<input_file> of=/path/to/<output_file bs=<block-size> count=<number-of-blocks> <other_options> Use the dd command to : 1. Measure server throughput (write speed) dd if=/dev/zero of=/tmp/out-file1.img bs=1G count=1 oflag=dsync Note: "oflag=dsync" option means use synchronized I/O for data. It doesn't use cache and gives accurate results 2. Measure server latency dd if=/dev/zero of=/tmp/out-file1.img bs=512 count=1000 oflag=dsync If you want to run RAW IO on a disk directly for long time you can run dd command in while loop loop; # while true;do dd if=/dev/zero of=/dev/sdb bs=2048 count=5000 oflag=dsync;sync;done; To come out of this loop use "Ctrl + C".