Saturday, 28 February 2015

Error - Could not open configuration file /etc/httpd/conf.d/nfsen.conf

During the installation of nfsen - a netflow monitoring system on my machine, I stumbled across this error after doing nfsen configuration:

Could not open configuration file /etc/httpd/conf.d/nfsen.conf

I checked all the permissions and they were correct. After some time, I realized that it is an SE-Linux issue!

[root@localhost html]# vim /etc/httpd/conf.d/nfsen.conf
[root@localhost html]# service httpd start
Starting httpd: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Could not open configuration file /etc/httpd/conf.d/nfsen.conf: Permission denied
                                                           [FAILED]
[root@localhost html]# ls -l /etc/httpd/conf/httpd.conf
-rw-r--r--. 1 apache apache 34418 Feb 28 21:52 /etc/httpd/conf/httpd.conf
[root@localhost html]# httpd -k start
[root@localhost html]# httpd -k stop
[root@localhost html]# sestatus
SELinux status:                 enabled
SELinuxfs mount:                /selinux
Current mode:                   enforcing
Mode from config file:          enforcing
Policy version:                 24
Policy from config file:        targeted

[root@localhost html]# chcon -t httpd_config_t /etc/httpd/conf.d/nfsen.conf
[root@localhost html]# service httpd start
Starting httpd:                                            [  OK  ]

Friday, 13 February 2015

ImportError: No module named version

I have installed python beaver package and wanted to install elasticsearch-curator. That's when I encountered this error:

File "/usr/lib64/python2.6/distutils/dist.py", line 975, in run_commands

        self.run_command(cmd)

      File "/usr/lib64/python2.6/distutils/dist.py", line 995, in run_command

        cmd_obj.run()

      File "<string>", line 12, in replacement_run

      File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2310, in load

        return self.resolve()

      File "/usr/lib/python2.6/site-packages/pkg_resources/__init__.py", line 2316, in resolve

        module = __import__(self.module_name, fromlist=['__name__'], level=0)

    ImportError: No module named version

It turned out that python-daemon package with the culprit!

To get rid of, do the following:
    # pip uninstall python-daemon
    # pip install python-daemon
  
    If you wish, you may install specific version also, say
    # pip install python-daemon==1.6.1
    # pip install beaver --upgrade
    # pip install elasticsearch-curator


Thursday, 12 February 2015

Elasticsearch - Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 51.0

While installing elasticsearch on my Scientific Linux 6.5, I encountered the following error:
[root@meg ELK]# Exception in thread "main" java.lang.UnsupportedClassVersionError: org/elasticsearch/bootstrap/Elasticsearch : Unsupported major.minor version 51.0
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:643)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:277)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:73)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:212)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:323)
        at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:294)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:268)
Could not find the main class: org.elasticsearch.bootstrap.Elasticsearch. Program will exit.
^C

This error is generated because JDK version on the system is not present or it needs to be updated.
I downloaded latest version of JDK from Oracle site - http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html




The steps to configure the latest java on the system are described below:

[root@meg ELK]# rpm -e elasticsearch
warning: /etc/elasticsearch/elasticsearch.yml saved as /etc/elasticsearch/elasticsearch.yml.rpmsave
[root@meg ELK]# rpm -ivh elasticsearch-
elasticsearch-1.4.0.noarch.rpm  elasticsearch-head-master.zip
[root@meg ELK]# rpm -ivh jdk-
jdk-7u71-linux-x64.rpm  jdk-8u31-linux-x64.rpm
[root@meg ELK]# rpm -ivh jdk-8u31-linux-x64.rpm
Preparing...                ########################################### [100%]
   1:jdk1.8.0_31            ########################################### [100%]
Unpacking JAR files...
        rt.jar...
        jsse.jar...
        charsets.jar...
        tools.jar...
        localedata.jar...
        jfxrt.jar...
[root@meg ELK]# ja
jar      java     javac    javadoc  javaws
[root@meg ELK]# java -version
java version "1.6.0_33"
OpenJDK Runtime Environment (IcedTea6 1.13.5) (rhel-1.13.5.0.el6_6-x86_64)
OpenJDK 64-Bit Server VM (build 23.25-b01, mixed mode)
[root@meg ELK]# ls -l /usr/share/java
java/       java-1.3.1/ java-1.4.0/ java-1.4.1/ java-1.4.2/ java-1.5.0/ java-1.6.0/ java-1.7.0/ javadoc/    java-ext/   java-utils/ javazi/
[root@meg ELK]# ls -l /usr/java/jdk1.7.0_71/
bin/                                jre/                                README.html                         THIRDPARTYLICENSEREADME.txt
COPYRIGHT                           lib/                                release
db/                                 LICENSE                             src.zip
include/                            man/                                THIRDPARTYLICENSEREADME-JAVAFX.txt
[root@meg ELK]# alternatives --install /usr/bin/java java /usr/java/jdk1.7.0_71/bin/java 2
[root@meg ELK]# alternatives --config java

