CyberKeeda In Social Media
Showing posts with label RHEL 6.X. Show all posts
Showing posts with label RHEL 6.X. Show all posts

Linux Command to find Hard disk serial number and details.


Most of the times, when a linux system contains more then 1 hard drives and during the process of re installation to keep the user data safe and simply format the system without effecting the user data placed in another physical drive, we face challenges while discriminating hardisks by sda, sdb, sdc

The best approach is to identify the hard disk serial number and the apply actions accordingly.

So in my case i have two hard disks as sda and sdb one hard disk has system files and configurations and one has user data 

I have identified this using pvs command

[root@cyberkeeda ~]# pvs

     PV         VG       Fmt  Attr PSize   PFree
  /dev/sda2  rootvg   lvm2 a--u 465.25g    0

  /dev/sdb1  homevg lvm2 a--u 465.75g    0


I can easily identify from here, which hdd has root file, system files installed within it.

here sda  -- system files
       sdb  -- user data

Find the hard disk details from the below mentioned commands.

hdparm


[root@cyberkeeda ~]# hdparm -I /dev/sd? | grep 'Serial\ Number'

Output will look like

       Serial Number:      WD-WCC2SFS30435
       Serial Number:      WD-WCC2HEFS25680


One can also use lshw or smartctl to fetch more details of hard drives

lshw

[root@cyberkeeda ~]# lshw -class disk

smartctl

[root@cyberkeeda ~]#  smartctl -i /dev/sda

If you are missing those tools, just install following packages

# apt-get install smartmontools
# yum install  smartmontools

# apt-get install lshw
# yum install lshw

Read more ...

How to install VMWare tools from rpm using VMWare repository.



We got this requirement, when our Linux beginners folks tried to install the vmware tools from source / tar ball, they went through a lot of difficulties.

Everyone is not so comfortable while installing any application from source code, and some times i too went through a lot of challenges , the best fix is find the relevant RPM fro it and install it from one line command at all.

Somehow, i managed to find the vmware-tools repository from vmware itself.

Find and download the appropriate repos that fulfill your requirement:  

http://packages.vmware.com/tools/esx/latest/repos/index.html

http://packages.vmware.com/tools/esx/index.html.

And the below link is for latest packages and updates 

http://packages.vmware.com/tools/esx/latest/index.html 

Download and install the respective repo and install it from yum command

[root@localhost ~]# wget https://packages.vmware.com/tools/esx/latest/repos/vmware-tools-repo-RHEL6-10.0.9-1.el6.x86_64.rpm

[root@localhost ~]# rpm -Uvh vmware-tools-repo-RHEL6-10.0.9-1.el6.x86_64.rpm

Once done, you can simply run the YUM tool to install the packages

[root@localhost ~]#  yum install -y vmware-tools-esx-nox

And if your linux box has not access to internet, download from the corrosponding repos from your desktop and copy it into your linux box.

Once you have the packages, you can simply install it from rpm command line.

# rpm -Uvh vmware-tools-esx-nox-10.0.9-1.el6.x86_64.rpm

It might ask for dependencies too, you can find the dependencies from the same link , download and complete your installation.


Read more ...

PHP How to install, configure and enable ZIP Extension from source code within centos / rhel 6



So Enabling ZIP within PHP 5.6 dose not meet with the common approach of enabling a extension, Since it requires the libzip packages with a greater version of 0.11 or more.

RHEL ships libzip greater then 0.9 with RHEL 7.3 or more, hence the approach for enabling this must be slight different.


To avoid these challenges, we must go the way of installation of modules using PECL

Download Packages as required from --  http://pecl.php.net/package/zip

Here I have downloaded     zip-1.11.0.tgz

Now just execute the below mentioned PECL command.

# pecl install zip-1.11.0.tgz

# pecl uninstall XXXX

Though it will guide it to rest of the work but still I too want to add.

Locate your php.ini file and the

You should add "extension=zip.so" to php.ini

Once you are done, remember to reload/restart apache to apply the effect / changes.

