Search This Blog

Tuesday, July 26, 2011

How to Download RPM using yum?

For example:
Consider a scenario where you would only need to download the rpm and not necessarily install it.

You will have to install an additional rpm called yum-downloadonly
yum install yum-downloadonly

Once the above rpm is installed all you have to do is run below command.
yum install sendmail-cf-8.13.8-2.el5 -y --downloadonly --downloaddir=/tmp

(In above example sendmail-cf-8.13.8-2.el5 rpm is downloaded and stored in /tmp .in your case it could be anything.)

The above command will only download the rpm and not necessarily installed it.

Note:
(I would recommend you to run above command where rpm getting downloaded is not already installed in my case it is sendmail-cf-8.13.8-2.el5 .Otherwise you will get an error saying rpm is already installed.You may remove the rpm using rpm -e )

Wednesday, July 20, 2011

NFS Monitoring

You can use iostat -n option for finding network statistic of NFS share.


Please Leave us with your comments and Queries/Suggestions.
I will try to reply asap.

Disk Monitoring using iostat

The iostat utility is run on virtual machine hosted on Virtual BOX.


# iostat
Linux 2.6.18-92.el5 (PuppetMaster) 07/20/2011

avg-cpu: %user %nice %system %iowait %steal %idle
0.05 0.08 0.65 0.04 0.00 99.18

Device: tps Blk_read/s Blk_wrtn/s Blk_read Blk_wrtn
sda 0.18 2.43 2.86 1430655 1686634
dm-0 0.43 1.63 2.86 963178 1686624
dm-1 0.00 0.00 0.00 896 0

Wednesday, July 13, 2011

Hdparm for beginners.

There are numerous Harddisk monitoring utilities are available and Hdparm is one of them.

Why use Hdparm?
Its a most commonly found utility on most of the linux distribution.
Simple and Easy to understand.

In this article we are going to see only two options available with Hdparm .
you may find following link useful to understand the definitions given below.

http://linux.about.com/od/lsa_guide/a/gdelsa44.htm

1) -t

Perform timings of device reads for benchmark and comparison purposes. For meaningful results, this operation should be repeated 2-3 times on an otherwise inactive system (no other active processes) with at least a couple of megabytes of free memory. This displays the speed of reading through the buffer cache to the disk without any prior caching of data. This measurement is an indication of how fast the drive can sustain sequential data reads under Linux, without any filesystem overhead. To ensure accurate measurements, the buffer cache is flushed during the processing of -t using the BLKFLSBUF ioctl. If the -T flag is also specified, then a correction factor based on the outcome of -T will be incorporated into the result reported for the -t operation.(Source Man pages)

If above definition is little difficult to understand ,see if this helps.
As you know for the very first read the data is first read from Disk and stored into RAM .For the next read for same data instead of taking the data from disk the data in RAM is read for faster reading.
Well -t option make sure only the timing between data being read from disk and stored into ram is calculated.

2) -T

Perform timings of cache reads for benchmark and comparison purposes. For meaningful results, this operation should be repeated 2-3 times on an otherwise inactive system (no other active processes) with at least a couple of megabytes of free memory. This displays the speed of reading directly from the Linux buffer cache without disk access. This measurement is essentially an indication of the throughput of the processor, cache, and memory of the system under test. If the -t flag is also specified, then a correction factor based on the outcome of -T will be incorporated into the result reported for the -t operation.

If above definition is little difficult to understand ,see if this helps.

Well -T option make sure only the timing between data being read from RAM is calculated.In this process Actual Disk read doesn't happen.

There are many options available but the options described in this article are very commonly used for storage monitoring.

hdparm output for my machine:
# hdparm -t /dev/sda

/dev/sda:
Timing buffered disk reads: 108 MB in 3.04 seconds = 35.51 MB/sec

# hdparm -T /dev/sda

/dev/sda:
Timing cached reads: 3496 MB in 1.99 seconds = 1756.56 MB/sec

