LINUX AND VMWARE STUFF

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

Wednesday, August 14, 2019

Yum commands with examples for RPM package Management

Wednesday, August 14, 2019 0
As part of system admin activities, we need to install, remove and update the system packages. Most of the Linux distros have package manager utility.

Here i have listed some linux distros and its package manager.

Redhat/Centos/Oracle linux - yum (Yellow-Dog Updater Modified)
Fedora         - yum / DNF (Dandified YUM)
opensuse         - zypper
ubuntu/debian         - apt / dpkg /synaptic
Arch Linux         - pacman
Gentoo Linux         - Portage

Yum (Yellow-Dog Updater Modified) is default package manager for some of the Linux distros.

Earlier, rpm command is used for managing packages. Yum command knows how to resolve dependencies by sourcing the additional package. But rpm command can alert us the dependencies, it is unable to source the additional packages.

This documents is having some important yum command with example.

1. To check the version of the yum installed on the server.

[root@nsk ~]# yum --version
3.4.3

2. If we want to know the dependency package before installing the package.

Yum deplist will list all the dependencies and what packages provide those dependencies for the given packages. 

[root@nsk ~]# yum deplist tigervnc

 package: tigervnc.x86_64 1.8.0-5.el7
  dependency: /bin/sh
   provider: bash.x86_64 4.2.46-30.el7
  dependency: coreutils
   provider: coreutils.x86_64 8.22-21.el7
  ....
  ..
  .
  dependency: tigervnc-license
   provider: tigervnc-license.noarch 1.8.0-5.el7


3. To install the package. Here -y option will install the vnc package without any prompt. Also all dependency packages also installed.

[root@nsk ~]# yum install vnc -y 

Installed:
  tigervnc.x86_64 0:1.8.0-5.el7

Dependency Installed:
  fltk.x86_64 0:1.3.4-1.el7                mesa-libGLU.x86_64 0:9.0.0-4.el7                tigervnc-icons.noarch 0:1.8.0-5.el7

Complete!
[root@nsk ~]#


4. To uninstall the package. Here dependency packages also removed.

[root@nsk ~]# yum remove vnc

 Erasing    : tigervnc-1.8.0-5.el7.x86_64   1/1
 Verifying  : tigervnc-1.8.0-5.el7.x86_64   1/1

Removed:
  tigervnc.x86_64 0:1.8.0-5.el7

Complete!
[root@nsk ~]#


5. To know the linux machine had any updates that needed to be applied without running it interactively.

[root@nsk ~]# yum check-update

dconf.x86_64                       0.26.0-3.el7_5.1        updates
firefox.x86_64                    60.2.1-1.el7.centos     updates
firewall-config.noarch         0.4.4.4-15.el7_5         updates
firewalld.noarch                   0.4.4.4-15.el7_5        updates
firewalld-filesystem.noarch 0.4.4.4-15.el7_5         updates
flatpak.x86_64                       0.8.8-4.el7_5           updates

Exit value codes
100 - Package available for updates  or  lists the packages
  0 - No package available for update
  1 - Error


6. We can update the existing installed package.

If we have older version package installed in server and we can use yum update packagename to upgrade it to current version.

[root@nsk ~]# yum update ansible.noarch

Resolving Dependencies
--> Running transaction check
---> Package ansible.noarch 0:2.6.3-1.el7 will be updated
---> Package ansible.noarch 0:2.6.5-1.el7 will be an update

7. If we want to update the specific version of package.
Here we need to specify the exact version of the package. It will work like upgrade. 

[root@nsk ~]# yum update-to tigervnc-1.8.0-5.el7.x86_64


8. If you want to downgrade the currently installed package to previous highest version or particular version.

Yum downgrade command is used to downgrade a package from the version currently installed to the previouse highest version or specific version.

Currently installed firefox version

[root@nsk ~]# rpm -qa |  grep -i firefox
firefox-60.1.0-4.el7.centos.x86_64

[root@nsk ~]# yum downgrade firefox

  Installing : firefox-52.8.0-1.el7.centos.x86_64                1/2
  Cleanup  : firefox-60.1.0-4.el7.centos.x86_64                2/2
  Verifying  : firefox-52.8.0-1.el7.centos.x86_64                1/2
  Verifying  : firefox-60.1.0-4.el7.centos.x86_64                2/2

Removed:
  firefox.x86_64 0:60.1.0-4.el7.centos

Installed:
  firefox.x86_64 0:52.8.0-1.el7.centos

Complete!

[root@nsk ~]# rpm -qa | grep -i firefox
firefox-52.8.0-1.el7.centos.x86_64


9. Search the package which needs to be installed

Yum search command is used to search by using keyword.