Verify -: You should see, something like below within your phpinfo.php page






Read more ...

configure: error: and their fixes for RHEL / CentOS



This post is dedicated to the various config errors that we encounter while compiling any specific software from source code, the application / software may be different.
But their errors and fixes are same for everyone.

Here are some config errors and their fixes.


  • configure: error: mcrypt.h not found. Please reinstall libmcrypt
For RHEL/CENTOS/FEDORA

   #  yum install libmcrypt
    #   yum install  libmcrypt-devel

For Ubuntu
  
   #  sudo apt-get install libmcrypt-dev


   #  sudo apt-get install libmcrypt
  • configure: error: xml2-config not found. Please check your libxml2 installation
For RHEL/CENTOS/FEDORA

   #  yum install libxml2
    #   yum install libxml2-devel

For Ubuntu
  
   #  sudo apt-get install libxml2*

  • configure: error: Please reinstall the libcurl distribution – easy.h should be in /include/curl/

For RHEL/CENTOS/FEDORA

   #  yum install curl-devel
    #   yum install curl

For Ubuntu
  
   #  sudo apt-get install curl-dev



Read more ...

Remove old kernels safely just by single command.




Every time we upgrade our kernel, it consumes some of the valuable space from our /boot partition, definitely a time comes its asking to free some spaces out of it.

But to keep some old kernels within your boot menu is also useful, in case some of the kernel fails to boot other might help us to boot.

Now in case you are puzzled which one to remove to free up some space, here is the solution.
The best approach is to keep the latest kernel and remove the old one, now again which one is older or latest ?

Let don't think so much Redhat Linux has already created a solution for it already, before knowing the below mentioned command, i used to do the same stuffs manually by carefully moving the oldest kernels relevant files one by one manually.

Just move on now to the a scenario

Suppose i have three kernels installed and i want to keep the latest two and else remove other kernels.

Simply run the below mentioned command.

root@localhost ]-:#  package-cleanup --oldkernel --count=2

Count =2 means it will keep the latest 2 kernel and remove rest.

Thanks to one of my group members and friend Ravish Rana, for sharing such a useful stuff with us and thus I'm sharing with all the blog readers.
Read more ...

Redhat / CentOS - Show address bar with full path in Nautilus instead of breadcrumbs bar


We can obtain it from nautilus utility.







use the command.

[root@localhost] # nautilus --browser
Read more ...

USB Flash drive recognized within lsusb but not in fdisk



While on my way to format the Transcend flash drive, i went through the normal procedure to format an external usb storage.

I executed my command to check it's showing within the kernel or not.

# lsusb

and i found it as

Bus 002 Device 005: ID 066d:c09d Transcend Information, Inc. JetFlash

but when i executed the command fdisk -l  i couldn't find any extra drive as /dev/sdd as i already have three hardisk as /dev/sda, /dev/sdb, /dev/sdc

I figured out the error can be resolved using the command.

[root@localhost]#  modprobe usb_storage

and all fixed within this cammand at all.


Read more ...

Install Apache 2.4 on Centos / RHEL 6 from Source Code



Apache 2.4 is not shipped within RHEL / Centos 6.XX and even it's not within RHN or Centos central repository.

The best way is to download the tar ball and compile it within your host, since if you are installing it for your firm obviously It might be not allowed to directly download packages from internet.


Requirement / Dependencies

Even installation of apache from tarball needs two utilty , make sure both are installed within your server/host to proceed ahead

Apache Portable Runtime Packages.

  1. apr
  2. apr-util
  3. distache
  4. distache-devel
Download and install it one by one, as all are dependencies of one another, take a chill pill and go ahead.

Download APR packages from - http://apr.apache.org/
Download Distache packages from the link - Download
Download the apache tarball from apache's official website

Build and install the APR packages

