Showing posts with label CentOS. Show all posts
Showing posts with label CentOS. Show all posts

Wednesday, February 8, 2017

Configuring 2 Gateways on the same Linux Box permanently

Suppose you have 2 network on a PC says
192.168.1.5/24 (eth0 - Private Network)
172.16.10.4/24 (eth1 - Public Network)

Let's assume the 172.16.10.254 is the Default Gateway for 172.16.10.0 network. If there is a router at 192.168.1.254 for the internal network and you wish to connect to other networks says 192.168.5.0 192.168.6.0 and 192.168.7.0 networks. You will need to add "static routes" to these networks

route add -net 192.168.5.0 netmask 255.255.255.0 gw 192.168.1.254
route add -net 192.168.6.0 netmask 255.255.255.0 gw 192.168.1.254
route add -net 192.168.7.0 netmask 255.255.255.0 gw 192.168.1.254


To make the setting permanent, edit /etc/sysconfig/network-scripts/route-eth0
192.168.5.0/24 via 192.168.1.154 dev eth0 
192.168.6.0/24 via 192.168.1.154 dev eth0 
192.168.7.0/24 via 192.168.1.154 dev eth0 

To check the setting is ok
# ip route show

Wednesday, January 18, 2017

SMB Security Best Practices by US-Cert

Taken from  SMB Security Best Practices

US-CERT recommends that users and administrators consider:
  • disabling SMB v1 and
  • blocking all versions of SMB at the network boundary by blocking TCP port 445 with related protocols on UDP ports 137-138 and TCP port 139, for all boundary devices.
US-CERT cautions users and administrators that disabling or blocking SMB may create problems by obstructing access to shared files, data, or devices. The benefits of mitigation should be weighed against potential disruptions to users. For more information on SMB, please review Microsoft Security Advisories 2696547 (link is external) and 204279 (link is external)

Monday, January 16, 2017

Unable to spin down CD-ROM

I have an interesting issues today. My CD-ROM fail to spin down and there is a faulty disk inside the CD-ROM.

Inside the /var/log/messages
Buffer I/O error on device sr0, logical block 0 Error

There is no way you can un-mount the CDROM by the tradtional umount /dev/sr0. If you do a
# ps -afe|grep sr0
user1   11061  9280  0 12:43 pts/0 /sbin/blkid -o udev -p -u noraid /dev/sr0

To do a quick resolve, you can kill the process ID associated with /sbin/blkid -o udev -u noraid /dev/sr0
# kill -9 11061

The CD-ROM should stop spinning

Tuesday, January 3, 2017

Creating a Local Directory Repository to act like a local media for CentOS 6

Just say you wants a local Directory Repository to act like a local media. This happens when you wish to do yum local install from a directory of RPMs only instead of pulling directly from Internet repository.

1. At /etc/yum.repos.d/, create a local repo, something like

# vim /etc/yum.repos.d/local.repo

2. Inside the /etc/yum.repos.d/local.repo,

[myrepo]
name=My Local Repo
baseurl=file:///home/user1/RPM
enabled=1
gpgcheck=0

One more thing you may want to know is that the RPMs from the CentOS Disks including repomd.xml be copied into /home/user1/RPM

3. Disabled the rest of the Repo. For example,
# yum-config-manager --disable rpmforge

4. The Yum will pull from the enabled Repository only.

Tuesday, December 20, 2016

Compiling glibc-2.14 on CentOS 6

Step 1: Download glibc-2.14 from GNU Site
# wget http://ftp.gnu.org/gnu/glibc/glibc-2.14.tar.gz

Step 2: Untar and Preparation
# tar zxvf glibc-2.14.tar.gz
# cd glibc-2.14
# mkdir build
# cd build

Step 3: Compile and install
# ../configure --prefix=/usr/local/glibc-2.14
# make -j8
# make install

Wednesday, October 12, 2016

Blank Screen with VNCServers on CentOS 6

I was getting a blank screen when I do a launch vncserver session and my /home/user1/.vnc/xstartup
is like this:
#!/bin/sh

[ -r /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
export LANG
export SYSFONT
vncconfig -iconic &
unset SESSION_MANAGER
unset DBUS_SESSION_BUS_ADDRESS
OS=`uname -s`
if [ $OS = 'Linux' ]; then
  case "$WINDOWMANAGER" in
    *gnome*)
      if [ -e /etc/SuSE-release ]; then
        PATH=$PATH:/opt/gnome/bin
        export PATH
      fi
      ;;
  esac
