Thursday, December 30, 2010

Name Name Name , What is in a Name, How to Name a machine

  • Whether the system is virtual.
  • Whether the system is in development or production.
  • What application or operating system is running on the system.
  • Whether it is the first, second, or third (etc.) of a sequence.

say a virtual server , for production use, exchange server, 001


VPxch001.yourcompanydomain.com

Thursday, November 18, 2010

Apache daily Logrotate in linux

Apache log rotation : access_logs etc...etc...

In Linux kernel, program daemons, firewalls, etc, generate their respective log files and they are everywhere. In fact, there are so many log files of various levels that sometimes, it can be a nightmare to maintain them.

Log files are one of the most important files where almost all precious and sometimes unnecessary information are stored in regard to your server’s running state.

tail -f /var/log/messages ” is the command if you want to get feel and see the actual current logs generated by various daemons running on your system.

Now if your server also has a Apache Web server running and you want to manage their respective logs in your own fashion, then the following information might help you out.

How to see them

tail -f /var/log/httpd/access_log

First of all, you will need the program called “logrotate”. Logrotate is very useful utility which can rotate log files and archive them in a location that you specify. We will be using “logrotate” in conjunction with “cron“.

By Default the logrotate.conf file have weekly rotation of logs and logs are kept for 4 weeks.

cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files daily
weekly

# keep 4 weeks worth of backlogs
rotate 4

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
minsize 1M
create 0664 root utmp
rotate 1
}


if you want to change them then you have to change the
weekly ---->daily
rotation
4---->2
like below.....

cat /etc/logrotate.conf
# see "man logrotate" for details
# rotate log files daily
daily

# keep 4 weeks worth of backlogs
rotate 2

# create new (empty) log files after rotating old ones
create

# uncomment this if you want your log files compressed
#compress

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

# no packages own wtmp -- we'll rotate them here
/var/log/wtmp {
monthly
minsize 1M
create 0664 root utmp
rotate 1
}

# system-specific logs may be also be configured here.


or you can use command to do the same

perl -pi -e 's/weekly/daily/' /etc/logrotate.conf
perl -pi -e 's/rotate 4/rotate 2/' /etc/logrotate.conf

To cross check
logrotate -dv /etc/logrotate.d/httpd

Thursday, November 11, 2010

USB drive format by linux machine

check you drive in /var/log/messeges for the device.

#mkfs.vfat /dev/sdxx

now mount it

#mount -t vfat /dev/sdxx /media/usbdir

#umount /media/usbdir

How to check files in linux without comments

grep -v '#' /etc/httpd/conf/httpd.conf > /tmp/httpd.conf

Backup of Important Files in linux

Vi MyBackupFiles.txt

/etc/passwd
/etc/users
/etc/groups
/home/userName

save and exit by :wq

now

# tar -zcf backup-`date +%Y-%m-%d`.tar.gz -T /MyBackupFiles.txt

Mail Send by command line

# Mail -s “Hello world” abc@xyz.com

#echo | mutt -a mybackup.tar -s “daily backup” abc@mydomain.com

#printf “Hello\nWorld” | mail abc@xyz.com

#printf “This is the main body of the mail\n with line break” | mail -s “Subject of the Email” to@abc.com -f from@abc.com

# echo “Welcome to Jungle ” | mail -s “Hello world” abc@xyz.com -c pqr@xyz.com -b ghi@xyz.com

#( df -h; free -m ) | mail -s "disk and RAM report" abc@xyz.com

Wednesday, November 10, 2010

Adding second harddisk to ESXi

Under "Configuration > Storage"
Click "Add Storage..."
Choose the new disk, and go.

or

If you are in a non-production environment you just :
- down the server
- put into the server the new disk
- start the server and make attention to controller BIOS utility to create LUN
- create the new LUN using the new disk
- start and connect with VI client to ESX
- follow the procedure described bottom to discover and format the new disk as VMFS


Tuesday, October 19, 2010

Hyperic HQ on CentOS 5.5 and MySQL

1. First Start the Mysql
/etc/init.d/mysql start
2. Set the password for Mysql

/usr/bin/mysqladmin -u root password 'yourPassword'
3. Login to Mysql
#mysql -u root -p

4. CREATE USER 'hqadmin'@'localhost' IDENTIFIED BY 'hqadmin'

5 . GRANT ALL ON *.* TO 'hqadmin'@'localhost';

6. create database HQ;


7. mysql>

GRANT ALL PRIVILEGES
ON HQ.*
TO 'hqadmin'@'localhost'
IDENTIFIED BY 'hqadmin'
WITH GRANT OPTION;