[root@localhost]# mkdir -p /usr/local/httpd-build
Move and extract the apr packages into it.
Then execute the below mentioned command
[root@localhost httpd-build]# rpmbuild -tb apr-1.5.1.tar.bz2
[root@localhost httpd-build]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-1.5.1-1.x86_64.rpm /root/rpmbuild/RPMS/x86_64/apr-devel-1.5.1-1.x86_64.rpm
RPM packages are written to /root/rpmbuild/RPMS/ folder when built. We will only install apr-util and apr-util-devel packages necessary for Apache 2.4.9 build.
[root@localhost httpd-build]# rpmbuild -tb apr-util-1.5.3.tar.bz2
[root@localhost httpd-build]# rpm -Uvh /root/rpmbuild/RPMS/x86_64/apr-util-1.5.3-1.x86_64.rpm /root/rpmbuild/RPMS/x86_64/apr-util-devel-1.5.3-1.x86_64.rpm
While installing APR packages, if it shows dependencies of dustache packages , download and install the rpms provide din the above link.

Once APR packages were installed, we can proceed ahead with the installation of Apache 2.4.X

Extract the Apache 2.4 tarball downloaded from above provided link.

[root@localhost httpd-build]# tar -xvf httpd-2.4.xx
[root@localhost httpd-build]# cd httpd-2.4.xx

Configure.

[root@localhost httpd-build] ./configure --prefix=PREFIX
If it shows any error or you are not sure to add prefixes within it, go with default configuration by removing prefixes
[root@localhost httpd-build] ./configure

Compile

[root@localhost httpd-build] make

Install

[root@localhost httpd-build] make install

If all done successfully without any error, you are done with the installation.

Default Directory

[root@localhost httpd-build] cd /usr/local/apache2/

Customize

[root@localhost httpd-build] vim /usr/local/apache2/conf/httpd.conf

Test

[root@localhost httpd-build] sh /usr/local/apache2/bin/apachectl -k start
Go to your browser and hit http://localhost or http://your ip address
If all set you will get a page saying.

It Works !


Do comment, in case you ge any error while installing Apache 2.4, next blog post will be helpfull to you as it is relevant with Apache 2.4..
Installation of PHP 5.6 on Centos/RHEL 6

Read more ...

Configuring A High Availability Cluster (Heartbeat) On CentOS

This guide shows how you can set up a two node, high-availability HTTP cluster with heartbeat on

CentOS. Both nodes use the Apache web server to serve the same content.

Pre-Configuration Requirements

1. Assign hostname node01 to primary node with IP address 10.64.61.80 to eth0.

2. Assign hostname node02 to slave node with IP address 10.64.61.81.

Run the commands now...

Note: on node01

#uname –n

must return node01.

On node02

#uname –n

must return node02.

10.64.61.82 is the virtual IP address that will be used for our Apache webserver (i.e., Apache will

listen on that address).

Configuration

1. Download and install the heartbeat package. In our case we are using CentOS so we will install heartbeat with yum:

#yum install heartbeat

or download these packages:

heartbeat-2.08

heartbeat-pils- 2.08

heartbeat-stonith- 2.08

2. Now we have to configure heartbeat on our two node cluster. We will deal with three files. These are:

authkeys

ha.cf

haresources

3. Now moving to our configuration. But there is one more thing to do, that is to copy these files to the /etc/ha.d directory. In our case we copy these files as given below:

#cp /usr/share/doc/heartbeat-2.1.2/authkeys /etc/ha.d/

#cp /usr/share/doc/heartbeat-2.1.2/ha.cf /etc/ha.d/

#cp /usr/share/doc/heartbeat-2.1.2/haresources /etc/ha.d/

4. Now lets start configuring heartbeat. First we will deal with the authkeys file, we will use authentication method 2 (sha1). For this we will make changes in the authkeys file as below.


#vi /etc/ha.d/authkeys

Then add the following lines:

auth 2
2 sha1 test-ha

Change the permission of the authkeys file:

chmod 600 /etc/ha.d/authkeys

5. Moving to our second file (ha.cf) which is the most important. So edit the ha.cf file with vi:

#vi /etc/ha.d/ha.cf

Add the following lines in the ha.cf file:

logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
bcast eth0
udpport 694
auto_failback on
node node01
node node02

Note: node01 and node02 is the output generated by #uname -n

6. The final piece of work in our configuration is to edit the haresources file. This file contains theinformation about resources which we want to highly enable. In our case we want the webserver (httpd) highly available:


#vi /etc/ha.d/haresources

Add the following line:

node01 10.64.61.82 httpd

7. Copy the /etc/ha.d/ directory from node01 to node02:

#scp -r /etc/ha.d/ root@node02:/etc/

8. As we want httpd highly enabled let's start configuring httpd:

#vi /etc/httpd/conf/httpd.conf

Add this line in httpd.conf:

Listen 10.64.61.82:80

9. Copy the /etc/httpd/conf/httpd.conf file to node02:

#scp /etc/httpd/conf/httpd.conf root@node02:/etc/httpd/conf/

10. Create the file index.html on both nodes (node01 & node02):

On node01:

echo "node01 apache test server" > /var/www/html/index.html

On node02:

echo "node02 apache test server" > /var/www/html/index.html


11. Now start heartbeat on the primary node01 and slave node02:

#/etc/init.d/heartbeat start

12. Open web-browser and type in the URL:

http://10.64.61.82

It will show node01 apache test server.

13. Now stop the hearbeat daemon on node01:

#/etc/init.d/heartbeat stop

In your browser type in the URL http://10.64.61.82 and press enter.

It will show node02 apache test server.

14. We don't need to create a virtual network interface and assign an IP address (10.64.61.82)

to it. Heartbeat will do this for you, and start the service (httpd) itself. So don;t worry about

this.

Don't use the IP addresses 10.64.61.80 and 10.64.61.81 for services. These addresses are used

by heartbeat for communication between node01 and node02. When any of them will be used

for services/resources, it will disturb hearbeat and will not work. Be carefull!!!

Read more ...

Command to open GUI File Manager window using SSH



So if you too have a requirement for some freak Redhat/Centos GUI lovers and you have the only way to provide the same through SSH, probably it will help you out.

Like if you own a linux workstation there is a Linux Workstation located remotely and VNC access , Vino access is strictly prohibited over there and the only protocol that can be used is SSH, then this is the exactly the post you are looking for.

Here our approach is to toggle remote workstation's directory through GUI File-Manager instead of using cd path/to/some/ditectory

First of all, you need to simply ssh to remote linux Host.

# ssh youruser@10.x.x.x

The moment you logged into the remote host it will provide you the default shell with default location, it varies for all of us.

Now to toggle the directories further graphically, simply run the command gnome-open .


# gnome-open .

The moment you enter it, a pop up window will appear showing the default present folders and file.




  • If you want to toggle the know directory use it.


# gnome-open  /your/own/directory


Hope it will work for you too.





Read more ...

