This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Tuesday, June 26, 2018

Solved : Sendmail stat=Service unavailable

Tuesday, June 26, 2018 0
Situation : Maillog says Service unavailable

Jun 24 06:43:54 testserver sendmail[24622]: w5O4hsFN024620: to=<testuser@remotetest.com> ctladdr=<oratest@testserver.mail.com> (20001/20001), delay=00:00:00, xdelay=00:00:00, mailer=relay, pri=150623, relay=relayserver.com. [10.0.34.1], dsn=5.0.0, stat=Service unavailable

Solution:




Go to /etc/mail path 

 
Step1 : generics-domains file should be below format.

[root@testserver mail]# cat generics-domains
testserver
testserver.mail.com
mail.com
testserver.mail.com

Step2 : genericstable file should be below format

[root@testserver mail]# cat /etc/mail/genericstable


@testserver.mail.com auth_mail_id@relaydomain.com
@mail.com auth_mail_id@relaydomain.com

Map the genericstable by running below command.


# makemap hash /etc/mail/genericstable < /etc/mail/genericstable

Here,
auth_mail_id@relaydomain.com    : Change to your relay server authentication mail id
@testserver.mail.com                      : Your smtp server name
testuser@remotetest.com                : Where you want to send mails
oratest@testserver.mail.com           : smtp server mail id

Now mail will be accepted by relay server.

Thursday, June 14, 2018

Difference between NFSv2, NFSv3 and NFS4 and advantage of NFSv4

Thursday, June 14, 2018 0

Difference between NFSv2, NFSv3 and NFS4 and advantage of NFSv4


Network File System (NFS), allows remote hosts to mount file systems over a network and interact with those file systems as though they are mounted locally. This enables system administrators to consolidate resources on to centralized servers on the network.

NFSv2:
    1. NFS version 2 (NFSv2) is older and widely supported.  NFSv2 is not supported on RHEL7
    2. It can use both TCP and UDP protocol over an IP network(port 2049). But it use UDP running over an IP network to provide a stateless network connection between the client and server.
    3. UDP is stateless, if the server goes down unexpectedly, UDP clients continue to saturate the network with requests for the server. when a frame is lost with UDP, the entire RPC request must be re transmitted

NFSv3:
    1. NFS version 3 (NFSv3) supports safe asynchronous writes and is more robust at error handling than NFSv2; it also supports 64-bit file sizes and offsets, allowing clients to access more than 2Gb of file data.
    2. It can use both TCP and UDP protocol over an IP network(port 2049). But it use UDP running over an IP network to provide a stateless network connection between the client and server.
    3. UDP is stateless, if the server goes down unexpectedly, UDP clients continue to saturate the network with requests for the server. when a frame is lost with UDP, the entire RPC request must be re transmitted.

NFSv4:
    1. NFS version 4 (NFSv4) works through firewalls and on the Internet, no longer requires an rpcbind service, supports ACLs, and utilizes stateful operations.
    2. RHEL 6 supports NFSv2, NFSv3, and NFSv4 clients. When mounting a file system via NFS, RHEL uses NFSv4 by default, if the server supports it.
    3. It use TCP protocol. With TCP, only the lost frame needs to be resent. For these reasons, TCP is the preferred protocol when connecting to an NFS server.

Advantage of NFSv4:
    1. The mounting and locking protocols have been incorporated into the NFSv4 protocol
    2. The server also listens on the well-known TCP port 2049. As such, NFSv4 does not need to interact with rpcbind, lockd, and rpc.statd daemons. The rpc.mountd daemon is required on the NFS server to set up the exports.

Wednesday, April 25, 2018

How to free the disk space from deleted files in which PIDs are still running?

Wednesday, April 25, 2018 0
Sometimes we have removed large size of logfiles or files from linux server as part of housekeeping. But it will not release the disk space while running lsof command

[root@testserver ~]# lsof / | grep -i deleted
sh          3716       root    4w   REG  249,0  2269000 3342481 /var/log/cellos/mcelogd-mon.log (deleted)
sh          3716       root    5w   REG  249,0  2333681 3342525 /var/log/cellos/mcelogd-mon.trc (deleted)
tgtd        4144       root    4w   REG  249,0 26684869 3342480 /var/log/cellos/qd.log (deleted)
tgtd        4144       root    5w   REG  249,0 27453138 3342483 /var/log/cellos/qd.trc (deleted)
tgtd        4145       root    4w   REG  249,0 26684869 3342480 /var/log/cellos/qd.log (deleted)
tgtd        4145       root    5w   REG  249,0 27453138 3342483 /var/log/cellos/qd.trc (deleted)
iscsiuio    4592       root    4w   REG  249,0 26684869 3342480 /var/log/cellos/qd.log (deleted)
iscsiuio    4592       root    5w   REG  249,0 27453138 3342483 /var/log/cellos/qd.trc (deleted)

Normally we need to stop the logging service (syslog) before deleting the log files or stop the service which is related to the files.
Stopping  log collection on running server is not good practice.

Then how to solve the issue?

Free the Disk Space

Find the PID of deleted process, go to /proc then nullify it.