[root@nsk ~]# yum search vnc

tigervnc.x86_64 : A TigerVNC remote display system
tigervnc-icons.noarch : Icons for TigerVNC viewer
tigervnc-license.noarch : License of TigerVNC suite
tigervnc-server.x86_64 : A TigerVNC server
xorg-x11-server-source.noarch : Xserver source code required to build VNC server (Xvnc)

  Name and summary matches only, use "search all" for everything.
[root@nsk ~]#


10. Display about the information about package

  Once you search the package, Yum info command is used to display some additional information about that package.

[root@nsk ~]# yum info tigervnc.x86_64

Available Packages
Name         : tigervnc
Arch           : x86_64
Version      : 1.8.0
Release     : 5.el7
Size           : 239 k
Repo          : base/7/x86_64
Summary   : A TigerVNC remote display system
URL            : http://www.tigervnc.com
License       : GPLv2+
Description : Virtual Network Computing (VNC) is a remote display system which
            : allows you to view a computing 'desktop' environment not only on the
            : machine where it is running, but from anywhere on the Internet and
            : from a wide variety of machine architectures.  This package contains a
            : client which will allow you to connect to other desktops running a VNC
            : server.

11. View all available packages.

yum list will show all available packages.

[root@nsk ~]# yum list


12. View only the installed packages

[root@nsk ~]# yum list installed


13. Find a package name by using file name.

    Yum provides command is used to findout the package which is related to the file in Linux server.

[root@nsk ~]# yum provides /etc/nsswitch.conf

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf


14. Find a list of group software packages

In yum, related packages are grouped together with specific name. We can install the group instead of search one by one.

[root@nsk ~]# yum grouplist

Installed Environment Groups:
   GNOME Desktop
Available Environment Groups:
   Minimal Install
   Compute Node
   Infrastructure Server
   File and Print Server
   Cinnamon Desktop
   MATE Desktop
   Basic Web Server
   Virtualization Host
   Server with GUI
   KDE Plasma Workspaces
   Development and Creative Workstation
Available Groups:
   Cinnamon
   Compatibility Libraries
   Console Internet Tools
   Development Tools
   Educational Software
   Electronic Lab
   Fedora Packager
   General Purpose Desktop
   Graphical Administration Tools
   Haskell
   Legacy UNIX Compatibility
   MATE
   Milkymist
   Scientific Support
   Security Tools
   Smart Card Support
   System Administration Tools
   System Management
   TurboGears application framework
   Xfce
Done
[root@nsk ~]#


15. If we want to install particular rpm group, can yum groupinstall

[root@nsk ~]# yum groupinstall 'MATE'


16. Display the available software repositories

Yum is always pointed to some of the software repositories. We can view the same by running below command.

[root@nsk ~]# yum repolist


17. Install from disabled repositories.

Normally all the repositories are enabled. If we need to install packages from disabled repositories, we need to use below command.

[root@nsk ~]# yum --enablerepo=epel install tigervnc.x86_64

Running transaction
  Installing : tigervnc-1.8.0-5.el7.x86_64     1/1
  Verifying  : tigervnc-1.8.0-5.el7.x86_64     1/1

Installed:
  tigervnc.x86_64 0:1.8.0-5.el7

Complete!


18. Yum commands in interactive shell.

we can run yum commands in interactive shell mode.


[root@nsk ~]# yum shell

> updateinfo
epel/x86_64/updateinfo                                                                                                | 948 kB  00:00:00
Updates Information Summary: updates
    3 Bugfix notice(s)
    2 Enhancement notice(s)


By using shell command, we can run multiple commands from a file. First add the command in text file then execute the yum shell command.

[root@nsk nsk]# cat shell_cmd.txt
provides /etc/nsswitch.conf
info tigervnc.x86_64

[root@nsk nsk]# yum shell shell_cmd.txt

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.i686 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf

glibc-2.17-222.el7.x86_64 : The GNU libc libraries
Repo        : @base
Matched from:
Filename    : /etc/nsswitch.conf

Installed Packages
Name        : tigervnc
Arch          : x86_64
Version      : 1.8.0
Release     : 5.el7
Size           : 680 k
Repo          : installed
From repo  : base
Summary    : A TigerVNC remote display system
URL         : http://www.tigervnc.com
License     : GPLv2+
Description : Virtual Network Computing (VNC) is a remote display system which
            : allows you to view a computing 'desktop' environment not only on the
            : machine where it is running, but from anywhere on the Internet and
            : from a wide variety of machine architectures.  This package contains a
            : client which will allow you to connect to other desktops running a VNC
            : server.


19. If we want to see the status of past yum activities