Fix - Amazon Recovery mount XFS file system has duplicate UUID problem (XFS: Filesystem sdc1 has duplicate UUID - can't mount )


While mounting my recovery volume on amazon web services , i found the error
Though i was using all sort of wright commands to mount the XSF filesytem directory.

Finally after checking the dmeg log i sort out that it's the same UUID as it's a backup clone at all.

To fix those things i googled out the command to mount the XFS filesystem without UUID

#mount -o nouuid /dev/sdc1 /mnt/recovery
Read more ...

Varnish-Cache Server Installation from Source Code ( tar.gz file )




Varnish is a program that can greatly speed up a Web site while reducing the load on the Web server. According to Varnish's official site, Varnish is a "Web application accelerator also known as a caching HTTP reverse proxy".


One can easily install Varnish-Cache server from yum directly, but this type we are going to install it by source code.

Download Varnish-Cache server   ---  Click here

Download and move it into /var/local directory

[root@cyberkeeda ~]# cd /var/local/

[root@cyberkeeda local]# tar xzf varnish-3.0.3.tar.gz


[root@cyberkeeda local]# cd  varnish-3.0.3

[root@cyberkeeda local]# sh autogen.sh

[root@cyberkeeda local]# configure

[root@cyberkeeda local]# make

[root@cyberkeeda local]#make install

One can find a installed folder by source code /var/local/varnish



Do comment in case of any issue while installation.



Read more ...

Sed Command to find and delete string from a file.




Scenario-:

So I have a huge host entry and configuration file named as hostname.cfg and a part of the content is shown below

 #cat hostname.cfg

        host_name                mixhost44x
        alias                         test machine
        contact_groups          admins
        hostgroups                mix-Users

Here i have a requirement to delete "  mixhost44x " from the file hostname.cfg.

Syntax  -:  sed 's/word-to-find//g' yourfile.txt > output.txt

So using the above command i can use it as.

                   sed 's/ mixhost44x//g' hostname.cfg > output.txt

  • Sed with backup

         # sed -i.bak 's/ mixhost44x//g' hostname.cfg 

  • Sed without backup 
          # sed -i 's/ mixhost44x//g' hostname.cfg 

  • Sed to find and delete lines starting with a pattern 

          # sed -i '/^your_pattern_or_word/d' hostname.cfg 
For Wild character like [ , use the below one liner
               sed -i '/^[[]/d' /tmp/iplists.txt






    Read more ...

    Want to delete few lines above and below certain string ( sed / awk )

    My requirement is to delete certain lines from my nagios file, might be you have some different requirement but the agenda remains the same.



    Lets take an example.

    Below mentioned is a part of my hostname.cfg file.

    My requiremnet is to make a shell script to delete lines begining from "define host {" upto "}"
    and the variable input ( read ) to fetch from user is just the host_name which can differ.

    here i want to delete all entries relevant to host_name --> hostname02x
    so i need to delete entries relevant to it beginning from "define host {" upto "}" , so that the file which earlier look

    #cat hostname.cfg

    define host{
                    use                     linux-server            ; Name of host template to use
                    host_name               hostname01x
                    hostgroups              COT-Servers
                    contact_groups          admins
                    alias                   FEA Preprod
                 }

    define host{
                    use                     linux-server            ; Name of host template to use
                    host_name               hostname02x
                    hostgroups              COT-Servers
                    contact_groups          admins
                    alias                   Grid Engine
                  }

    looks like...

    #cat hostname.cfg

    define host{
                    use                     linux-server            ; Name of host template to use
                    host_name               hostname01x
                    hostgroups              COT-Servers
                    contact_groups          admins
                    alias                   FEA Preprod
                 }


    Sed Method 


    # sed -i.bak '/define host/ {:a;/}/!{N;ba};/hostname02x/d}' hostname.cfg


    Explanation :

    • /define host/ : starting from /define host/
    • :a : a label for upcoming loop
    • /}/! : if } is not found...
    • N : append the line to the pattern space
    • ba : branch to label a to check if next line contains a }
    • when loop ends, } has been found
    • /hostname02x/d : deletes the pattern space if it matches /hostname02x/

    Awk Method


    awk -v RS="[}]\n" -v ORS="}\n" '!/hostname02x/' hostname.cfg


    Read more ...

    Recover fstab file.



    • Boot the system in rescue mode. 
    • fdisk -l shows the partision of / 
    • mount -o rw /dev/sda4?
    • vi /etc/fstab & put entry of file system manualy. or recover from /etc/mtab file.
    Read more ...

    How to configure/ increase /decrease screen brightness in Redhat / Centos / Ubuntu

    I was looking for the same and got after googling the same after a long time , hope this gonna help you out !!!

    For Ubuntu 
    #sudo apt-get install xbacklight
    
    For CentOS / Redhat 
    #yum install xbacklight
    then type this xbacklight -set 50
    there 50 stands for brightness range we can get it upto 100 from 0 .
    you can also increase and decrease the brightness from present value to specified level.as you mentioned if you want to increase to 10% from current value of brightness then you can give this
    xbacklight -inc 10
    
    and to decrease 10% you can give this
    xbacklight -dec 10 
    Read more ...
    Designed By Jackuna