8. FLUSH PRIVILEGES;




[nkumar@testpedia hyperic-hq-installer]$ ./setup.sh -mysql
Unpacking JRE to temporary directory /tmp/jre
Please ignore references to missing tools.jar
Unable to locate tools.jar. Expected to find it in /tmp/lib/tools.jar
Initializing Hyperic HQ 4.4.0 Installation...
Loading taskdefs...
Taskdefs loaded
Choose which software to install:
1: Hyperic HQ Server
2: Hyperic HQ Agent
You may enter multiple choices, separated by commas.
1,2
HQ server installation path [default '/home/hyperic']:

Enter the JDBC connection URL for the MySQL Enterprise / Community Server 5.x database [default 'jdbc:mysql://localhost:3306/HQ']:

Enter the username to use to connect to the database:
hqadmin
Enter the password to use to connect to the database.:
(again):
HQ agent installation path [default '/home/hyperic']:

Loading install configuration...
Install configuration loaded.
Preparing to install...
Validating agent install configuration...
Validating server install configuration...
Checking server webapp port...
Checking server secure webapp port...
Checking server JRMP port...
Checking server JNP port...
Checking database permissions...
Verifying admin user properties
Validating server DB configuration...
Installing the agent...
Looking for previous installation
Unpacking agent to: /home/hyperic/agent-4.4.0...
Installing the agent JRE ...
Unpacking JRE x86-linux-glibc2-jre-1_5.tar.gz to: /home/hyperic/agent-4.4.0...
Setting permissions on agent binaries...
Fixing line endings on text files...
--------------------------------------------------------------------------------
Installation Complete:
Agent successfully installed to: /home/hyperic/agent-4.4.0
--------------------------------------------------------------------------------

You can now start your HQ agent by running this command:

/home/hyperic/agent-4.4.0/bin/hq-agent.sh start

Installing the server...
Unpacking server to: /home/hyperic/server-4.4.0...
Creating server configuration files...
Copying binaries and libraries to server installation...
Copying server configuration file...
Copying server control file...
Copying server binaries...
Copying server db-upgrade files...
Copying server libs...
Setting up server database...
Installing the server JRE ...
Unpacking JRE x86-linux-glibc2-jre-1_6.tar.gz to: /home/hyperic/server-4.4.0...
Setting permissions on server binaries...
Fixing line endings on text files...
--------------------------------------------------------------------------------
Installation Complete:
Server successfully installed to: /home/hyperic/server-4.4.0
--------------------------------------------------------------------------------


You can now start your HQ server by running this command:

/home/hyperic/server-4.4.0/bin/hq-server.sh start

Note that the first time the HQ server starts up it may take several minutes
to initialize. Subsequent startups will be much faster.

Once the HQ server reports that it has successfully started, you can log in
to your HQ server at:

http://10.32.1.90:7080/
username: hqadmin
password: hqadmin

To change your password, log in to the HQ server, click the "Administration"
link, choose "List Users", then click on the "hqadmin" user.


Setup completed.
A copy of the output shown above has been saved to:
/home/hyperic/hyperic-hq-installer/installer-4.4.0/logs/hq-install.log

Deleting temporary JRE
[nkumar@testpedia hyperic-hq-installer]$

[nkumar@testpedia hyperic-hq-installer]$ /home/hyperic/server-4.4.0/bin/hq-server.sh start
Starting HQ server...
Initializing HQ server configuration...
Checking jboss jndi port...
Checking jboss mbean port...
Verify HQ database schema...
Unable to locate tools.jar. Expected to find it in /home/hyperic/server-4.4.0/lib/tools.jar
Loading taskdefs...
Taskdefs loaded
Booting the HQ server (Using JAVA_OPTS=-XX:MaxPermSize=192m -Xmx512m -Xms512m -XX:+HeapDumpOnOutOfMemoryError)...
HQ server booted.
Login to HQ at: http://127.0.0.1:7080/

[nkumar@testpedia agent-4.4.0]$ cd bin/
[nkumar@testpedia bin]$ ls
hq-agent.bat hq-agent.sh
[nkumar@testpedia bin]$ ./hq-agent.sh start
Starting HQ Agent...
- No token file found, waiting for Agent to initialize
[ Running agent setup ]
What is the HQ server IP address: 10.32.1.90
Should Agent communications to HQ always be secure [default=no]:
What is the HQ server port [default=7080]:
- Testing insecure connection ... Success
What is your HQ login [default=hqadmin]:
What is your HQ password:
What IP should HQ use to contact the agent [default=10.32.1.90]:
What port should HQ use to contact the agent [default=2144]:
- Received temporary auth token from agent
- Registering agent with HQ
- HQ gave us the following agent token
1287485373135-2043646290005887556-7886790376674905170
- Informing agent of new HQ server
- Validating
- Successfully setup agent
[nkumar@testpedia bin]$

