Installing EPEL Repository on CentOS

EPEL stands for Extra Packages for Enterprise Linux. This is a massive collection of packages that are very useful for the building of many modern stacks and include many tools for the running and maintenance of systems.

The homepage of EPEL is here: http://fedoraproject.org/wiki/EPEL.

You can browse the package set using repoview:

Installing on Centos 5.x & 6.x:

For EL5:

su -c 'rpm -Uvh http://mirror.switch.ch/ftp/mirror/epel/5/i386/epel-release-5-4.noarch.rpm'
...
su -c 'yum install puppet'

For EL6:

su -c 'rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm'
...
su -c 'yum install puppet'

For EL7

sudo yum install epel-release

Setting hostname

#vim /etc/sysconfig/network

Use something like

HOSTNAME=testarossa.maranello.local

to overwrite the default name and domain of the server.

e.g.

NETWORKING=yes
HOSTNAME=testarossa.maranello.local

To avoid rebooting issue the following :

hostname  testarossa.maranello.local

That will set it for the current  session.

 

 

 

Monitoring connections

To monitor TCP and UDP connections the following command is very useful:

netstat -t -u

to have a continuous update use the watch command:

watch netstat -t -u

There is a much stronger tool for real time analysis called iptraf.

It is quite self explanatory :

at command line run

iptraf

This tool has many functions and is text mode menu ncurses based application really worth learning.

 

Fixing Warning: RPMDB altered outside of yum

What does it mean?

The yum message “Warning: RPMDB altered outside of yum.” or, as the yum message said for a few months, “Warning: RPMDB has been altered since the last yum transaction.” means some application has altered the rpm database (installed or removed a package) without going through the Yum APIs. This is almost always due to someone using rpm directly (Ie. rpm -ivh blah.rpm), but another possibility is an application built on top of the rpm APIs (Ie. smart, apt, zypp). While it’s possible that someone has hacked your machine and altered the rpmdb maliciously, it would have to be done poorly to trigger this warning.

Why has yum started to emit this warning?

There are three main sets of reasoning behind bringing this to the users attention.

New yum features require yum being “the” packaging API

There are now a few features in yum, requested by users of the package management system, that require yum is aware of all package actions on the system. Here a few of the current ones:

  • The most obvious example is “yum history”, which records when packages were installed, when and by whom. If yum is not involved in installing/updating/removing/etc. some packages then a lot of the benefits of “yum history” are gone. For instance there is no useful audit trail anymore, you can’t use “yum history list blah” and know you have all the instances where something happened to “blah”.
  • Yum now has it’s own database, for package information it wants to record but has no corresponding entry in the rpmdb, the obvious example is “the id of the repository that this package was installed from” but there are quite a few pieces of info. now.
  • Following on from the previous point, rpmdb versions are a significant feature for managing many machines by yum. They require information from the yumdb, so installing something via. yum on one machine but via. rpm on another would give the machines different “rpmdb versions”.

This is not a complete list, and as more package management features are implemented they are much more likely to be implemented at the yum layer than at the rpm layer. Not because rpm is bad, but for the same reasons that the above features were implemented in yum, it’s much easier and faster to implement them there.

 

Solution :

# yum clean all
 

Setting up NTP server

Setting up NTP is very important for a host of application especially clusters and applications like DBs requiring all the servers to be critically time-wise synced.

Install NTP on Red Hat and CentOS 6

$ yum install ntp
$ chkconfig ntpd on
$ ntpdate pool.ntp.org
$ service ntpd start

Install NTP on Ubuntu

$ apt-get install ntp

Setup default gateway with route command Linux

Display default route

The following three commands display the current routing table:

# route

Output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
192.168.1.0     *               255.255.255.0   U     0      0        0 ra0
default         dsl-router      0.0.0.0         UG    0      0        0 ra0
# /sbin/route

Output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
191.255.255.0   *               255.255.255.0   U     0      0        0 eth0
169.254.0.0     *               255.255.0.0     U     0      0        0 eth0
default         191.255.255.1   0.0.0.0         UG    0      0        0 eth0

You can use -n option, to display numerical addresses instead of trying to determine symbolic host names (via dns or /etc/hosts file). This is useful if you are trying to determine why the route to your nameserver has vanished.$

#/sbin/route -n

Output:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
191.255.255.0   0.0.0.0         255.255.255.0   U     0      0        0 venet0
169.254.0.0     0.0.0.0         255.255.0.0     U     0      0        0 venet0
0.0.0.0         191.255.255.1   0.0.0.0         UG    0      0        0 venet0

 