There are 2 programs which provide 'java'.

  Selection    Command
-----------------------------------------------
*+ 1           /usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java
   2           /usr/java/jdk1.7.0_71/bin/java

Enter to keep the current selection[+], or type selection number: 2
[root@meg ELK]# java -version
java version "1.7.0_71"
Java(TM) SE Runtime Environment (build 1.7.0_71-b14)
Java HotSpot(TM) 64-Bit Server VM (build 24.71-b01, mixed mode)
[root@meg ELK]# rpm -ivh elasticsearch-
elasticsearch-1.4.0.noarch.rpm  elasticsearch-head-master.zip
[root@meg ELK]# rpm -ivh elasticsearch-1.4.0.noarch.rpm
Preparing...                ########################################### [100%]
   1:elasticsearch          ########################################### [100%]
### NOT starting on installation, please execute the following statements to configure elasticsearch to start automatically using chkconfig
 sudo /sbin/chkconfig --add elasticsearch
### You can start elasticsearch by executing
 sudo service elasticsearch start

[root@meg ELK]# vim /etc/elasticsearch/elasticsearch.yml
[root@meg ELK]# service elasticsearch start
Starting elasticsearch:                                    [  OK  ]

Friday, 6 February 2015

Find out which libraries being used by a program in linux

To find out the libraries being used by a software, use ldd. ldd will tell you what libraries are loaded by a particular piece of software. For example:

[psj@localhost ~]$ ldd /usr/bin/python
    linux-gate.so.1 =>  (0x00221000)
    libpython2.6.so.1.0 => /usr/lib/libpython2.6.so.1.0 (0x00222000)
    libpthread.so.0 => /lib/libpthread.so.0 (0x00ca4000)
    libdl.so.2 => /lib/libdl.so.2 (0x00cc1000)
    libutil.so.1 => /lib/libutil.so.1 (0x0723a000)
    libm.so.6 => /lib/libm.so.6 (0x00cd3000)
    libc.so.6 => /lib/libc.so.6 (0x00b0b000)
    /lib/ld-linux.so.2 (0x00ae9000)

To list libraries for the programs under execution, lsof is your best friend.

[psj@localhost ~]$ lsof -n -P +c 0 |grep udev
gnome-settings- 2227            psj  mem       REG      253,0    60160      69022 /lib/libudev.so.0.5.1
gnome-settings- 2227            psj  mem       REG      253,0    27456      69023 /usr/lib/libgudev-1.0.so.0.0.1
gnome-panel     2246            psj  mem       REG      253,0    60160      69022 /lib/libudev.so.0.5.1


Thanks to a great tip from Johannes B. Ullrich at SANS, ISC.

More details are available here - https://isc.sans.edu/forums/diary/What+is+using+this+library/19275/

Thursday, 5 February 2015

Fabric installation error - pkg_resources.DistributionNotFound: paramiko>=1.10

I wanted to install fabric package for automated deployments.  I was confident that I have installed all the dependent packages

# yum install python-devel
# yum install gmp-devel

I have also download latest version of gmplib and compiled it:

# tar -xvjf gmp-0.6.0.0a.tar.bz2
#./configure
#make
#make install

"gmplib" that comes with default CentOS installation is old and fabric reports time attack related vulnerabilities when running. More details - https://community.webfaction.com/questions/12199/libgmp-time-attack-vulnerability

# pip install meld3
# pip install ecdsa
# pip install pycrypto
# pip install paramiko
# pip install fabric

But, it was not going to be a smooth ride and I encountered an error:

Traceback (most recent call last):
  File "/usr/bin/fab", line 5, in <module>
    from pkg_resources import load_entry_point
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 2655, in <module>
    working_set.require(__requires__)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 648, in require
    needed = self.resolve(parse_requirements(requirements))
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 546, in resolve
    raise DistributionNotFound(req)
pkg_resources.DistributionNotFound: paramiko>=1.10

I tried many attempts in installing/re-installing/upgrading all the packages... The error will not going away... Frustrated, I checked my setup tools version:
psj@psj-desktop:~$ easy_install --version
setuptools 0.6

There after, I updated setup tools using pip:
# pip install setuptools --upgrade

You can also use:
# easy_install -U setuptools

All the python packages were re-installed once again using:
# pip install ecdsa --ignore-installed
# pip install pycrypto --ignore-installed
# pip install paramiko --ignore-installed
# pip install fabric --ignore-installed

The problem related to "paramiko" disappeared!!