Sunday 13 September 2020

Linux Service status checkings

To list all service


[root@rhel1 ~]# systemctl list-units --type=service

  UNIT                               LOAD   ACTIVE SUB     DESCRIPTION

  abrt-ccpp.service                  loaded active exited  Install ABRT coredump hook

  abrt-oops.service                  loaded active running ABRT kernel log watcher

  abrt-xorg.service                  loaded active running ABRT Xorg log watcher

  abrtd.service                      loaded active running ABRT Automated Bug Reporting Tool

  atd.service                        loaded active running Job spooling too

  

  

To list all Failed service


[root@rhel1 ~]# systemctl --failed

  UNIT           LOAD   ACTIVE SUB    DESCRIPTION

● kdump.service  loaded failed failed Crash recovery kernel arming

● mcelog.service loaded failed failed Machine Check Exception Logging Daemon


To list all Failed dependencies service


[root@rhel1 ~]# systemctl list-dependencies rsyslog

rsyslog.service

● ├─system.slice

● ├─basic.target

● │ ├─microcode.service

● │ ├─rhel-dmesg.service


to check active service


[root@rhel1 ~]# systemctl is-active rsyslog

unknown

[root@rhel1 ~]#

[root@rhel1 ~]#


to check enabled service


[root@rhel1 ~]# systemctl is-enabled rsyslog

disabled

[root@rhel1 ~]#

[root@rhel1 ~]#


to enable service


[root@rhel1 ~]# systemctl enable rsyslog

Created symlink from /etc/systemd/system/multi-user.target.wants/rsyslog.service to /usr/lib/systemd/system/rsyslog.service.

[root@rhel1 ~]#

[root@rhel1 ~]#


to check enable status of service


[root@rhel1 ~]# systemctl is-enabled rsyslog

enabled

[root@rhel1 ~]#

[root@rhel1 ~]#


to check active status of service


[root@rhel1 ~]# systemctl is-active rsyslog

inactive

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]#


To start service


[root@rhel1 ~]# systemctl start  rsyslog

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl is-active rsyslog

active

[root@rhel1 ~]#

[root@rhel1 ~]#


to reload service


[root@rhel1 ~]# systemctl reload rsyslog

Failed to reload rsyslog.service: Job type reload is not applicable for unit rsyslog.service.

See system logs and 'systemctl status rsyslog.service' for details.

[root@rhel1 ~]#


to restart service


[root@rhel1 ~]# systemctl restart rsyslog

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl status rsyslog.service

● rsyslog.service - System Logging Service

   Loaded: loaded (/usr/lib/systemd/system/rsyslog.service; enabled; vendor preset: enabled)

   Active: active (running) since Sun 2020-09-13 20:44:35 IST; 13s ago

     Docs: man:rsyslogd(8)

           http://www.rsyslog.com/doc/

 Main PID: 67310 (rsyslogd)

   CGroup: /system.slice/rsyslog.service

           └─67310 /usr/sbin/rsyslogd -n


Sep 13 20:44:30 rhel1 systemd[1]: Stopped System Logging Service.

Sep 13 20:44:30 rhel1 systemd[1]: Starting System Logging Service...

Sep 13 20:44:35 rhel1 rsyslogd[67310]:  [origin software="rsyslogd" swVersion="8.24.0-38.el7" x-pid="67310" x-info="http://www.rsyslog.com"] start

Sep 13 20:44:35 rhel1 systemd[1]: Started System Logging Service.



to set default targets:


[root@rhel1 ~]# systemctl set-default rescue.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/rescue.target.

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl get-default

rescue.target

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl set-default poweroff.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/poweroff.target.

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl set-default multi-user.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl set-default network

network-online.target  network-pre.target     network.target

[root@rhel1 ~]# systemctl set-default network

network-online.target  network-pre.target     network.target

[root@rhel1 ~]# systemctl set-default network.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/network.target.

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl set-default graphical.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl set-default multi-user.target

Removed symlink /etc/systemd/system/default.target.

Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/multi-user.target.

[root@rhel1 ~]#

[root@rhel1 ~]# systemctl get-default

multi-user.target

[root@rhel1 ~]#


HOW to fill File system Full ?

 Most destructed command 


cat /dev/zero > /Filesystem_mountpoint/file_name