fi
if [ -x /etc/X11/xinit/xinitrc ]; then
  exec /etc/X11/xinit/xinitrc
fi
if [ -f /etc/X11/xinit/xinitrc ]; then
  exec sh /etc/X11/xinit/xinitrc
fi
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &

After I remodify the xstartup, it WORKED!
#!/bin/sh
# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources

xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &

Tuesday, October 11, 2016

Resolve Leap Second Issues in Red Hat Enterprise Linux

Taken from Resolve Leap Second Issues in Red Hat Enterprise Linux

Leap seconds are a periodic one-second adjustment of Coordinated Universal Time(UTC) in order to keep a system's time of day close to the mean solar time. However, the Earth's rotation speed varies in response to climatic and geological events, and due to this, UTC leap seconds are irregularly spaced and unpredictable.

Upcoming Leap Second Events:
The next leap second will occur on 2016 December 31, 23h 59m 60s UTC.

Environment:

Red Hat Enterprise Linux versions 4
Red Hat Enterprise Linux versions 5
Red Hat Enterprise Linux versions 6
Red Hat Enterprise Linux versions 7

Scope:
Customers running highly time-sensitive or un-patched RHEL servers.

Severity:
The severity depends on how far behind the customer in on updating RHEL and how sensitive their operations are to time adjustments. Some customers will just appreciate the news. Others running un-patched servers may experience kernel hangs.