Yum history command is used to view the past activities of yum. We can use info/list/packages-list/packages-info/summary to view what happened, undo/redo/rollback to act on that information and new to start a new history file.

Here, 
info/list/summary         - use transaction id or package
packages-list/packages-info - use package
undo/redo/rollback         - use single transaction id or the keyword and an offset from the last transaction
undo/redo         - use specified transaction id


[root@nsk ~]# yum history  list
Loaded plugins: fastestmirror, langpacks
ID     | Command line                     | Date and time      | Action(s)          | Altered
-------------------------------------------------------------------------------
    50 | update firefox                     | 2018-10-10 15:31 | Update             |    1
    49 | downgrade firefox              | 2018-10-10 15:20 | Downgrade      |    1
    48 | remove tigervnc-1.8.0-5.    | 2018-10-09 18:19 | Erase               |    1
    47 | --enablerepo=epel instal    | 2018-10-09 17:29 | Install               |    1
    46 | remove vnc                        | 2018-10-09 15:12 | Erase               |    1
    45 | install vnc                           | 2018-10-09 15:10 | Install               |    4
    44 | install nmon                       | 2018-10-08 15:33 | Install                |    1
    43 | install pwgen                      | 2018-09-18 16:04 | Install               |    1
    42 | install php-* --skip-bro       | 2018-09-13 20:06 | Install                |  638 ss
    41 | install mysql-*                    | 2018-09-13 19:52 | Install                |   87
    40 | install ipython                     | 2018-09-13 18:41 | Install               |   35
    39 | install phpmy*                    | 2018-09-07 18:35 | Install                |    2
    38 | install mariadb-*                 | 2018-09-07 13:20 | Install                |    9
    37 | erase mariadb-*                 | 2018-09-07 13:20 | Erase                |    9
    36 | install mariadb-*                 | 2018-09-07 13:19 | Install                |    9
    35 | remove mariadb-*              | 2018-09-07 13:18 | Erase                |    9
    34 | install mariadb-*                 | 2018-09-07 12:10 | Install                |   19
    33 | remove mariadb-*              | 2018-09-07 11:55 | Erase                 |    8 EE
    32 | install phpmyadmin            | 2018-08-31 14:00 | Install                 |    7  <
    31 | install php-pgsql                 | 2018-08-31 13:22 | Install                |    2 >
history list

Here,

> - The rpmdb was changed, outside yum, after the transaction.
        < - The rpmdb was changed, outside yum, before the transaction.
        * - The transaction aborted before completion.
        # - The transaction completed, but with a non-zero status.
        E - The transaction completed fine, but had warning/error output during the transaction.
        P - The transaction completed fine, but problems already existed in the rpmdb.
        s - The transaction completed fine, but --skip-broken was enabled and had to skip some packages.

[root@nsk ~]# yum history list all
Loaded plugins: product-id, rhnplugin, search-disabled-repos, security, subscription-manager
This system is receiving updates from RHN Classic or RHN Satellite.
ID     | Login user                           | Date and time    | Action(s)      | Altered
-------------------------------------------------------------------------------
    38 | Shahapuri ... <a251761>  | 2018-08-03 17:45 | I, O, U        |  145 EE
    37 | Shahapuri ... <a251761>  | 2018-08-03 17:43 | Update       |    5
    36 | System <unset>                | 2018-05-11 11:27 | Erase         |    2 EE
    35 | T ... <a262237>                 | 2018-03-01 10:46 | E, I, U        |   80 EE
    34 | System <unset>                | 2017-12-01 13:47 | Update       |    1 EE
    33 | Kukkala ... <a253740>      | 2017-11-24 10:42 | E, I, U         |  246 EE
    32 | Kukkala ... <a253740>      | 2017-11-24 10:38 | Update       |    3
    31 | System <unset>                | 2017-11-21 14:50 | I, U             |    4
    30 | System <unset>                | 2017-06-16 09:57 | Update       |    2
    29 | Govindu ... <a055637>     | 2017-02-20 13:17 | E, I, U         |   42 EE
    28 | Shukla ... <a222788>        | 2016-11-04 10:01 | E, I, U         |   31 EE
    27 | Shukla ... <a222788>        | 2016-11-04 10:00 | Update       |    1
    26 | S ... <a210111>                 | 2016-08-18 15:34 | E, I, O, U    |  261 EE
    25 | S ... <a210111>                 | 2016-08-18 15:24 | Update       |    3 EE
    24 | System <unset>                | 2016-08-05 14:42 | Install         |    4
    23 | Bennurmth ... <a215476> | 2016-06-30 14:17 | Update       |    1
    22 | S ... <a034124>                | 2016-06-01 09:16 | E, I, U         |    5
    21 | Govindu ... <a055637>     | 2016-02-24 12:42 | E, I, U         |   267 EE
    20 | Govindu ... <a055637>     | 2016-02-24 12:40 | Update       |    3
    19 | Honappa ... <a175300>    | 2016-02-04 11:52 | Install         |    1
    18 | Honappa ... <a175300>    | 2016-02-04 11:52 | I, U             |   29
    17 | Lindström ... <a209141>   | 2015-12-02 08:15 | Install         |    4  <
    16 | Lindström ... <a209141>   | 2015-11-06 10:07 | I, U             |    6 >
    15 | Lindström ... <a209141>   | 2015-11-06 10:07 | Install         |    6
    14 | Lindström ... <a209141>   | 2015-11-06 10:06 | Update       |    1
    13 | Lindström ... <a209141>   | 2015-11-06 10:06 | Update       |    5
    12 | Meijer ... <a044156>         | 2015-03-25 18:03 | Install         |   16
    11 | Meijer ... <a044156>         | 2015-03-25 15:54 | Install         |    5
    10 | Palakurthi ... <tin1926>     | 2015-01-28 19:08 | I, U             |  262 EE
     9 | Muniraj ... <a028981>        | 2014-12-24 14:44 | Update       |    2
     8 | System <unset>                 | 2014-09-26 10:04 | Update       |    1
     7 | System <unset>                 | 2014-09-25 16:10 | Update       |    1
     6 | System <unset>                 | 2014-09-15 11:45 | Install          |  1 EE
     5 | System <unset>                 | 2014-09-15 11:44 | Erase          |    1
     4 | System <unset>                 | 2014-09-15 11:41 | Install          |   15
     3 | System <unset>                 | 2014-09-15 11:37 | I, U              |   94 EE
     2 | System <unset>                 | 2014-09-15 11:36 | Install          |   35
     1 | System <unset>                 | 2014-09-15 11:29 | Install          |  573