Copy and paste the windows client agent to the windows machine.
open the command prompt

C:\hyperic-hq-agent-4.4.0\bin
C:\hyperic-hq-agent-4.4.0\bin>hq-agent.bat install
wrapper | Hyperic HQ Agent installed.

C:\hyperic-hq-agent-4.4.0\bin>hq-agent.bat start
C:\hyperic-hq-agent-4.4.0\bin>hq-agent.bat install
wrapper | Hyperic HQ Agent installed.

C:\hyperic-hq-agent-4.4.0\bin>hq-agent.bat start
wrapper | Starting the Hyperic HQ Agent service...
wrapper | Hyperic HQ Agent started.
[ Running agent setup ]
What is the HQ server IP address: 10.32.1.90
Should Agent communications to HQ always be secure [default=no]: yes
What is the HQ server SSL port [default=7443]:
- Testing secure connection ... Success
What is your HQ login [default=hqadmin]:
What is your HQ password:
What IP should HQ use to contact the agent [default=10.32.1.10]:
What port should HQ use to contact the agent [default=2144]:
- Received temporary auth token from agent
- Registering agent with HQ
- HQ gave us the following agent token
1287486594154-1703742189515298800-4312413996966000623
- Informing agent of new HQ server
- Validating
- Successfully setup agent

C:\hyperic-hq-agent-4.4.0\bin>

Tuesday, October 12, 2010

How to Install SUN Java on CentOS 5.5

1. Go to Sun website. http://www.oracle.com/technetwork/java/javase/downloads/index.html

2. From java SE download section , select Java JDK.

3. Choose linux for 32 bit or linux x64 for a 64 bit version from "platform" section and press continute.
a. for 64 bit java
4.wget -c "location of .bin file ". if you are using putty the just right click on the hyper link and "copy link location", then just right click on the putty.
5. ./jdk-6u22-linux-i586.bin?A................. or sh jdk-...whatever version you have downloaded
         5a. copy java from this location to /usr/java
6. alternatives –-install /usr/bin/java java /usr/java/jdk1.6.0_22/bin/java 2

7. alternatives --config java

9.There are 4 programs which provide 'java'.


Selection Command
-----------------------------------------------
1 /usr/lib/jvm/jre-1.4.2-gcj/bin/java
* 2 /usr/lib/jvm/jre-1.6.0-openjdk/bin/java
+ 3 /opt/jdk1.6.0_22/bin/java
4 /usr/java/jdk1.6.0_22/bin/java
Enter to keep the current selection[+], or type selection number: 4

10. check the java installation

sudo java -version
[sudo] password for nkumar:
java version "1.6.0_22"
Java(TM) SE Runtime Environment (build 1.6.0_22-b04)
Java HotSpot(TM) Client VM (build 17.1-b03, mixed mode, sharing)


Also install JPackage from http://jpackage.org/yum.php
configure the jpackage repositories in yum Create a new file /etc/yum.repos.d/jpackage.repo
and copy the file from jpackage site.

# yum install -y jpackage-utils


For detailed information please visit

http://wiki.centos.org/HowTos/JavaOnCentOS









 




Monday, October 4, 2010

500 firewall error after upgrading to exchange 2007 from exchange 2003

After upgrading from exchange 2003 to exchange 2007 we have started receiving " 500 Firewall Error" in the mail logs for outside domain.

The issue appears when we send the bulk mails/multiple recipient with same subject and time stamp. The issue was completely random. sometimes mail delivered and sometime not.


Fix:

We have cisco router and firewall at gateway. after some debugging we found that issue was due to IP INSPECT feature in cisco IOS.

After running the below command the issues disappears.

no ip inspect name SDM_LOW esmtp

http://www.cisco.com/en/US/docs/ios/security/command/reference/sec_i2.html

ip inspect name esmtp
no ip inspect name esmtp

Tuesday, September 28, 2010

Which process is eating away the memory

which process is using up your memory using ps, awk, sort

The following command lists all the process sorted based on the used memory size.

$ ps aux | awk '{if ($5 != 0 ) print $2,$5,$6,$11}' | sort -k2n

PID VSZ RSS COMMAND