example:-

[root@rhel1 ~]# df -h /mnt

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/testvg-vol1  197M   11M  187M   6% /mnt

[root@rhel1 ~]#

[root@rhel1 ~]# cat /dev/zero > /mnt/crash_file

cat: write error: No space left on device

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# df -h /mnt

Filesystem               Size  Used Avail Use% Mounted on

/dev/mapper/testvg-vol1  197M  197M   68K 100% /mnt

[root@rhel1 ~]#


Linux LVM commands

 ===LVM======

1) To create PV

pvs

[root@rhel1 ~]# pvs

  PV         VG     Fmt  Attr PSize   PFree

  /dev/sda2  rhel   lvm2 a--   <9.00g      0

  /dev/sdb   ora-vg lvm2 a--  508.00m 508.00m

  /dev/sdc   ora-vg lvm2 a--  508.00m 508.00m

  /dev/sdd          lvm2 ---  512.00m 512.00m



[root@rhel1 ~]# pvcreate  /dev/sde

  Physical volume "/dev/sde" successfully created.

[root@rhel1 ~]# pvs

  PV         VG     Fmt  Attr PSize   PFree

  /dev/sda2  rhel   lvm2 a--   <9.00g      0

  /dev/sdb   ora-vg lvm2 a--  508.00m 508.00m

  /dev/sdc   ora-vg lvm2 a--  508.00m 508.00m

  /dev/sdd          lvm2 ---  512.00m 512.00m

  /dev/sde          lvm2 ---  512.00m 512.00m


=>to create VG


[root@rhel1 ~]# vgcreate ora-vg /dev/sdb /dev/sdc

  Volume group "ora-vg" successfully created

[root@rhel1 ~]#

[root@rhel1 ~]#

[root@rhel1 ~]# vgs

  VG     #PV #LV #SN Attr   VSize    VFree

  ora-vg   2   0   0 wz--n- 1016.00m 1016.00m

  rhel     1   2   0 wz--n-   <9.00g       0

[root@rhel1 ~]#


=> to create LV

[root@rhel1 ~]# lvcreate  -L +1000m -n data1 ora-vg

Logical volume "data1" created.


[root@rhel1 ~]# lvs

  LV    VG     Attr       LSize    Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  data1 ora-vg -wi-a----- 1000.00m

  root  rhel   -wi-ao----   <8.00g

  swap  rhel   -wi-ao----    1.00g

[root@rhel1 ~]# vgs

  VG     #PV #LV #SN Attr   VSize    VFree

  ora-vg   2   1   0 wz--n- 1016.00m 16.00m

  rhel     1   2   0 wz--n-   <9.00g     0

  

===> create FS


[root@rhel1 ~]# mkfs.ext4 /dev/mapper/ora--vg-data1

mke2fs 1.42.9 (28-Dec-2013)

Filesystem label=

OS type: Linux

Block size=4096 (log=2)

Fragment size=4096 (log=2)

Stride=0 blocks, Stripe width=0 blocks

64000 inodes, 256000 blocks

12800 blocks (5.00%) reserved for the super user

First data block=0

Maximum filesystem blocks=262144000

8 block groups

32768 blocks per group, 32768 fragments per group

8000 inodes per group

Superblock backups stored on blocks:

        32768, 98304, 163840, 229376


Allocating group tables: done

Writing inode tables: done

Creating journal (4096 blocks): done

Writing superblocks and filesystem accounting information: done


===> mount FS


[root@rhel1 ~]# mkdir /data1

[root@rhel1 ~]# mount -t ext4 /dev/mapper/ora--vg-data1 /data1


[root@rhel1 ~]# df -h /data1

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/ora--vg-data1  969M  2.5M  900M   1% /data1

[root@rhel1 ~]#


====> To extend FS

1)create PV

2)Add PV to VG

3)extend Volume/resize volume


#pvcreate /dev/sdd

#vgextend ora-vg /dev/sdd

#lvextend -L +100m /dev/mapper/ora--vg-data1

#umount /data1


[root@rhel1 mapper]# resize2fs /dev/mapper/ora--vg-data1

resize2fs 1.42.9 (28-Dec-2013)

Resizing the filesystem on /dev/mapper/ora--vg-data1 to 281600 (4k) blocks.