history list


20. If we want to know the last transactions details from history list. We can specifically give the transaction ID to know about it.

[root@nsk ~]# yum history info
Loaded plugins: fastestmirror, langpacks
Transaction ID : 50
Begin time       : Wed Oct 10 15:31:55 2018
Begin rpmdb    : 2356:97f14b883648310fc9cf9ed660ba4f5f7b52c615
End time          :            15:32:09 2018 (14 seconds)
End rpmdb       : 2356:efedc71553518d49ee1e9feb83d17272b3fde07a
User                 : root <root>
Return-Code    : Success
Command Line   : update firefox
Transaction performed with:
    Installed     rpm-4.11.3-32.el7.x86_64                        @base
    Installed     yum-3.4.3-158.el7.centos.noarch                 @base
    Installed     yum-metadata-parser-1.1.4-10.el7.x86_64         @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-46.el7_5.noarch @updates
Packages Altered:
    Updated firefox-52.8.0-1.el7.centos.x86_64 @updates
    Update          60.2.1-1.el7.centos.x86_64 @updates
history info


[root@nsk ~]# yum history info 43
Loaded plugins: fastestmirror, langpacks
Transaction ID : 43
Begin time       : Tue Sep 18 16:04:53 2018
Begin rpmdb    : 2351:7203da1b9738104d8a8aa568e21412033e0bd122
End time          :                           (0 seconds)
End rpmdb       : 2352:020dc0b21e7c31b8452fea1a659a87d426f0370a
User                 : root <root>
Return-Code    : Success
Command Line   : install pwgen
Transaction performed with:
    Installed     rpm-4.11.3-32.el7.x86_64                        @base
    Installed     yum-3.4.3-158.el7.centos.noarch                 @base
    Installed     yum-metadata-parser-1.1.4-10.el7.x86_64         @anaconda
    Installed     yum-plugin-fastestmirror-1.1.31-46.el7_5.noarch @updates
Packages Altered:
    Install pwgen-2.08-1.el7.x86_64 @epel
history info

21. Package-info is used to know when the package is installed. If it is transacted more than one time also listed.

[root@nsk ~]# yum history package-info php
Loaded plugins: fastestmirror, langpacks
Transaction ID : 24
Begin time     : Thu Aug 30 13:59:58 2018
Package        : php-5.4.16-45.el7.x86_64
State              : Install
Size               : 4,591,806
Build host      : x86-01.bsys.centos.org
Build time      : Fri Apr 13 00:42:53 2018
Packager       : CentOS BuildSystem <http://bugs.centos.org>
Vendor           : CentOS
License          : PHP and Zend and BSD
URL                : http://www.php.net/
Source RPM   : php-5.4.16-45.el7.src.rpm
Commit Time  : Tue Jan 23 17:30:00 2018
Committer      : Remi Collet <rcollet@redhat.com>
Reason          : user
Command Line   : install php
From repo      : base
Installed by   : root <root>
history package-info
[root@nsk ~]#