Wednesday, July 6, 2011

Puppet Server and Client Installation and Configuration Version 2.7.1

Puppet Server & Client Installation & Configuration Version 2.7.1

Server Side Installation

Host Name: PuppetMaster

ruby-1.8.5-5.el5_4.8
ruby-libs-1.8.5-5.el5_4.8
Facter 1.6.0 (tar+gzip)
(http://www.puppetlabs.com/misc/download-options/)
puppet-2.7.1 (tar.gz)
(http://www.puppetlabs.com/misc/download-options/ )

Note :
Please follow above sequence for installation.)

A supported Ruby version. Ruby 1.8.5, 1.8.7, and 1.9.2 are fully supported (with a handful of known issues under 1.9.2); Ruby 1.8.1 is supported on a best-effort basis for agent use only. Other versions of Ruby are used at your own risk, and Ruby 1.8.6, 1.9.0, and 1.9.1 are not recommended for compatibility reasons.

To avoid any certification error Make sure following criteria’s are full filled
1) Make sure the time on puppet Server and puppet client is in sync.
2) Make sure that /etc/hosts file has proper entry on both puppet client and puppet server.

Installation Steps:

1) ruby-1.8.5-5.el5_4.8
# yum install ruby
Confirm the installation :
# rpm -qa | grep ruby
ruby-1.8.5-5.el5_4.8
ruby-libs-1.8.5-5.el5_4.8
# ruby --version
ruby 1.8.5 (2006-08-25) [i386-linux]

2) ruby-libs-1.8.5-5.el5_4.8
will get installed if you run yum install ruby.

4) Facter 1.6.0 (tar+gzip)
#gunzip facter-1.6.0.tar.gz
#tar -xvf facter-1.6.0.tar
#cd facter-1.6.0
#ruby install.rb
Confirm the installation.
# facter --version
1.6.0


5) puppet-2.7.1 (tar.gz)
#gunzip /install/puppet-2.7.1.tar.gz
#tar -xvf puppet-2.7.1.tar
#cd puppet-2.7.1
#ruby install.rb
Confirm the installation.
# puppet --version
2.7.1
#puppetmasterd --version
2.7.1
#puppetd --version
2.7.1
#puppetca --version
2.7.1


Configuration:
Step 1: Create manifests folder
#mkdir -p /etc/puppet/manifests

Step 2: place your site.pp file into it.
Content of site.pp file
{ "/etc/sudoers":
owner => root,group => root, mode => 440
}
Above lines ensures that /etc/sudoers files at client meets following requirement.
owner = root, group = root, mode = 440
Step 3: Start the puppet master.

# puppet master --mkusers
Note: Example given here demonstrates following
the basic puppet (2.7.1)
setup Getting started with puppet (2.7.1)
(A simple check to see the file permission is achieved through puppet)

Client Side Installation

Installation Steps:
Note :
There are no separate steps for puppet client installation. Whatever Installation steps are performed in Puppet Server needs to be done in puppet client as well.

Configuration Step

Step 1:

Run following command to implement the rules defined at Puppet server.

# puppet agent --server puppetmaster --waitforcert 60 –test

info: Creating a new SSL key for puppetclient.domain.com

warning: peer certificate won't be verified in this SSL session

info: Caching certificate for ca

warning: peer certificate won't be verified in this SSL session

warning: peer certificate won't be verified in this SSL session

info: Creating a new SSL certificate request for puppetclient.domain.com

info: Certificate Request fingerprint (md5): 72:C6:73:89:B9:69:D9:8D:93:69:C3:69:14:AD:7E:E2

warning: peer certificate won't be verified in this SSL session

warning: peer certificate won't be verified in this SSL session

warning: peer certificate won't be verified in this SSL session


Note:
For the First run you will need to register your client at server.
(Read further in this article to see how to register your client at server.)

After registration of client on Server you should get following response.