3823 3788 484 /sbin/mingetty

3827 3788 484 /sbin/mingetty

3830 3788 484 /sbin/mingetty

3833 3788 488 /sbin/mingetty

3834 3788 484 /sbin/mingetty

3873 3788 484 /sbin/mingetty

2173 3796 568 /usr/sbin/acpid

1835 3800 428 klogd

1832 5904 596 syslogd

2054 5932 540 /usr/sbin/sdpd

2281 6448 360 gpm

The above command lists the PID, Used virutal memory size, Used resident set-size and process command. The output is sorted on VSZ.

While debugging performance issues, use this command to find out which process is using up the memory.

Find out Top 10 Largest File or Directory Using du, sort and head

du command shows summarized disk usage for each file and directory of a given location (/var/log/*). The output of a sort command is reversely sorted based on the size.

# du -sk /var/log/* | sort -r -n | head -10
1796    /var/log/audit
1200    /var/log/sa
612     /var/log/anaconda.log
512     /var/log/wtmp
456     /var/log/messages.4
92      /var/log/messages.2
76      /var/log/scrollkeeper.log
72      /var/log/secure
56      /var/log/cups
48      /var/log/messages.1

How to Resolve VC Service Problem - VC data base limit 4 GB




Posting this with the permission of my colleague Mike


Problem:
Surface Problems:
No clients can connect to the Virtual Center; error usually states a problem with “remote computer”. The remote computer is the virtual center server. Upon checking the virtual center server, you should notice that the “VMWare virtual center server” service is not running. The Virtual Center service will not start. It repeatedly stops after attempting to start the service manually or after reboot (automatically).

Root Problem:
The Virtual Center Database was at the 4GB limit.






The first error I noticed was the “unexpectedly shutdown error” (first error shown above). After digging through the logs you may start to see other errors indicating a database problem.

Resolution:
Use KB article http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1000125
In short, do the following:
Stop services
Backup database
Run script to trim database size
Shrink database
Restart services

Stop/Start Virtual center services:
Log into the virtual center server, go to services and stop/start the VMWare VirtualCenter Server service

Backup Database for Virtual Center
We use MSSQL Express Database for our VC environment.
Open SQL Server Management Studio application; login in with windows authentication (default settings)

Browse to the database being used by Virtual Center – In our case VIM_VCDB



Right Click the DB, select tasks and backup. A backup window will appear:

Ensure that the appropriate DB is selected and that a FULL backup is selected.

Create a name for the backup and note where the backup will be located once complete. Then press OK.

Your backup will run and the progress bar (bottom left corner) will indicate when it is complete. This can take more than 30 minutes.

Run Script to clean up database:

I have downloaded the script on our virtual center server. It is located on the mtalbot desktop. The script can be downloaded from the KB article posted above.

I highly recommend that you watch the video in the KB article! It is short and easy to understand.

In short you need to open the script; it should open in SQL server management studio. YOU MUST CHANGE THE DATABASE TO THE VIRTUAL CENTER DATABASE VIM_VCDB.

Execute the script to get an idea of how many rows will be deleted.

There are two things that need to be adjusted in order to execute the script and delete rows.

1. The “SET @DELETE_DATA = 0 “

a. If set to 0, then no data will be deleted.

b. If set to 1, then data will delete from the DB

2. The “SET @CUTOFF_DATE = GETUTCDATE – 180”

a. Change the number to the amount of days you would like to delete data

b. A suggestion is to delete minimal days and review the size of your database. If you are comfortable with the size of the database, you do not need to delete more days.



Notes about Database and Script:

*SQL Express has a data limit size of 4GB. If our database is approaching or at 4GB this is when we run into this problem. We need to backup database, trim records from db.

*The SQL script will delete tasks, events, and performance data. Simply comment or delete the applicable section of the script if any of these items are not to be purged.

*You can build a new query to monitor the transaction log progress. This will tell you how the log files and space are being updated during the execution of the original script run.

Again, review the video in the KB article for more information.



Shrink Database:

Open SQL Server Management

Browse to the database being used by Virtual Center – In our case VIM_VCDB



Right Click the DB, select tasks, shrink and database.

A window will pop up to allow you to manage the process, review your settings and click OK. Verify you are working with the correct DB. Also, note the size and free space available.



The progress bar in the bottom left corner will let you know when the process is complete.

Once the shrink is complete, restart the server or service for VMWare Virtual Center Server.

Stop/Start Virtual center services:

Log into the virtual center server, go to services and stop/start the VMWare VirtualCenter Server service