The filesystem on /dev/mapper/ora--vg-data1 is now 281600 blocks long.


[root@rhel1 mapper]# mount /dev/mapper/ora--vg-data1 /data1


[root@rhel1 mapper]# df -h /data1

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/ora--vg-data1  1.1G  2.5M  993M   1% /data1



or --> online

[root@rhel1 ~]# lvresize -L +100m -r /dev/mapper/ora--vg-data1

  Size of logical volume ora-vg/data1 changed from 1.46 GiB (375 extents) to 1.56 GiB (400 extents).

  Logical volume ora-vg/data1 successfully resized.

resize2fs 1.42.9 (28-Dec-2013)

Filesystem at /dev/mapper/ora--vg-data1 is mounted on /data1; on-line resizing required

old_desc_blocks = 1, new_desc_blocks = 1

The filesystem on /dev/mapper/ora--vg-data1 is now 409600 blocks long.


[root@rhel1 ~]# df -h /data1

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/ora--vg-data1  1.6G  3.0M  1.5G   1% /data1


=====


To RUN FSCK


root@rhel1 ~]# e2fsck -f /dev/mapper/ora--vg-data1

e2fsck 1.42.9 (28-Dec-2013)

Resize inode not valid.  Recreate<y>? yes

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

Free blocks count wrong for group #0 (28117, counted=28118).

Fix<y>? yes

Free blocks count wrong (285661, counted=285662).

Fix<y>? yes


/dev/mapper/ora--vg-data1: ***** FILE SYSTEM WAS MODIFIED *****

/dev/mapper/ora--vg-data1: 11/72000 files (0.0% non-contiguous), 9250/294912 blocks

[root@rhel1 ~]# e2fsck -f /dev/mapper/ora--vg-data1

e2fsck 1.42.9 (28-Dec-2013)

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/ora--vg-data1: 11/72000 files (0.0% non-contiguous), 9250/294912 blocks

[root@rhel1 ~]# e2fsck -f /dev/mapper/ora--vg-data1

e2fsck 1.42.9 (28-Dec-2013)

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/ora--vg-data1: 11/72000 files (0.0% non-contiguous), 9250/294912 blocks



=========>



TO export VGS


[root@rhel1 ~]# vgs

  VG     #PV #LV #SN Attr   VSize  VFree

  ora-vg   4   1   0 wz--n-  1.98g 432.00m

  rhel     1   2   0 wz--n- <9.00g      0

[root@rhel1 ~]# lvs

  LV    VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  data1 ora-vg -wi-ao----  1.56g

  root  rhel   -wi-ao---- <8.00g

  swap  rhel   -wi-ao----  1.00g

[root@rhel1 ~]#

[root@rhel1 ~]# df -h /data1

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/ora--vg-data1  1.6G  3.0M  1.5G   1% /data1

[root@rhel1 ~]#

[root@rhel1 ~]# umount /data1

[root@rhel1 ~]#

[root@rhel1 ~]# lvchange -an ora-vg

[root@rhel1 ~]#

[root@rhel1 ~]# lvs

  LV    VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  data1 ora-vg -wi-------  1.56g

  root  rhel   -wi-ao---- <8.00g

  swap  rhel   -wi-ao----  1.00g

[root@rhel1 ~]#

[root@rhel1 ~]# vgchange -an ora-vg

  0 logical volume(s) in volume group "ora-vg" now active

[root@rhel1 ~]#

[root@rhel1 ~]# vgs

  VG     #PV #LV #SN Attr   VSize  VFree

  ora-vg   4   1   0 wz--n-  1.98g 432.00m

  rhel     1   2   0 wz--n- <9.00g      0

[root@rhel1 ~]#

[root@rhel1 ~]# vgexport ora-vg

  Volume group "ora-vg" successfully exported


=> To do DR Node


[root@rhel2 ~]# vgimport ora-vg

  Volume group "ora-vg" successfully imported

  