# puppet agent --server PuppetMaster --waitforcert 60 --test

info: Caching catalog for puppetclient.domain.com

info: Applying configuration version '1309406496'

info: Creating state file /var/lib/puppet/state/state.yaml

notice: Finished catalog run in 0.05 seconds

As /etc/sudoers file meet the puppet servers manifest we didn’t notice any change in above output.

# ls -ltr /etc/sudoers

-r--r----- 1 root root 3185 Jan 22 2009 /etc/sudoers

To actually see the changes at puppet client lets modify /etc/sudoers file .

[root@puppetclient tmp]# chmod 777 /etc/sudoers

[root@puppetclient tmp]# chown ftp:root /etc/sudoers

[root@puppetclient tmp]# ls -ltr /etc/sudoers

-rwxrwxrwx 1 ftp root 3185 Jan 22 2009 /etc/sudoers

Now when the permissions on /etc/sudoers is changed on puppet client .

We will run the command once again and check the output.

# puppet agent --server PuppetMaster --waitforcert 60 --test

info: Caching catalog for puppetclient.domain.com

info: Applying configuration version '1309406496'

notice: /Stage[main]//File[/etc/sudoers]/owner: owner changed 'ftp' to 'root'

notice: /Stage[main]//File[/etc/sudoers]/mode: mode changed '777' to '440'

notice: Finished catalog run in 0.11 seconds

Now check the permission.

[root@puppetclient tmp]# ls -ltr /etc/sudoers

-r--r----- 1 root root 3185 Jan 22 2009 /etc/sudoers

As you can see puppet master has implemented the rule on puppet client.


Register puppet client on puppet server:

Whenever a puppet client request for puppet certificate for the first time, client won’t get it unless server signs clients certificate at server end.

Here are the steps to sign clients certificate at server end.

Step 1:

List the available certificates

# puppetca -l

puppetclient.domain.com

Step 2:

Sign them

# puppetca -s puppetclient.domain.com

notice: Signed certificate request for puppetclient.domain.com

notice: Removing file Puppet::SSL::CertificateRequest puppetclient.domain.com at '/etc/puppet/ssl/ca/requests/puppetclient.domain.com.pem'

Note:
This is the default behavior and can be changed . But for the security reason its recommended not to set the server on auto signing mode.


How to find the port of particular application?

Question : How do I find the port which is used by a particular application ?
Answer :
Consider Tomcat application is running on port 8080.
To check whether the Tomcat is running or not.

Initially you need to understand the output presented by
netstat -ntpl .
In above case Tomcat is using java as their process so i grep with java. Your application might be using different name.

#netstat -ntpl | grep java
tcp 0 0 ::ffff:127.0.0.1:8005 :::* LISTEN 6375/java
tcp 0 0 :::8009 :::* LISTEN 6375/java
tcp 0 0 :::8080 :::* LISTEN 6375/java

You should see at least one java process and you can use ps to identify if this is Tomcat.

# ps -ef | grep 6375
root 6375 1 0 May18 pts/2 00:01:06 /usr/java/jdk1.6.0_20/bin/java -Djava.util.logging.config.file=/install/apache-tomcat-5.5.29/conf/logging.properties -Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager -Djava.endorsed.dirs=/install/apache-tomcat-5.5.29/common/endorsed -classpath /install/apache-tomcat-5.5.29/bin/bootstrap.jar -Dcatalina.base=/install/apache-tomcat-5.5.29 -Dcatalina.home=/install/apache-tomcat-5.5.29 -Djava.io.tmpdir=/install/apache-tomcat-5.5.29/temp org.apache.catalina.startup.Bootstrap start
root 9222 5091 0 18:29 pts/2 00:00:00 grep 6375

for killing the process just use.
kill -9

The above article is with reference to my question posted on below forum .
http://www.linuxquestions.org/questions/showthread.php?p=4010963&posted=1#post4010963