[root@testserver ~]# cd /proc/3716/fd
[root@testserver fd]# ls -al
total 0
dr-x------ 2 root root  0 Apr  9 17:08 .
dr-xr-xr-x 9 root root  0 Apr  9 17:08 ..
lrwx------ 1 root root 64 Apr  9 17:08 0 -> /dev/null
l-wx------ 1 root root 64 Apr  9 17:08 1 -> /var/log/exadatatmp/__imglog_stdout__.tFvWrjjEZTPOJWm3racIEPF5W9YQqMI3
lrwx------ 1 root root 64 Apr  9 17:08 10 -> /dev/null
lrwx------ 1 root root 64 Apr  9 17:08 11 -> /dev/null
l-wx------ 1 root root 64 Apr  9 17:08 2 -> /var/log/exadatatmp/__imglog_stderr__.tFvWrjjEZTPOJWm3racIEPF5W9YQqMI3
lr-x------ 1 root root 64 Apr  9 17:08 255 -> pipe:[21686]
l-wx------ 1 root root 64 Apr  9 17:08 4 -> /var/log/cellos/mcelogd-mon.log (deleted)
l-wx------ 1 root root 64 Apr  9 17:08 5 -> /var/log/cellos/mcelogd-mon.trc (deleted)

The process ID 3716 running on 4w (write mode).

[root@testserver fd]# ls -al 4
l-wx------ 1 root root 64 Apr  9 17:08 4 -> /var/log/cellos/mcelogd-mon.log (deleted)

We can release the space by nullify this file.

[root@testserver ~]# >/proc/3716/fd/4
[root@testserver ~]# lsof / | grep -i deleted | grep -i 3716
sh          3716       root    5w   REG  249,0        0 3342525 /var/log/cellos/mcelogd-mon.trc (deleted)

Alternate way, we can compress the file or we can kill the PID if not needed.

Thursday, April 19, 2018

Facter command in Linux

Thursday, April 19, 2018 0
Facter command is used to Collect and display facts about the current server. The library behind Facter is easy to expand, making Facter an easy way to collect information about a system information such as hardware details, network settings, virtualization type and kernel/OS information from within the shell or within Ruby. If no facts are specifically asked for, then all facts will be displayed.

If we want to use facter command, we need to install facter rpm.

Display all facts

[root@testserver manifests]# facter
architecture => x86_64
augeasversion => 1.1.0
bios_release_date => 01/06/2018
bios_vendor => Xen
bios_version => 4.4.4OVM
blockdevice_xvda_size => 53687091200
blockdevices => xvda
domain => puppet.test.com
facterversion => 2.4.4
filesystems => ext4,iso9660
fqdn => testserver.puppet.test.com
gid => root
hardwareisa => x86_64
....
....
uptime_days => 62
uptime_hours => 1491
uptime_seconds => 5368909
uuid => 0004FB00-0006-0000-7071-48CB71E70F8A
virtual => xenhvm

Display a single fact

[root@testserver ~]#  facter interfaces
eth0,eth1,eth2,lo

Facts format as JSON

[root@testserver ~]# facter --json architecture kernel  uptime timezone puppetversion bios_vendor
{
  "timezone": "CAT",
  "uptime": "62 days",
  "architecture": "x86_64",
  "kernel": "Linux",
  "bios_vendor": "Xen",
  "puppetversion": "3.8.1"

Facts format as YAML

[root@testserver  ~]# facter --yaml architecture kernel  uptime timezone puppetversion bios_vendor
---
bios_vendor: Xen
kernel: Linux
uptime: 62 days
timezone: CAT
architecture: x86_64
puppetversion: 3.8.1

Facter will produce output by below format.
a. JSON
b. YAML
c. Plaintext

Thursday, April 12, 2018

How to change the default login shell by command line in linux server?

Thursday, April 12, 2018 0
By using chsh command we can change the default login shell to other shell.

By using -l option we can list the available login shell on linux server.

[root@testserver ~]# chsh -l
/bin/sh
/bin/bash
/sbin/nologin
/bin/dash
/bin/tcsh
/bin/csh
/bin/ksh

Then which user login shell need to change, we can change by below command. (If a shell is not given on the command line, chsh prompts for one)

[root@testserver ~]# chsh hygmtng7
Changing shell for hygmtng7.
New shell [/bin/ksh]: /bin/bash
Shell changed.

Before
[root@testserver ~]# cat /etc/passwd | grep -i hygmtng7
hygmtng7:x:20009:20009::/gmtng7/hyperion:/bin/ksh

After
[root@testserver ~]# cat /etc/passwd | grep -i hygmtng7
hygmtng7:x:20009:20009::/gmtng7/hyperion:/bin/bash

Thursday, April 5, 2018

How to use --exclude option in du command

Thursday, April 05, 2018 0
du command is used to estimate file space usage.

Sometime we need to exclude some folder or files while running du command.
For that we can use below option to achieve that.

[root@testserver /]# du -sh * --exclude=repository --exclude=oem1

The above command will exclude the repository & oem folder  under / path.

Hope it helps.

Sunday, March 18, 2018

How to Add SSH Public Key to Remote Server(s) in a Single Command.

Sunday, March 18, 2018 0
Below command is used to copy the key to single server.

# cat id_rsa.pub | ssh username@servername 'cat >> /home/user/.ssh/authorized_keys'

Below command is used to copy the key to multiple server. We can use for loop.

# for i in  `cat serverlist`; do echo $i; cat id_rsa.pub |
ssh username@servername 'cat >> /home/user/.ssh/authorized_keys'; done

Hope it helps.