Please note that a destionation entry 0.0.0.0 (or default) is the default gatway. In above example 191.255.255.1 is a default gatway.

Add / setup a new route

The syntax is as follows:
route add default gw {IP-ADDRESS} {INTERFACE-NAME}

Where,

  • IP-ADDRESS: Specify router IP address
  • INTERFACE-NAME: Specify interface name such as eth0

For example if your router IP address is 192.168.1.254 type the following command as the root user:

# route add default gw 192.168.1.254 eth0

OR use hostname such as dsl-router:

# route add default gw dsl-router eth0

Setting route using GUI tools/command under Linux

If you find above command hard to use, consider using GUI tools. If your are using Red Hat/CentOS/Fedora core Linux type following command:

# redhat-config-network

OR

If you are using other Linux distribution use command:

# network-admin

Installing iostat in CentOS with yum

Iostat is a very powerful tool for monitoring the throughput of your storage subsystems. Especially to locate bottle necks and pinpoint possible upgrade scenarios. Not immediately visible here is how to install it on Centos 5.x and 6.x.

We shall use the whatprovides tool in yum to locate the packages that provide iostat

  (more…)

Installing vim editor.

To install vim

[root@testarossa-00-0c-29-47-8f-35 ~]# yum whatprovides vim-enhanced
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.crazynetwork.it
 * epel: fr2.rpmfind.net
 * extras: mirror.crazynetwork.it
 * updates: mirror.crazynetwork.it
2:vim-enhanced-7.0.109-7.el5.i386 : A version of the VIM editor which includes
                                  : recent enhancements.
Repo        : base
Matched from:

[root@testarossa-00-0c-29-47-8f-35 ~]# yum install vim-enhanced-7.0.109-7.el5.i386 
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.crazynetwork.it
 * epel: ftp.uni-koeln.de
 * extras: mirror.crazynetwork.it
 * updates: mirror.crazynetwork.it
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package vim-enhanced.i386 2:7.0.109-7.el5 set to be updated
--> Processing Dependency: vim-common = 2:7.0.109-7.el5 for package: vim-enhanced
--> Running transaction check
---> Package vim-common.i386 2:7.0.109-7.el5 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package              Arch         Version                   Repository    Size
================================================================================
Installing:
 vim-enhanced         i386         2:7.0.109-7.el5           base         1.2 M
Installing for dependencies:
 vim-common           i386         2:7.0.109-7.el5           base         6.4 M

Transaction Summary
================================================================================
Install       2 Package(s)
Upgrade       0 Package(s)

Total download size: 7.7 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): vim-enhanced-7.0.109-7.el5.i386.rpm               | 1.2 MB     00:03     
(2/2): vim-common-7.0.109-7.el5.i386.rpm                 | 6.4 MB     00:18     
--------------------------------------------------------------------------------
Total                                           344 kB/s | 7.7 MB     00:22     
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing     : vim-common                                               1/2 
  Installing     : vim-enhanced                                             2/2 

Installed:
  vim-enhanced.i386 2:7.0.109-7.el5                                             

Dependency Installed:
  vim-common.i386 2:7.0.109-7.el5                                               

Complete!
[root@testarossa-00-0c-29-47-8f-35 ~]#

List interfaces and IPs neatly

The following command gives a neat list of the Devices and their IPs / details without all the gruesome details.

ifconfig | egrep  "Link|inet"

A sample result would be:

[root@testarossa-00-0c-29-47-8f-35 vm]# ifconfig | egrep "Link|inet"
eth0 Link encap:Ethernet HWaddr 00:0C:29:47:8F:2B 
 inet addr:192.168.47.135 Bcast:192.168.47.255 Mask:255.255.255.0
eth1 Link encap:Ethernet HWaddr 00:0C:29:47:8F:35 
 inet addr:192.168.1.71 Bcast:192.168.1.255 Mask:255.255.255.0
lo Link encap:Local Loopback 
 inet addr:127.0.0.1 Mask:255.0.0.0
peth1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF 
vif0.1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF 
vif4.0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF 
virbr0 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF 
 inet addr:192.168.122.1 Bcast:192.168.122.255 Mask:255.255.255.0
xenbr1 Link encap:Ethernet HWaddr FE:FF:FF:FF:FF:FF 
[root@testarossa-00-0c-29-47-8f-35 vm]#