22. Package-list will show the transaction id and respective action.

[root@nsk ~]# yum history package-list firefox
Loaded plugins: fastestmirror, langpacks
ID     | Action(s)      | Package
-------------------------------------------------------------------------------
    50 | Updated        | firefox-52.8.0-1.el7.centos.x86_64
    50 | Update          |  60.2.1-1.el7.centos.x86_64
    49 | Downgrade   | firefox-52.8.0-1.el7.centos.x86_64
    49 | Downgraded |   60.1.0-4.el7.centos.x86_64
    29 | Install            | firefox-60.1.0-4.el7.centos.x86_64                 EE
history package-list


23. Download a package without installation

Don't update, just download it. This action will be done in background, so yum lock is release for other action. We can mention the download directory

[root@nsk ~]# yum install --downloadonly --downloaddir=/download/dir  package


24. Skip Packages With Broken Dependencies during update.

It will resolve depsolve problems by removing packages that are causing problems from the transaction.

[root@nsk ~]# yum update --skip-broken


25. Exclude kernel or other packages from getting updated


[root@nsk ~]# yum update --exclude=PACKAGENAME

Wednesday, June 5, 2019

Yum failed with Errno 256 No more mirrors to try - Solved

Wednesday, June 05, 2019 0
Situation:
Yum is  failed with Errno 256, No more mirrors to try.

root@testserver# yum list available | grep erna
https://rhn.test.com/pulp/repos/shared/lce-lcs_6month_rhel7/ccv-lcs_6month_rhel7/content/dist/rhel/server/7/7Server/x86_64/extras/os/repodata/repomd. 

       xml: [Errno 14] curl#58 - "SSL peer rejected your certificate as expired."
Trying other mirror.


One of the configured repositories failed (Red Hat Enterprise Linux 7 Server - Extras (RPMs)),
and yum doesn't have enough cached data to continue. At this point the only
safe thing yum can do is fail. There are a few ways to work "fix" this:

     1. Contact the upstream for the repository and get them to fix the problem.

....
...
..

    yum-config-manager --save --setopt=rhel-7-server-extras-rpms.skip_if_unavailable=true

failure: repodata/repomd.xml from rhel-7-server-extras-rpms: [Errno 256] No more mirrors to try.
https://rhn.test.com/pulp/repos/shared/lce-lcs_6month_rhel7/ccv-lcs_6month_rhel7/content/dist/rhel/server/7/7Server/x86_64/extras/os/repodata/repomd. 

       xml: [Errno 14] curl#58 - "SSL peer rejected your certificate as expired."


Solution:
Becasue of corrupted yum cache, getting this error.  So refresh the subscription-manager clean the old cache & run the yum command

root@testserver# subscription-manager refresh
All local data refreshed
root@testserver# yum clean all
root@testserver#
root@testserver# yum list available | grep erna
AdaptermFernablesung_15_hq.noarch
DatentauschInternational_hq.noarch
Fernablesung_2.37_hq.noarch 2.0.0.RELEASE-8 tec-x86_64-server-software-release-7
Fernablesung_Application_hq.noarch
Fernablesung_Comm_3.42_hq.noarch 5.4.1.RELEASE-92 tec-x86_64-server-software-release-7
Fernablesung_Helper_hq.noarch 7.1.5.RELEASE-126 tec-x86_64-server-software-release-7
Fernablesung_IF_3.08_hq.noarch 2.1.0.RELEASE-4 tec-x86_64-server-software-release-7
Fernablesung_IF_3.10_hq.noarch 6.1.1.RELEASE-45 tec-x86_64-server-software-release-7
Fernablesung_Tss3_hq.noarch 1.1.1.RELEASE-315 tec-x86_64-server-software-release-7
ems-AdaptermFernablesung_15_hq.noarch
ems-Fernablesung_hq.noarch 5.2.0.RELEASE-28 tec-x86_64-server-software-release-7
gnome-shell-extension-alternate-tab.noarch
gnome-shell-extension-alternative-status-menu.noarch
root@testserver#

Sunday, December 9, 2018

How to setup and configure Network Teaming on RHEL 7 server

Sunday, December 09, 2018 0
Here we are using nmcli to configure the network teaming. 

nmtui : Text user Interface
nmcli : Command line Interface
Teaming type : loadbalance
Interface         : team0, eth0, eth2

teamd package should be installed on server.

We can see the previous network configuration setup by using nmcli command.