[[root@rhel2 ~]# vgs

  VG     #PV #LV #SN Attr   VSize VFree

  ora-vg   4   1   0 wz--n- 1.98g 432.00m

  rhel     1   1   0 wz--n- 7.00g      0

[root@rhel2 ~]# lvs

  LV    VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  data1 ora-vg -wi------- 1.56g

  root  rhel   -wi-ao---- 7.00g

[root@rhel2 ~]# vgchange -ay ora-vg

  1 logical volume(s) in volume group "ora-vg" now active

[root@rhel2 ~]#

[root@rhel2 ~]# lvchange -ay ora-vg

[root@rhel2 ~]#

[root@rhel2 ~]#

[root@rhel2 ~]# lvs

  LV    VG     Attr       LSize Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  data1 ora-vg -wi-a----- 1.56g

  root  rhel   -wi-ao---- 7.00g

[root@rhel2 ~]#

[root@rhel2 ~]#

[root@rhel2 ~]# vgs

  VG     #PV #LV #SN Attr   VSize VFree

  ora-vg   4   1   0 wz--n- 1.98g 432.00m

  rhel     1   1   0 wz--n- 7.00g      0

[root@rhel2 ~]#


[root@rhel2 ~]# mount /dev/mapper/ora--vg-data1 /mnt


[root@rhel2 mnt]# df -h /mnt

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/ora--vg-data1  1.6G  3.0M  1.5G   1% /mnt


=====


to restore VGS -configuration


[root@rhel1 ~]# vgcfgbackup

  Volume group "ora-vg" successfully backed up.

  Volume group "rhel" successfully backed up.



root@rhel1 archive]# vgremove ora-vg

Do you really want to remove volume group "ora-vg" containing 1 logical volumes? [y/n]: y

Do you really want to remove active logical volume ora-vg/data1? [y/n]: y

  Logical volume "data1" successfully removed

  Volume group "ora-vg" successfully removed


[root@rhel1 archive]# vgcfgrestore -f /etc/lvm/archive/ora-vg_00012-467063718.vg ora-vg

  Restored volume group ora-vg

[root@rhel1 archive]# vgs

  VG     #PV #LV #SN Attr   VSize  VFree

  ora-vg   4   1   0 wz--n-  1.98g 432.00m

  rhel     1   2   0 wz--n- <9.00g      0

[root@rhel1 archive]# lvs

  LV    VG     Attr       LSize  Pool Origin Data%  Meta%  Move Log Cpy%Sync Convert

  data1 ora-vg -wi-------  1.56g

  root  rhel   -wi-ao---- <8.00g

  swap  rhel   -wi-ao----  1.00g




======

root@rhel1 mapper]# vgchange -ay ora-vg

  1 logical volume(s) in volume group "ora-vg" now active


[root@rhel1 mapper]# lvchange -ay ora-vg

root@rhel1 mapper]# mount /dev/mapper/ora--vg-data1 /mnt


[root@rhel1 mapper]# df -h /mnt

Filesystem                 Size  Used Avail Use% Mounted on

/dev/mapper/ora--vg-data1  1.6G   19M  1.5G   2% /mnt

[root@rhel1 mapper]#


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


Saturday 12 September 2020

vmware - workstation shared storage configuration

 1)Create  virtual disks

2)go to advanced settings and make them as persistent

3)go to file virtualname.vmx ...sample file shown below

add below 2 lines

==========

disk.locking="FALSE"

scsi1.sharedBus="VIRTUAL"

==========

scsi1.virtualDev = "lsilogic"

scsi1.present = "TRUE"

scsi1:2.fileName = "C:\Users\mchittibabu\Documents\Virtual Machines\storage\disk3.vmdk"

scsi1:2.mode = "independent-persistent"

scsi1:2.present = "TRUE"

scsi1:3.fileName = "C:\Users\mchittibabu\Documents\Virtual Machines\storage\disk4.vmdk"

scsi1:3.mode = "independent-persistent"

scsi1:3.present = "TRUE"

scsi1:1.fileName = "C:\Users\mchittibabu\Documents\Virtual Machines\storage\disk2.vmdk"

scsi1:1.mode = "independent-persistent"

scsi1:1.present = "TRUE"

scsi1:0.fileName = "C:\Users\mchittibabu\Documents\Virtual Machines\storage\disk1.vmdk"

scsi1:0.mode = "independent-persistent"

scsi1:0.present = "TRUE"

scsi1:3.redo = ""

scsi1:1.redo = ""

scsi1:2.redo = ""

scsi1:0.redo = ""

scsi1.pciSlotNumber = "37"