Linux Interview Scenarios
How to set up and use iSCSI target on Linux
What is iSCSI?iSCSI is an Internet Protocol based storage networking standard for linking data storage facilities. By carrying SCSI commands over IP networks, iSCSI can facilitate data transfers over local area networks (LANs), wide area networks (WANs), or the Internet. Through iSCSI, the space on storage server will be regarded as local disks by client's operation system. But in reality, all data transferred to the disk are actually transferred over network to the storage server.
What is iSCSI Target and LUN?
In SCSI terminology, A LUN (logical unit number) represents an individually addressable (logical) SCSI device that is part of a physical SCSI device (called "Target"). An iSCSI environment emulates the connection to a SCSI hard disk. An iSCSI Target is like a connection interface, and LUNs are essentially numbered disk drives. When an iSCSI Target is connected by an iSCSI initiator (a client), all the LUNs mapped to the iSCSI Target are virtually attached to the client's operation system. Therefore, Initiators can establish and manage file systems on iSCSI LUNs, as they would a raw SCSI or IDE hard drive.
https://www.synology.com/en-us/knowledgebase/DSM/tutorial/Virtualization/How_to_set_up_and_use_iSCSI_target_on_Linux
Detailed iSCSI targets from 1st stage onwards will be found in above URL.
########################################################################
You Noticed A Kernel Error Message During The Boot Process, But It Scrolled Before You Could Read This? What Log File Could You Check To Find Out That Message?
The log file that contains kernel boot messages is /var/log/dmesg
########################################################################
high memory utilization in Linux troubleshooting process
top (check the load avge and memory)
free -h (check pagecache and clear it if required.)
vmstat -s
check for memory ballooning.
sar -r (check at what time it is utilizing more memory)
##########################################################################
Implementing Sendmail on RHEL 5/6/7
https://tecadmin.net/install-sendmail-server-on-centos-rhel-server/
##############################################################################
Installation of RHEL / Centos 7 Distributions using PXE and Kickstart Files
https://www.tecmint.com/multiple-centos-installations-using-kickstart/
###############################################################################
How to configure a SSH Tunnel ?
On the client machine perform the following step:
From a new console/terminal execute the telnet command as follows:
##############################################################################
Ethernet Channel Bonding enables two or more Network Interfaces Card (NIC) to a single virtual NIC card which may increase the bandwidth and provides redundancy of NIC Cards. This is a great way to achieve redundant links, fault tolerance or load balancing networks in production system. If one physical NIC is down or unplugged, it will automatically move resources to other NIC card. Channel/NIC bonding will work with the help of bonding driver in Kernel. We’ll be using two NIC to demonstrate the same.
There are almost six types of Channel Bond types are available. Here, we’ll review only two type of Channel Bond which are popular and widely used.
The following is a sample channel bonding configuration file.
Let’s see interfaces created using ifconfig command which shows “bond0” running as the MASTER both interfaces “eth1” and “eth2” running as SLAVES.
Implementing Sendmail on RHEL 5/6/7
https://tecadmin.net/install-sendmail-server-on-centos-rhel-server/
##############################################################################
Installation of RHEL / Centos 7 Distributions using PXE and Kickstart Files
https://www.tecmint.com/multiple-centos-installations-using-kickstart/
###############################################################################
How to configure a SSH Tunnel ?
On the client machine perform the following step:
[root@host]# ssh -N -L <port-number>:<remote-machine-ip>:<remote-machine-port> user@remote-machine-ip
From a new console/terminal execute the telnet command as follows:
[root@host]# telnet localhost <port-number>
##############################################################################
Ethernet Channel Bonding enables two or more Network Interfaces Card (NIC) to a single virtual NIC card which may increase the bandwidth and provides redundancy of NIC Cards. This is a great way to achieve redundant links, fault tolerance or load balancing networks in production system. If one physical NIC is down or unplugged, it will automatically move resources to other NIC card. Channel/NIC bonding will work with the help of bonding driver in Kernel. We’ll be using two NIC to demonstrate the same.
There are almost six types of Channel Bond types are available. Here, we’ll review only two type of Channel Bond which are popular and widely used.
- 0: Load balancing (Round-Robin) : Traffic is transmitted in sequential order or round-robin fashion from both NIC. This mode provides load balancing and fault tolerance.
- 1: Active-Backup : Only one slave NIC is active at any given point of time. Other Interface Card will be active only if the active slave NIC fails.
Creating Ethernet Channel Bonding
We have two Network Ethernet Cards i.e eth1 and eth2 where bond0 will be created for bonding purpose. Need superuser privileged to execute below commands.Load Balancing (Round-Robin)
Configure eth1
Mention parameter MASTER bond0 and eth1 interface as a SLAVE in config file as shown below.# vi /etc/sysconfig/network-scripts/ifcfg-eth1
DEVICE="eth1" TYPE=Ethernet ONBOOT="yes" BOOTPROTO="none" USERCTL=no MASTER=bond0 SLAVE=yes
Configure eth2
Here also, specify parameter MASTER bond0 and eth2 interface as a SLAVE.# vi /etc/sysconfig/network-scripts/ifcfg-eth2
DEVICE="eth2" TYPE="Ethernet" ONBOOT="yes" USERCTL=no #NM_CONTROLLED=yes BOOTPROTO=none MASTER=bond0 SLAVE=yes
Create bond0 Configuration
Create bond0 and configure Channel bonding interface in the “/etc/sysconfig/network-scripts/” directory called ifcfg-bond0.The following is a sample channel bonding configuration file.
# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0 ONBOOT=yes IPADDR=192.168.246.130 NETMASK=255.255.255.0 BONDING_OPTS="mode=0 miimon=100"Note: In the above configuration we have chosen Bonding Options mode=0 i.e Round-Robin and miimon=100 (Polling intervals 100 ms).
Let’s see interfaces created using ifconfig command which shows “bond0” running as the MASTER both interfaces “eth1” and “eth2” running as SLAVES.
# ifconfig
bond0 Link encap:Ethernet HWaddr 00:0C:29:57:61:8E inet addr:192.168.246.130 Bcast:192.168.246.255 Mask:255.255.255.0 inet6 addr: fe80::20c:29ff:fe57:618e/64 Scope:Link UP BROADCAST RUNNING MASTER MULTICAST MTU:1500 Metric:1 RX packets:17374 errors:0 dropped:0 overruns:0 frame:0 TX packets:16060 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1231555 (1.1 MiB) TX bytes:1622391 (1.5 MiB) eth1 Link encap:Ethernet HWaddr 00:0C:29:57:61:8E UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:16989 errors:0 dropped:0 overruns:0 frame:0 TX packets:8072 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:1196931 (1.1 MiB) TX bytes:819042 (799.8 KiB) Interrupt:19 Base address:0x2000 eth2 Link encap:Ethernet HWaddr 00:0C:29:57:61:8E UP BROADCAST RUNNING SLAVE MULTICAST MTU:1500 Metric:1 RX packets:385 errors:0 dropped:0 overruns:0 frame:0 TX packets:7989 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:34624 (33.8 KiB) TX bytes:803583 (784.7 KiB) Interrupt:19 Base address:0x2080 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:8 errors:0 dropped:0 overruns:0 frame:0 TX packets:8 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:480 (480.0 b) TX bytes:480 (480.0 b)Restart Network service and interfaces should be OK.
# service network restart
Shutting down interface bond0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface bond0: [ OK ]Checking the status of the bond.
# watch -n .1 cat /proc/net/bonding/bond0
Sample Ouput
Below output shows that Bonding Mode is Load Balancing (RR) and eth1 & eth2 are showing up.Every 0.1s: cat /proc/net/bonding/bond0 Thu Sep 12 14:08:47 2013 Ethernet Channel Bonding Driver: v3.6.0 (September 26, 2009) Bonding Mode: load balancing (round-robin) MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth1 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 2 Permanent HW addr: 00:0c:29:57:61:8e Slave queue ID: 0 Slave Interface: eth2 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 2 Permanent HW addr: 00:0c:29:57:61:98 Slave queue ID: 0
Create Active Backup
In this scenario, Slave interfaces remain same. only one change will be there in the bond interface ifcfg-bond0 instead of ‘0‘ it will be ‘1‘ which is shown as under.# vi /etc/sysconfig/network-scripts/ifcfg-bond0
DEVICE=bond0 ONBOOT=yes IPADDR=192.168.246.130 NETMASK=255.255.255.0 BONDING_OPTS="mode=1 miimon=100"Restart network service and check the status of bonding.
# service network restart
Shutting down interface bond0: [ OK ] Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface bond0: [ OK ]Checking the status of the bond with command.
# watch -n .1 cat /proc/net/bonding/bond0
Sample Output
Bonding Mode is showing fault-tolerance (active-backup) and Slave Interface is up.Every 0.1s: cat /proc/n... Thu Sep 12 14:40:37 2013 Ethernet Channel Bonding Driver: v3.6.0 (September 2 6, 2009) Bonding Mode: fault-tolerance (active-backup) Primary Slave: None Currently Active Slave: eth1 MII Status: up MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0 Slave Interface: eth1 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 00:0c:29:57:61:8e Slave queue ID: 0 Slave Interface: eth2 MII Status: up Speed: Unknown Duplex: Unknown Link Failure Count: 0 Permanent HW addr: 00:0c:29:57:61:98 Slave queue ID: 0Note: Manually down and up the Slave Interfaces to check the working of Channel Bonding. Please see the command as below.
# ifconfig eth1 down # ifconfig eth1 upThats it!
#####################################################################
On my RHEL 7 setup the rsyslog service fails to start but the problem is once the rsyslog server fails I do not get any messages in /var/log/messages hence I am unable to debug or find the problem why the rsyslog service is failing. Where should I check my system messages in such scenarios?
A. On RHEL 7 we have "journal" which is a component of systemd that is responsible for viewing and management of log files. Logging data is collected, stored, and processed by the Journal's journald service. It creates and maintains binary files called journals based on logging information that is received from the kernel, from user processes, from standard output, and standard error output of system services or via its native API. These journals are structured and indexed, which provides relatively fast seek times. Journal entries can carry a unique identifier. The journald service collects numerous meta data fields for each log message. The actual journal files are secured, and therefore cannot be manually edited.
To view the log files you can use
# journalctl
How to implement logrotate on audit log files ?
To implemet logrotate on audit log files, we need to modify
minimum below listed three parameters :
1. num_logs = 90 (Number of logs to keep on the server based
on the disk space)
2. max_log_file_action = rotate (This parameter tells the
system what action to take when the system has detected that the max file size
limit has been reached)
if we keep the second parameter as
"keep_logs" for second one, it does not use the num_logs setting.
3. max_log_file = 6 (Maximum each log file size in MB's)
######################################################################
Disk space not getting freed even after deleting files ?
Disk space not getting freed even after deleting files ?
#######################################################################
Showmount command not working getting hang what could be done in this scenario ?
https://access.redhat.com/solutions/64542
########################################################################
What happens when you type an URL www.example.com in the browser ?
Browser ---> OS ---> OS memory --> OS ---> Resolver(ISP) --> DNS
In DNS we have three different units..
Root servers
Domain extension servers
Authoritative servers.
Root server will store the location of all extension servers like .org.com .in...
In our case it is .com server.
Domain extension server or .com server stores the location of authorative servers of all domains ending with .com
Authorative servers stores the IP address for some domains.
In simple the route will be like this
Browser ---> OS ---> OS memory --> OS ---> Resolver(ISP) -->Root server (it redirects to .com servers) --> Authorative servers (IP address) --> Resolver (ISP) --> OS --> Browser.
Browser establishes the connection between the OS and Authorative server.
This complete process will completes in fraction of seconds.
##############################################################################
After upgrading kernel the machine fails to boot, what will you do?
A. The very first thing to be done here is to edit the grub menu at boot stage and make the system boot with alternative kernel (assuming the last kernel is still installed) or else try booting the system with using the rescue option from the grub menu.
Once the node is UP then you can analyse the issue of why the node is failing to boot from new kernel. Many times the kernel is not properly installed and all the libraries are not available which leads to this problem. or the GRUB can be corrupted so you can regerate the initramfs using grub2-mkconfig
If there is a kernel panic observed then boot the system with alternate kernel or rescue and then enable kdump. Share the kdump with the support engineers as they can then further try to debug the source of the problem
Showmount command not working getting hang what could be done in this scenario ?
https://access.redhat.com/solutions/64542
########################################################################
What happens when you type an URL www.example.com in the browser ?
Browser ---> OS ---> OS memory --> OS ---> Resolver(ISP) --> DNS
In DNS we have three different units..
Root servers
Domain extension servers
Authoritative servers.
Root server will store the location of all extension servers like .org.com .in...
In our case it is .com server.
Domain extension server or .com server stores the location of authorative servers of all domains ending with .com
Authorative servers stores the IP address for some domains.
In simple the route will be like this
Browser ---> OS ---> OS memory --> OS ---> Resolver(ISP) -->Root server (it redirects to .com servers) --> Authorative servers (IP address) --> Resolver (ISP) --> OS --> Browser.
Browser establishes the connection between the OS and Authorative server.
This complete process will completes in fraction of seconds.
##############################################################################
After upgrading kernel the machine fails to boot, what will you do?
A. The very first thing to be done here is to edit the grub menu at boot stage and make the system boot with alternative kernel (assuming the last kernel is still installed) or else try booting the system with using the rescue option from the grub menu.
Once the node is UP then you can analyse the issue of why the node is failing to boot from new kernel. Many times the kernel is not properly installed and all the libraries are not available which leads to this problem. or the GRUB can be corrupted so you can regerate the initramfs using grub2-mkconfig
# grub2-mkconfig -o /boot/grub2/grub.cfg
If there is a kernel panic observed then boot the system with alternate kernel or rescue and then enable kdump. Share the kdump with the support engineers as they can then further try to debug the source of the problem
###############################################################################
Moving a volume group to another System
You can move an entire LVM volume group to another system.
It is recommended that you use the
vgexport
and vgimport
commands when you do this.
Note
As of Red Hat Enterprise Linux 6.5, you can use the
--force
argument of the vgimport
command.
This allows you to import volume groups that are missing physical volumes and subsequently run the
vgreduce --removemissing
command.
The
vgexport
command makes an inactive volume group inaccessible to the system, which allows you to detach its physical volumes. The vgimport
command makes a volume group accessible to a machine again after the vgexport
command has made it inactive.
To move a volume group form one system to another, perform the following steps:
- Make sure that no users are accessing files on the active volumes in the volume group, then unmount the logical volumes.
- Use the
-a n
argument of thevgchange
command to mark the volume group as inactive, which prevents any further activity on the volume group. - Use the
vgexport
command to export the volume group. This prevents it from being accessed by the system from which you are removing it.After you export the volume group, the physical volume will show up as being in an exported volume group when you execute thepvscan
command, as in the following example.#
pvscan
PV /dev/sda1 is in exported VG myvg [17.15 GB / 7.15 GB free] PV /dev/sdc1 is in exported VG myvg [17.15 GB / 15.15 GB free] PV /dev/sdd1 is in exported VG myvg [17.15 GB / 15.15 GB free] ...When the system is next shut down, you can unplug the disks that constitute the volume group and connect them to the new system. - When the disks are plugged into the new system, use the
vgimport
command to import the volume group, making it accessible to the new system. - Activate the volume group with the
-a y
argument of thevgchange
command. - Mount the file system to make it available for use.
Nice idea,keep sharing your ideas with us.i hope this information's will be helpful for the new learners.
ReplyDeletePython Training in Chennai
Python Training in Anna Nagar
JAVA Training in Chennai
Hadoop Training in Chennai
Selenium Training in Chennai
Python Training in Chennai
Python Training in Velachery