root@nsk# nmcli con show
NAME  UUID                                                            TYPE      DEVICE
eth0     5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03     ethernet    eth0
eth1     8761e75a-0ba3-4f73-80e4-66df47023ed1  ethernet    eth1

Teaming configuration

Execute the below command on server to create team0 teaming interface.

root@nsk# nmcli con add type team con-name team0 ifname team0 config '{ "runner": {"name": "loadbalance"}}'
Connection 'team0' (e07596d2-59b6-406a-a742-07d5ff96901b) successfully added.

root@nsk# nmcli con show
NAME   UUID                                                              TYPE      DEVICE
eth0     5fb06bd0-0bb0-7ffb-45f1-d6edd65f3e03        ethernet    eth0
eth1     8761e75a-0ba3-4f73-80e4-66df47023ed1     ethernet    eth1
team0  e07596d2-59b6-406a-a742-07d5ff96901b     team         team0

Now, /etc/sysconfig/network-scripts/team0 contains below lines

root@nsk# cat ifcfg-team0
TEAM_CONFIG="{\"runner\": {\"name\": \"loadbalance\", \"tx_hash\": [\"eth\", \"ipv4\", \"ipv6\"]}}"
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=dhcp
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=team0
UUID=e07596d2-59b6-406a-a742-07d5ff96901b
DEVICE=team0
ONBOOT=yes
DEVICETYPE=Team

Now add IPv4 address on team0 interface.

root@nsk# nmcli con mod team0 ipv4.addresses 172.27.0.169/28
root@nsk# nmcli con mod team0 ipv4.gateway 172.27.0.161
root@nsk# nmcli con mod team0 ipv4.method manual

Add eth0 interface to the teaming interface.

root@nsk# nmcli con add type team-slave con-name team0-slave0 ifname eth0 master team0
Connection 'team0-slave0' (5fa33d1b-3f25-4fda-b10d-a184e4260cbe) successfully added.

Add eth2 interface to the teaming interface.

root@nsk# nmcli con add type team-slave con-name team0-slave1 ifname eth2 master team0
Connection 'team0-slave1' (bbdb784b-2a9c-4fe3-9a19-11d64a9748ff) successfully added.

root@nsk# ls -al | grep -i team0

ifcfg-team0  
ifcfg-team0-slave0  
ifcfg-team0-slave1

Now bring up the team0 interface.

root@nsk# nmcli connection up team0
Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/11)

root@nsk# teamdctl team0 state
setup:
  runner: loadbalance

root@nsk# /etc/init.d/network restart
Restarting network (via systemctl):                        [  OK  ]

root@nsk# ifconfig | egrep -i "eth0|eth2|team0"

eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether b0:83:fe:d8:44:02  txqueuelen 1000  (Ethernet)
        RX packets 2930895882  bytes 2216873481505 (2.0 TiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1694125755  bytes 312320131645 (290.8 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 56

eth2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        ether b0:83:fe:d8:44:02  txqueuelen 1000  (Ethernet)
        RX packets 2705861  bytes 301266106 (287.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 25  bytes 4159 (4.0 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device interrupt 59

team0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 172.27.0.169  netmask 255.255.255.240  broadcast 172.27.0.175
        inet6 fe80::bbe8:90aa:4108:e728  prefixlen 64  scopeid 0x20<link>
        ether b0:83:fe:d8:44:02  txqueuelen 1000  (Ethernet)
        RX packets 35  bytes 2586 (2.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 28  bytes 4451 (4.3 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Check the configuration

root@nsk# nmcli con reload
root@nsk# nmcli con show
NAME                 UUID                                                             TYPE      DEVICE
eth1                    8761e75a-0ba3-4f73-80e4-66df47023ed1   ethernet    eth1
team0                 e07596d2-59b6-406a-a742-07d5ff96901b   team         team0
team0-slave0     5fa33d1b-3f25-4fda-b10d-a184e4260cbe     ethernet    eth0
team0-slave1     bbdb784b-2a9c-4fe3-9a19-11d64a9748ff     ethernet    eth2

Check the team0 ports status

root@nsk# teamnl team0 ports
 4: eth2: up 1000Mbit FD
 2: eth0: up 1000Mbit FD

We can use teamdctl command to check team0 configuration status.

root@nsk# teamdctl team0 state
setup:
  runner: loadbalance
ports:
  eth0
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
  eth2
    link watches:
      link summary: up
      instance[link_watch_0]:
        name: ethtool
        link: up
        down count: 0
root@nsk#

Note : If we need Activebackup setup, just replace the loadbalance with activebackup while creating team0 interface.

Thursday, November 8, 2018

Extend the cluster file system by extending the existing netapp storage lun in RHEL server

Thursday, November 08, 2018 0
If storage team extended the existing LUN instead of creating new LUN, below steps need to follow.

Run multipath -ll command and search the device info which is mapped to the LUN.

root@nsk# multipath -ll | grep -A 6 -i 3600a09634224747a367d4b55357c4f87
3600a09634224747a367d4b55357c4f87 dm-6 NETAPP,LUN C-Mode
size=400G features='4 queue_if_no_path pg_init_retries 50 retain_attached_hw_handle' hwhandler='0' wp=rw
`-+- policy='round-robin 0' prio=50 status=active
  |- 2:0:0:1 sdg 8:96  active ready running
  `- 1:0:0:1 sdc 8:32  active ready running
3600a09803830436a345d4b51506c4f43 dm-2 NETAPP,LUN C-Mode
size=110G features='4 queue_if_no_path pg_init_retries 50 retain_attached_hw_handle' hwhandler='0' wp=rw

As per above output, sdg and sdc is the devices.  Now rescan the LUN.

root@nsk# echo "1" > /sys/block/sdg/device/rescan
root@nsk# echo "1" > /sys/block/sdc/device/rescan 

Reload multipathd service 

root@nsk# /etc/init.d/multipathd reload

Resize the PV (provide complete path like below)

root@nsk# pvresize /dev/mapper/3600a09634224747a367d4b55357c4f87  

Extend the LV

root@nsk# lvextend -L +199.95g /dev/mapper/oracle_vg-oracledata

Monday, October 15, 2018

How to generate sosreport in different directory instead of default directory

Monday, October 15, 2018 0
Sosreport is a tool that collects configuration details, system information, diagnostic information and system logs from Linux server. Sosreport  generates  an archive report from the running system. The archive may be stored locally or centrally for recording or tracking purposes.

Normally sosreport will be saved under /tmp (RHEL6) /var/tmp (RHEL7) directory on linux server. Some time we need to save the sosreport to some other temporary directory because of space issue. 

Below steps are used to generate sosreport in different directory.

RHEL 5.6 and earlier

We need to set the temporary path environment before running sosreport.

[root@nsk ~]# env TMP=/path/to/target/directory sosreport

RHEL 5.7 and above

We have to use option --tmp-dir with sosreport to redirect the sosreport path 

[root@nsk ~]# sosreport --tmp-dir /path/to/target/directory

Sosreport may have hung because of a specific plugin. We can list all available sosreport plugin modules by below command

[root@nsk ~]# sosreport -l

Identify which plugin is hanging on by below command

[root@nsk ~]# sosreport -vvvv 

If a plugin times out or last plugin does not finish, rerun the sosreport and skip that plugin

[root@nsk ~]# sosreport -v -n plugin_name --tmp-dir /path/to/target/directory

Friday, October 5, 2018

Digging audit log with ausearch tool in RHEL 7

Friday, October 05, 2018 0
ausearch is a tool to search audit daemon logs based upon the events based on different search criteria.

 Audit system stores log entries in the /var/log/audit/audit.log file; if log rotation is enabled, rotated audit.log files are stored in the same directory.

Each event consists of three records, which share the same time stamp. Each record consists of several name=value pairs separated by a white space or a comma. 

type=SYSCALL msg=audit(1510471123.129:36): arch=c000003e syscall=175 success=yes exit=0 a0=1901a20 a1=1c5d a2=41a2d8 a3=18fe400 items=0 ppid=7 24 pid=725 auid=4294967295 uid=0 gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=(none) ses=4294967295 comm="modprobe" exe="/usr/bin/kmo d" subj=system_u:system_r:insmod_t:s0 key=(null)
type=PROCTITLE msg=audit(1510471123.129:36): proctitle=2F7362696E2F6D6F6470726F6265002D71002D2D0069707461626C655F6D616E676C65
type=NETFILTER_CFG msg=audit(1510471123.276:37): table=nat family=2 entries=0

Here, ausearch utility allows us to search Audit log files for specific events. Also it is used to read the audit log timestamp to user readable timestamp by using -i (--interpret) option.

Example:

1.Search for hostname with given hostname specific.

[root@nsk ~]# ausearch -i -hn nsk.testingserver.internal
----
type=USER_AUTH msg=audit(10/04/2018 12:32:02.610:75) : pid=1617 uid=root auid=unset ses=unset subj=system_u:system_r:xdm_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=pam_permit acct=gdm exe=/usr/libexec/gdm-session-worker hostname=nsk.testingserver.internal addr=? terminal=/dev/tty1 res=success'
----

2. Search only the first event that matches the search pattern.

[root@nsk ~]# ausearch -i -hn nsk.testingserver.internal --just-one
----
type=USER_AUTH msg=audit(10/04/2018 12:32:02.610:75) : pid=1617 uid=root auid=unset ses=unset subj=system_u:system_r:xdm_t:s0-s0:c0.c1023 msg='op=PAM:authentication grantors=pam_permit acct=gdm exe=/usr/libexec/gdm-session-worker hostname=nsk.testingserver.internal addr=? terminal=/dev/tty1 res=success'
[root@nsk ~]#

3. Search for all logged actions performed by user nsk, using the user's login ID (auid). 

[root@nsk log]# ausearch -ua 1001 -i
----
type=LOGIN msg=audit(12/04/2017 11:39:18.052:156) : pid=1433 uid=root subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 old-auid=unset auid=nsk tty=(none) old-ses=4294967295 ses=2 res=yes
----
type=USER_ROLE_CHANGE msg=audit(12/04/2017 11:39:18.991:157) : pid=1433 uid=root auid=nsk ses=2 subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='pam: default-context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 selected-context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 exe=/usr/sbin/sshd hostname=nsk addr=fe80::f24d:eb49:d219:6b0 terminal=ssh res=success'

4. Search for an event matching the given Process ID.

[root@nsk ~]# ausearch -i -p 2162
----
type=CRYPTO_SESSION msg=audit(10/05/2018 13:07:54.052:118) : pid=2162 uid=root auid=unset ses=unset subj=system_u:system_r:sshd_t:s0-s0:c0.c1023 msg='op=start direction=from-server cipher=aes256-ctr ksize=256 mac=hmac-sha2-256 pfs=curve25519-sha256@libssh.org spid=2163 suid=sshd rport=50935 laddr=10.0.2.15 lport=22  exe=/usr/sbin/sshd hostname=? addr=10.0.2.2 terminal=? res=success'
----

5. Search the /var/log/audit/audit.log file for successful login attempts

[root@nsk log]# ausearch --message USER_LOGIN --success yes --interpret
----
type=USER_LOGIN msg=audit(11/12/2017 13:04:08.279:110) : pid=662 uid=root auid=root ses=2 subj=system_u:system_r:local_login_t:s0-s0:c0.c1023
msg='op=login id=root exe=/usr/bin/login hostname=nsk addr=? terminal=tty1 res=success'
----
type=USER_LOGIN msg=audit(11/12/2017 13:05:46.297:107) : pid=1242 uid=root auid=root ses=1 subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c
0.c1023 msg='op=login id=root exe=/usr/sbin/sshd hostname=10.0.2.2 addr=10.0.2.2 terminal=/dev/pts/0 res=success'
----

6. Search for all account and group activities.

[root@nsk log]# ausearch -m ADD_USER -m DEL_USER -m ADD_GROUP -m DEL_GROUP -i
----
type=ADD_GROUP msg=audit(11/15/2017 22:05:29.396:169) : pid=15764 uid=root auid=root ses=2 subj=unconfined_u:unconfined_r:groupadd_t:s0-s0:c0.c1023 msg='op=add-group id=dovecot exe=/usr/sbin/groupadd hostname=? addr=? terminal=? res=success'
----
type=ADD_USER msg=audit(11/15/2017 22:05:29.431:171) : pid=15769 uid=root auid=root ses=2 subj=unconfined_u:unconfined_r:useradd_t:s0-s0:c0.c1023 msg='op=add-user id=dovecot exe=/usr/sbin/useradd hostname=? addr=? terminal=? res=success'

7. Search for all failed PROCTITLE from yesterday up until now

[root@nsk log]# ausearch --start yesterday --end now -m PROCTITLE -sv no -i
----
type=PROCTITLE msg=audit(10/03/2018 18:00:02.623:71) : proctitle=/usr/sbin/httpd -DFOREGROUND
type=SYSCALL msg=audit(10/03/2018 18:00:02.623:71) : arch=x86_64 syscall=open success=no exit=EACCES(Permission denied) a0=0x560fb5acc008 a1=O_RDONLY a2=0x1b6 a3=0x24 items=0 ppid=1 pid=1145 auid=unset uid=root gid=root euid=root suid=root fsuid=root egid=root sgid=root fsgid=root tty=(none) ses=unset comm=httpd exe=/usr/sbin/httpd subj=system_u:system_r:httpd_t:s0 key=(null)
type=AVC msg=audit(10/03/2018 18:00:02.623:71) : avc:  denied  { read } for  pid=1145 comm=httpd name=php-mapi.cfg dev="dm-0" ino=19498435 scontext=system_u:system_r:httpd_t:s0 tcontext=system_u:object_r:zarafa_etc_t:s0 tclass=file

Please refer man ausearch for more option.