Description:
Another leap second will be added on December 31, 2016.
Customers running RHEL servers that are completely patched and running NTP should not be concerned. (Applications should be fine, too, but it is always best to check with one's vendors.)
Customers running completely patched RHEL servers but not NTP will find their systems' times off by 1 second. Customers will need to manually correct that.
Customers running un-patched servers that cannot update their kernel, ntp and tzdata packages to at least the latest versions listed in the below document's "Known Issues" section's links should contact our Support Center for further assistance.

Resource:
Resolve Leap Second Issues in Red Hat Enterprise Linux: https://access.redhat.com/articles/15145#event

Friday, September 23, 2016

X Unable to launch

I was trying to launch X Windows after yum install  yum groupinstall "Desktop" "Desktop Platform" "General Purpose Desktop"

 But I was not able to launch X. Instead I got

Fatal server error:
[ 9491.484] could not open default font 'fixed'
[ 9491.484] (EE)
Please consult the CentOS support
at http://wiki.centos.org/Documentation
for help. (done)
[ 9491.484] (EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.

To solve this,
# yum -y install libXfont

Tuesday, March 22, 2016

Running ld in verbose mode

This really helped to find out in more details when there is an ld issues

ld -lfftw --verbose

attempt to open /usr/x86_64-redhat-linux/lib64/libfftw.so failed
attempt to open /usr/x86_64-redhat-linux/lib64/libfftw.a failed
attempt to open /usr/local/lib64/libfftw.so failed
attempt to open /usr/local/lib64/libfftw.a failed
attempt to open /lib64/libfftw.so failed
attempt to open /lib64/libfftw.a failed
attempt to open /usr/lib64/libfftw.so failed
attempt to open /usr/lib64/libfftw.a failed
attempt to open /usr/x86_64-redhat-linux/lib/libfftw.so failed
attempt to open /usr/x86_64-redhat-linux/lib/libfftw.a failed
attempt to open /usr/lib64/libfftw.so failed
attempt to open /usr/lib64/libfftw.a failed
attempt to open /usr/local/lib/libfftw.so failed
attempt to open /usr/local/lib/libfftw.a failed
attempt to open /lib/libfftw.so failed
attempt to open /lib/libfftw.a failed
attempt to open /usr/lib/libfftw.so failed
attempt to open /usr/lib/libfftw.a failed
ld: cannot find -lfftw

Wednesday, January 27, 2016

Set hostname for CentOS 7 using hostnamectl

1. Listing hostname using "hostnamectl" or "hostnamectl status"

[root@localhost ~]# hostnamectl
   Static hostname: helloworld.com
         Icon name: computer-server
           Chassis: server
        Machine ID: aaaaaaaaaaaaa
           Boot ID: ddddddddddd
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-327.el7.x86_64
      Architecture: x86-64

2.Setting static host-name using hostnamectl

# hostnamectl set-hostname "helloworld.com" --static

3. Delete static host-nameusing hostnamectl
# hostnamectl set-hostname "" --static

Tuesday, January 26, 2016

Listing more information on an rpm file

1. List the RPM to which a file belongs
# rpm -qa |grep  gcc
gcc-4.4.7-16.el6.x86_64
gcc-gnat-4.4.7-16.el6.x86_64
gcc-objc++-4.4.7-16.el6.x86_64
libgcc-4.4.7-16.el6.x86_64
gcc-c++-4.4.7-16.el6.x86_64
gcc-gfortran-4.4.7-16.el6.x86_64
gcc-java-4.4.7-16.el6.x86_64
gcc-objc-4.4.7-16.el6.x86_64

2. List all files from an installed package:
# rpm -qpl rpmforge-release-0.5.2-2.el6.rf.x86_64.rpm
/etc/apt
/etc/apt/sources.list.d
/etc/apt/sources.list.d/rpmforge-extras.list
/etc/apt/sources.list.d/rpmforge-testing.list
/etc/apt/sources.list.d/rpmforge.list
/etc/pki/rpm-gpg
/etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-dag
/etc/pki/rpm-gpg/RPM-GPG-KEY-rpmforge-fabian
/etc/smart
/etc/smart/channels
.....
.....

 List of dependent RPMs for a specific RPM package
# rpm -qaR htop
libc.so.6()(64bit)
libc.so.6(GLIBC_2.2.5)(64bit)
libc.so.6(GLIBC_2.3)(64bit)
libc.so.6(GLIBC_2.3.4)(64bit)
libc.so.6(GLIBC_2.4)(64bit)
libm.so.6()(64bit)
libm.so.6(GLIBC_2.2.5)(64bit)
libncursesw.so.5()(64bit)
libtinfo.so.5()(64bit)
rpmlib(CompressedFileNames) <= 3.0.4-1
rpmlib(FileDigests) <= 4.6.0-1
rpmlib(PayloadFilesHavePrefix) <= 4.0-1
rtld(GNU_HASH)
rpmlib(PayloadIsXz) <= 5.2-1

Saturday, December 26, 2015

Disabling selinux without restart on CentOS

Do the following

# setenforce 0
To verify that the selinux has been changed from enforcing to permissive which will not block anything, but warn only

# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   permissive
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted

Thursday, October 29, 2015

LibGL Error. Unable to load driver swrast_dri.so

If you encounter the error when you run applications, says MATLAB

libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast

You need to install mesa-libGLU*.x86_64 and mesa-libGLU*.i686

yum install  mesa-libGLU*.i686 mesa-libGLU*.x86_64

Tuesday, October 27, 2015

kipmi0 taking excessive CPU resources

This article kipmi0 problem provides a good explanation of kipmi0 problem. But it did not work on me. Instead, this modification of kipmid parameters

# echo 50 > /sys/module/ipmi_si/parameters/kipmid_max_busy_us

This keep the kipmi0 to 5% of the CPU

Wednesday, August 26, 2015

udev: renamed network interface eth0 to eth2

I was encountering this error when I start the network

# dmesg |grep eth0 
udev: renamed network interface eth0 to eth2

This occurs when you clone or change the NIC hardware and the OS still retain the old interface information in /etc/udev/rules.d/70-persistent-net.rules.

Just delete /etc/udev/rules.d/70-persisitent-net.rules and reboot the system so the Linux can rebuild the /etc/udev/rules.d/70-persistent-net.rules that match the replaced NIC hardware.

# rm  /etc/udev/rules.d/70-persistent-net.rules
# reboot

Thursday, August 20, 2015

No irq handler for vector on CentOS 6

If you are getting error messages on the /var/log/messages on your CentOS 6. You may want to see Redhat Bugzilla "No irq handler for vector" error, sluggish system"


Aug 20 11:22:58 node1 kernel: do_IRQ: 2.135 No irq handler for vector (irq -1)

Step 1: Edit Grub Bootloader. Add the pci=nomsi,noaer to the end of the kernel options

# vim /boot/grub.menu.1st

default=0
timeout=5
splashimage=(hd0,0)/grub/splash.xpm.gz
hiddenmenu
title CentOS 6 (2.6.32-504.el6.x86_64)
        root (hd0,0)
        kernel /vmlinuz-2.6.32-504.el6.x86_64 ro root=/dev/mapper/vg_cherry-lv_root rd_NO_LUKS  KEYBOARDTYPE=pc KEYTABLE=us LANG=en_US.UTF-8 rd_NO_MD rd_LVM_LV=vg_cherry/lv_root SYSFONT=latarcyrheb-sun16 crashkernel=128M rd_LVM_LV=vg_cherry/lv_swap rd_NO_DM rhgb quiet pci=nomsi,noaer
        initrd /initramfs-2.6.32-504.el6.x86_64.img

Step 2: Disable irqbalance daemon
# service irqbalance stop
# chkconfig --levels 2345 irqbalance off

Step 3: Reboot the System
# reboot 

References:
  1.  Red Hat Bugzilla – Bug 225399
  2.  No irq handler for vector

Friday, August 14, 2015

Fixing Rsync out of memory Issues

If you are doing rsync and you encountered this error like rsync out of memory, you may want to take a look.a this article (Rsync out of memory? Try this...). Need to add an additional parameter (--no-inc-recursive) to the rsync commands.

According to the article, the the out of memory failure occured when  rsync attempts to load all the filenames and info in to RAM at startup. For example,

# rsync -lH -rva --no-inc-recursive --progress gromacs remote_server:/usr/local

References:
  1. Commonly Used rsync Arguments

Wednesday, August 12, 2015

Cannot retrieve metalink for repository: epel. Please verify its path and try again

I was doing a yum install and I encountered an error

# yum install libstdc++-4.4.7-16.el6.x86_64
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
Error: Cannot retrieve metalink for repository: epel. 
Please verify its path and try again

The correct fix is to update your SSL certificates.
# yum upgrade ca-certificates --disablerepo=epel -y

Yum install again. You should be able to work.
# yum install libstdc++-4.4.7-16.el6.x86_64

Error when installing libXrender for CentOS 6

If you do encountered an issue such as this. Apparently, there is a incompatibility between llibXi-1.7.2-2.,/pre>2.el6.i686 != libXi-1.6.1-3.el6.x86_64

# yum install libXrender

Error:  Multilib version problems found. This often means that the root
       cause is something else and multilib version checking is just
       pointing out that there is a problem. Eg.:

         1. You have an upgrade for libXrender which is missing some
            dependency that another package requires. Yum is trying to
            solve this by installing an older version of libXrender of the
            different architecture. If you exclude the bad architecture
            yum will tell you what the root cause is (which package
            requires what). You can try redoing the upgrade with
            --exclude libXrender.otherarch ... this should give you an error
            message showing the root cause of the problem.

         2. You have multiple architectures of libXrender installed, but
            yum can only see an upgrade for one of those arcitectures.
            If you don't want/need both architectures anymore then you
            can remove the one with the missing update and everything
            will work.

         3. You have duplicate versions of libXrender installed already.
            You can use "yum check" to get yum show these errors.

       ...you can also use --setopt=protected_multilib=false to remove
       this checking, however this is almost never the correct thing to
       do as something else is very likely to go wrong (often causing
       much more problems).

       Protected multilib versions: libXrender-0.9.8-2.1.el6.i686 != libXrender-0.9.7-2.el6.x86_64
 You could try using --skip-broken to work around the problem

To resolve the issue, you have to install libXrender-0.9.8-2.1.el6.x86_64

# yum install libXrender-0.9.8-2.1.el6.x86_64

Finally, do a

# yum install libXrender

Error when installing libXi for CentOS 6

If you do encountered an issue such as this. Apparently, there is a incompatibility between llibXi-1.7.2-2.,/pre>2.el6.i686 != libXi-1.6.1-3.el6.x86_64

# yum install libXi 

Error:  Multilib version problems found. This often means that the root
       cause is something else and multilib version checking is just
       pointing out that there is a problem. Eg.:

         1. You have an upgrade for libXi which is missing some
            dependency that another package requires. Yum is trying to
            solve this by installing an older version of libXi of the
            different architecture. If you exclude the bad architecture
            yum will tell you what the root cause is (which package
            requires what). You can try redoing the upgrade with
            --exclude libXi.otherarch ... this should give you an error
            message showing the root cause of the problem.

         2. You have multiple architectures of libXi installed, but
            yum can only see an upgrade for one of those arcitectures.
            If you don't want/need both architectures anymore then you
            can remove the one with the missing update and everything
            will work.

         3. You have duplicate versions of libXi installed already.
            You can use "yum check" to get yum show these errors.

       ...you can also use --setopt=protected_multilib=false to remove
       this checking, however this is almost never the correct thing to
       do as something else is very likely to go wrong (often causing
       much more problems).

       Protected multilib versions: libXi-1.7.2-2.2.el6.i686 != libXi-1.6.1-3.el6.x86_64
 You could try using --skip-broken to work around the problem

To resolve the issue, we have to do a

# yum install libXi-1.7.2-2.2.el6.x86_64
and you will see quite a list of updates to some core libraries. Finally, you can do a

# yum install libXi