Monday, April 9, 2012

Linux- copy methods


Linux- copy methods

wget
Download a file

Download a file whose URL contains a “&” (note quotes)
wget http://www.example.com/min.php?page=home&user=ma
Draw an entire site (recursive download)
wget-r http://www.example.com/
Resume a download
wget-c http://www.example.com/xyz.html
Download files only an extension (here,. Jpg)
wget-A.jpg http://www.example.com/
Limit download speed
wget – limit-rate = 30k http://www.example.com/
Download via ftp (With authentication)
wget-r l4 ftp://username:password @ example.com /

If there are a list of pages, files, and so on that I want to grab for the script, I can list one URL-formatted item per line within a file. For example, if the file was ~/bin/getme, I would use:

wget -i ~/bin/data/getme

To download a copy of a complete web site, up to five levels deep, you use the -r option (for recursive):

wget -r site.com -o logfile

Instead of having the progress messages displayed on the standard output, you can save it to a log file with the -o option:

SCP

Copy the file "foobar.txt" from a remote host to the local host
$ scp your_username@remotehost.edu:foobar.txt /some/local/directory

Copy the file "foobar.txt" from the local host to a remote host


Copy the directory "foo" from the local host to a remote host's directory "bar"



Copy the file "foobar.txt" from remote host "rh1.edu" to remote host "rh2.edu"

$ scp your_username@rh1.edu:/some/remote/directory/foobar.txt \
your_username@rh2.edu:/some/remote/directory/

Copying the files "foo.txt" and "bar.txt" from the local host to your home directory on the remote host

$ scp foo.txt bar.txt your_username@remotehost.edu:~

Copy multiple files from the remote host to your current directory on the local host


$ scp your_username@remotehost.edu:~/\{foo.txt,bar.txt\}  .

RSYNC

$ rsync options source destination

Source and destination could be either local or remote. In case of remote, specify the login name, remote server name and location.

Synchronize Two Directories in a Local Server

$ rsync -zvr /var/dir1/ /root/dir2
 
-z  :enable compression
-v :verbose
-r    : recursive
-a : preserve time stamp
-d : sync the directory tree structure

Preserve timestamps during Sync using rsync -a


rsync -azv /var/dir1/ /root/dir2

rsync -arzv /var/dir1/ /root/dir2       (this will do recursively)
 
 
 
a = archive - means it preserves permissions (owners, groups), times, symbolic links, and devices.
r = recursive - means it copies directories and sub directories
v = verbose - means that it prints on the screen what is being copied 

Synchronize Only One File

To copy only one file, specify the file name to rsync command
 
rsync -v /var/singlefile /root/myfile/
 

Synchronize only the Directory Tree Structure (not the files)


rsync -v -d abc@192.168.200.10:/var/lib/ .

Use of "/" at the end of path:
When using "/" at the end of source, rsync will copy the content of the last folder.
When not using "/" at the end of source, rsync will copy the last folder and the content of the folder.

When using "/" at the end of destination, rsync will paste the data inside the last folder.
When not using "/" at the end of destination, rsync will create a folder with the last destination folder name and paste the data inside that folder.

Synchronize with the Directory Name
What if you wanted to not just copy all of the files under /myDir/, but also the /myDir/ directory name. Just leave off the last "/" after the "/myDir" directory name. This will tell rsync to copy the directory name and all files under that directory. On the remote server you will then see the directory structure /backups/myDir/.
rsync -avz /myDir user@remotemachine:/backups/

Incremental Backups using rsync

 
The following example will make an incremental backup of the directory /data/working/ and put a copy of any file that changes into a dated directory in /BACKUP/ . This can be used to keep a daily backup tree of any changed files and not have to overwrite the previous days files. Note that this method does need to copy the entire file if it changes as the new files are made in the directory named under current day.
 
rsync --backup --backup-dir=`date +%Y.%m.%d` -a /data/working/ /BACKUP/
 
LFTP




#!/bin/bash
HOST="your.ftp.host.dom"
USER="username" 
PASS="password"
LCD="/path/of/your/local/dir"
RCD="/path/of/your/remote/dir" 
lftp -c "set ftp:list-options -a;
open ftp://$USER:$PASS@$HOST;
lcd $LCD;
cd $RCD; 
mirror --reverse \
        --delete \
        --verbose \
        --exclude-glob a-dir-to-exclude/ \
        --exclude-glob a-file-to-exclude \
        --exclude-glob a-file-group-to-exclude* \
        --exclude-glob other-files-to-exclude"


Upload a file

lftp -e 'put /local/path/yourfile.txt; bye' -u user,password ftp.remote.com 

Download a file

lftp -e 'set net:timeout 10; get yourfile.txt; bye' -u user,password ftp.remote.com 

Mirroring / Recursive upload

When using the mirror command, LFTP is recursive by default.
Mirror everything from the /local/path to the root of the remote FTP site, including all subdirectories and their files. The -R switch means “reverse mirror” which means “put” [upload]. Remote path is simply /, the root.

lftp -e 'mirror -R /local/path/ /' -u user,password ftp.remote.com

Recursive Download

To mirror remote to local, just omit the -R param and swap remote path with local. Be careful with this. Don’t overwrite your local changes.

lftp -e 'mirror / /local/path/' -u user,password ftp.remote.com  

Special Characters in Username or Password

Special characters in your username or password must be escaped with backslashes:

lftp -e 'put /pathToyourfile.txt; bye' -u user,password\!\! ftp.remote.com



Wednesday, March 14, 2012

"device eth0 does not seem to be present, delaying initialization" Error CentOS 6.2 + VMware Clone

CentOS 6.2 Cloned VM are having this issue 

# ls /sys/class/net
eth1 lo

There is a device manager, udev, which stores the settings from the NIC of the vm prior to the cloning? process.? When you clone a vm it also changes the mac address of the NIC and as a result the vm sees it as a new NIC and assigns it to /dev/eth1.

As a result, we now have to edit the udev config file as well as the ifcfg-eth0 file to get the newly update virtual NIC card to operate on the eth0 device.

1. Delete 70-persistent-net.rules which is under /etc/udev/rules.d/ and reboot the machine

OR


First, edit: /etc/udev/rules.d/70-persistent-net.rules

# This file was automatically generated by the /lib/udev/write_net_rules
# program, run by the persistent-net-generator.rules rules file.
#
# You can modify it, as long as you keep each rule on a single
# line, and change only the value of the NAME= key.

# PCI device 0x8086:0x100f (e1000)
#SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:be:00:30", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"

# PCI device 0x8086:0x100f (e1000)
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:50:56:be:00:32", ATTR{type}=="1", KERNEL=="eth*", NAME="eth1"


Delete or comment the first SUBSYSTEM entry in the file.

Update the 'eth1' attribute in the remaining entry to 'eth0'

Edit /etc/sysconfig/network-scripts/ifcfg-eth0
Change the HWADDR to match the new mac address listed in the newly edited 70-persistent-net.rules file. eg in my case 00:50:56:be:00:32

like
DEVICE="eth0"
NM_CONTROLLED="yes"
ONBOOT=yes
HWADDR=00:50:56:BE:00:32
BOOTPROTO=static
 


Reeboot the machine.


Thursday, January 5, 2012

Add static route to linux

add a remote host

remote host 192.168.1.20
local gateway 10.1.1.20
route add -host 192.168.1.20 gw 10.1.1.20

add a remote network

route add -net 192.168.98.42 netmask 255.255.255.255 gw 192.168.99.1
 
check the route 
route -n
 
Delete a route
route del -net 10.41.41.0 netmask 255.255.255.0 gw 10.41.42.8
 
route add -net 192.56.76.0 netmask 255.255.255.0 dev eth0
adds a route to the network 192.56.76.x via "eth0". The Class C netmask modifier is not really necessary here because 192.* is a Class C IP address. The word "dev" can be omitted here.
 
To make the routing information persistent, add the “route add” line as seen above into the /etc/rc.local file.
Sample /etc/rc.local file.
or /etc/rc.d/rc.local

touch /var/lock/subsys/local
route add -net 10.41.41.0 netmask 255.255.255.0 gw 10.41.42.8



 


  
 

Wednesday, January 4, 2012

Error : Root File System Is Read-Only | linux based file system become read only

As a workaround, remount the Linux file system using this command to return it to the proper state:
 
mount -o remount /


Remount it. If /etc/fstab is correct, you can simply type:

mount -n -o remount /

If /etc/fstab is wrong, you must give the device name and possibly the
type, too: e.g.

mount -n -o remount -t ext2 /dev/hda2 /


VMware has identified a problem where file systems may become read-only after encountering busy I/O retry or SAN or iSCSI path failover errors.
 
The same behavior is expected even on a native Linux environment, where the time required for the file system to become read-only depends on the number of paths available to a particular target, the multi-path software installed on the operating system, and whether the failing I/O was to an EXT3 Journal. However, the problem is aggravated in an ESX host environment because ESX host manages multiple paths to the storage target and provides a single path to the guest operating system, which effectively reduces the number of retries done by the guest operating system.
 
These guest operating systems are affected:
  • RHEL5 (RedHat)
  • RHEL4 U6
  • RHEL4 U4
  • RHEL4 U3
  • SLES10
  • SLES9 SP3
  • Ubuntu 7.04 

    Note: This issue may affect other Linux distributions based on early 2.6 kernels as well, such as Ubuntu 7.04.
 

Monday, December 19, 2011

Focus back



You probably don’t want to admit it but you love distractions. In fact, just like monkeys, you get a shot of dopamine every time something pulls you in another direction. Why do you think you check your email so much?
Want to be more productive and get your focus back? There are no secret tricks here… do one thing at a time. Stop multitasking—it’s just another form of distraction.


Here are his tips for staying productive:
  1. Work backwards from goals to milestones to tasks. Writing “launch company website” at the top of your to-do list is a sure way to make sure you never get it done. Break down the work into smaller and smaller chunks until you have specific tasks that can be accomplished in a few hours or less: Sketch a wireframe, outline an introduction for the homepage video, etc. That’s how you set goals and actually succeed in crossing them off your list.
  2. Stop multi-tasking. No, seriously—stop. Switching from task to task quickly does not work. In fact, changing tasks more than 10 times in a day makes you dumber than being stoned. When you’re stoned, your IQ drops by five points. When you multitask, it drops by an average of 10 points, 15 for men, five for women (yes, men are three times as bad at multitasking than women). 
  3. Be militant about eliminating distractions. Lock your door, put a sign up, turn off your phone, texts, email, and instant messaging. In fact, if you know you may sneak a peek at your email, set it to offline mode, or even turn off your Internet connection. Go to a quiet area and focus on completing one task.
  4. Schedule your email. Pick two or three times during the day when you’re going to use your email. Checking your email constantly throughout the day creates a ton of noise and kills your productivity.
  5. Use the phone. Email isn’t meant for conversations. Don’t reply more than twice to an email. Pick up the phone instead. 
  6. Work on your own agenda. Don’t let something else set your day. Most people go right to their emails and start freaking out. You will end up at inbox-zero, but accomplish nothing. After you wake up, drink water so you rehydrate, eat a good breakfast to replenish your glucose, then set prioritized goals for the rest of your day. 
  7. Work in 60 to 90 minute intervals. Your brain uses up more glucose than any other bodily activity. Typically you will have spent most of it after 60-90 minutes. (That’s why you feel so burned out after super long meetings.) So take a break: Get up, go for a walk, have a snack, do something completely different to recharge. And yes, that means you need an extra hour for breaks, not including lunch, so if you’re required to get eight hours of work done each day, plan to be there for 9.5-10 hours.
for a complete article you can visit the below link

http://www.inc.com/ilya-pozin/7-things-highly-productive-people-do.html

Sunday, December 11, 2011

Monitoring Guidelines

  • Keep it simple stupid.
    • Start with simple monitoring, like PING to make sure that the host is up and standard checks like http, smtp and so on to make sure that standard services are up. Going from no monitoring to basic monitoring is a huge step and many organizations do not have the processes to handle more complex monitoring.
    • The next step is disk, CPU and memory on hosts. On network devices are port load, cpu load, network link.
    • Third step is to dig into bussiness critical applications and services.
  • Small iterations. Do not try to build a top of the line monitoring solution from day one. You will never leave the startup phase.
  • Let the monitoring solution pull the status instead of sending the status to the monitroing solution. This avoid complicated rules when different types of information is sent to the monitoring solution. So avoid sending SNMPtraps.
  • The monitoring solution is NOT a trashcan where to send tons of uninteresting garbage. It is far to common that HW vendors recommends to send thousands of unnecessary SNMPtraps to the monitoring solution and just a few is interesting. It is a nightmare to create the ruleset to figure out what is interesting, especially if there is dependencies where one message is interesting if another message has been sent before. The documentation is a badly written  MIB on a couple of hundered pages. In almost every case I’ve run into with this approch the implementation never ends and test cases are hard to create. When the systems are in production I can bet on that a critical event will occour which has not been taken care of and the production will stop. Managers will be upset, vendors will blame each other and customers will be angry.
  • Let the status be availiable easily:
    • via standard APIs, Perl and Bash is the most common.
    • SNMP via SNMPget instead of SNMPtraps
    • Status stored in a database, the monitoring solution can run SQL quries to get the status.
    • Commands the can be runned by the monitoring solution and the output parsed, or even better, exit codes are used and documented.
  • Normally it is not a good idea to read a log file to understand the status of of the software.
http://www.it-slav.net/blogs/2009/08/30/general-systems-and-network-management-guidelines-part-1/

Monday, November 7, 2011

How to Delete Exchange 2007 Logs manually | ESUTIL for intergrity Checking


Go to the bin directory of your exchange
C:\Program Files\Microsoft\Exchsrvr\bin>eseutil /mk  E:\Logs\e00.log

if you receive 
Operation terminated with error -1032 (JET_errFileAccessDenied, Cannot access file, the file is locked or in use) after 30.83 seconds.

that means that your data base is in mounted state, you have to dismount the exchange database and run the command again.


If the database is still mounted, use the following steps to dismount the database, and then run ESEUTIL:
  1. Start Exchange System Manager.
  2. Right-click the database that you want to dismount.
  3. Click All Tasks, and then click Dismount Store.
If you wish to use the ESEUTIL /k option on log files you'll need to stop the Microsoft Exchange Information Store service. To do so follow these steps:
  1. Start the Services applet in the Administrative Tools folder.
  2. Right-click the Microsoft Exchange Information Store service.
  3. Click Stop.
After the integrity check is over you must start the Microsoft Exchange Information Store service. To do so follow these steps:
  1. Start the Services applet in the Administrative Tools folder.
  2. Right-click the Microsoft Exchange Information Store service.
  3. Click Start.



 

Tuesday, October 4, 2011

Backup Deletion X no. of days

vi rmbackup.sh

#!/bin/bash
set -x
###Script for cron to delete backups
DIRECTORY=/home/BackupLocation/
DELETEOLDERTHAN="3"
find $DIRECTORY -type f -ctime +$DELETEOLDERTHAN
ls -la | mail -s "backup delete $HOSTNAME -'date'" abc@yourdoamin.com
exit 0

save and exit and chmod +x rmbackup.sh

Put the above script in cron
#crontab -e

*  3  * * * /home/rmbackup.sh

==================================================
Rsync Remote host backup script : Put this script on the machine where you want to take/pull the backup. generate the rsync key
#!/bin/sh
RSYNC=/usr/bin/rsync
SSH=/usr/bin/ssh
KEY=/root/rsync/mirror-rsync-key
RUSER=ursync                                              : create a user for rsync
RHOST=hostname of the remote machine
RPATH=/var/www/html/                                : remote data backup path
LPATH=/var/www/html/                                : Local Path
$RSYNC -azq --delete -e "$SSH -i $KEY" $RUSER@$RHOST:$RPATH $LPATH



Another way

Delete directory based on the time stamp. The below command will delete all the directories with time stamp 2012.

** you need to run this command in the same directory

rm -vrf `ls -lh | sed -n '/2012/p' | awk '{print $8}'`



Wednesday, September 7, 2011

How to Setup FTP and an anonymous FTP server with vsftpd with upload enable

Setup vsftpd in CentOS
yum install vsftpd
chkconfig vsftpd on
service vsftpd start
cp /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.original
anonymous_enable=NO
listen=YES
local_enable=NO
anonymous_enable=YES
write_enable=NO
anon_root=/var/ftp
anon_max_rate=2048000
xferlog_enable=YES 


   
 
 
 
Setup Anonymous FTP with upload enable
#
vim /etc/vsftpd/vsftpd.conf
anon_root=/myftpDir/pub
listen_port=21
listen=YES
local_enable=YES
anonymous_enable=YES
write_enable=YES
anon_max_rate=2048000
xferlog_enable=YES
ftp_username=ftp
anon_upload_enable=YES
anon_mkdir_write_enable=YES
#anon_other_write_enable=YES
anon_world_readable_only=NO
ftpd_banner=(All Activities are monitored on this system!!)
log_ftp_protocol=YES
no_anon_password=YES
local_umask=022

save & exit by :wq

Now
Make sure that root directory  is not  being writable
The ftp root directory MUST NOT be owned by ftp for security reasons (it should be root:root).

Change the permission as below:
chmod u-w /myftpDir/pub
mkdir /myftpDir/pub/upload
chown u-w /myftpDir/pub/upload






Monday, September 5, 2011

SAMBA


yum -y install samba samba-client
service smb start
chkconfig smb on
mkdir /data
mkdir /data/share
chmod 766 /data/share
mv /etc/samba/smb.conf /etc/samba/smb.conf.backup
vim /etc/samba/smb.conf
 
Samba Config - smb.conf
[global]
workgroup = workgroup
netbios name = abc
security = SHARE
load printers = No
default service = global
path = /data
available = No
encrypt passwords = yes

guest account = nobody
[ShareLocation]
guest ok = yes
guest only = yes
path = /ShareLocation
read only = yes
browseable = yes
save and exit by :wq
============================

Friday, July 1, 2011

Increase Ulimit in CentOS 5


1) edit /etc/sysctl.conf to add this line:
fs.file-max = 2048
2) sysctl -p
3)Vim /etc/security/limits.conf and add ther following lines

* soft nofile 65535
* hard nofile 65535
4)ulimit -n 65535

Friday, May 27, 2011

Simle logs backup script

[root@mywebServer cron.daily]# vim httpdbackup
#!/bin/sh
cd /var/log/httpd/
tar -zcf httpd.tgz .
mv httpd.tgz /home/public/backup/
cd /home/public/backup
ls -la | mail -s "backup $HOSTNAME -'date'" myEmailID@companyDomainName.com

Tuesday, April 19, 2011

Samba without Password

vim /etc/samba/smb.conf

Change it to :>

# security = user
security = share

also remove the semicolon from the below line.

guest account = nobody
[ABCProject]
guest ok = yes
guest only = yes
path = /Path to ABC Project
read only = yes
browseable = yes

[Share name]
writable = yes
path = /path/to/directory
public = yes
guest ok = yes
guest only = yes
guest account = nobody
browsable = yes

save and exit
:wq

/etc/init.d/samba restart

that's all.


Tuesday, April 5, 2011

Active Directory and DNS Health Check

Dcdiag.exe /v >> c:\Reports\pre_dcdiag.txt

This is a must and will always tell you if there is trouble with your DCs and/or services associated with it

Netdiag.exe /v >> c:\Reports\pre_Netdiag.txt

This will let me know if there are issues with the networking components on the DC.

Netsh dhcp show server >> c:\Reports\pre_dhcp.txt

Some may not do this but I've felt the pain of a DHCP server somehow not being authorized after a patch. This allows me verify the server count and names.

Repadmin /showreps >> c:\Reports\pre_rep_partners.txt

This shows all my replication and if it was successful or not. Just be aware that Global Catalogs will have more info here than a normal domain controller.

repadmin /replsum /errorsonly >> c:\Reports\pre_repadmin_err.txt

This is the one that always takes forever but will let you know who you are having issues replicating with.

DNSLINT is a good tool for checking your DNS


http://www.microsoft.com/downloads/en/details.aspx?FamilyID=dd7a00df-1a5b-4fb6-a8a6-657a7968bd11

http://technet.microsoft.com/en-us/library/cc976711.aspx

http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=CB42FC06-50C7-47ED-A65C-862661742764

Risk and Health Assessment Program for Active Directory (ADRAP) – Scoping Tool v1.6

http://www.microsoft.com/downloads/en/details.aspx?FamilyID=22205827-C164-4B62-9F8D-C3CD6077BD82

Microsoft Assessment and Planning Toolkit
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=67240B76-3148-4E49-943D-4D9EA7F77730

Microsoft Baseline Security Analyzer 2.2 (for IT Professionals)
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=02BE8AEE-A3B6-4D94-B1C9-4B1989E0900C

Microsoft Exchange Best Practices Analyzer v2.8
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=DBAB201F-4BEE-4943-AC22-E2DDBD258DF3

Microsoft Active Directory Topology Diagrammer
http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=CB42FC06-50C7-47ED-A65C-862661742764

Microsoft Office Visio 2007 Professional Add-In for Rack Server Virtualization (Virtual Rack)
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=3250331A-0116-4064-92D1-50B9B0727B75

Remote Server Administration Tools for Windows 7
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=7D2F6AD7-656B-4313-A005-4E344E43997D

Microsoft Exchange Server User Monitor
http://www.microsoft.com/downloads/en/details.aspx?FamilyID=9A49C22E-E0C7-4B7C-ACEF-729D48AF7BC9

Thursday, February 17, 2011

error parsing the server clients.xml file windows xp

Please try the following:

1) UnInstall KB982168 patch from "Add remove program".

2) Try to connect with vSphere Client to a server, which error messages do you get?

This was caused by a .Net 3 SP2 patch

Tuesday, January 18, 2011

MPLS Vs IPLC

MPLS is called multiprotocol because it works with the Internet IP, ATM, and frame relay network protocols. With reference to the OSI model, MPLS allows most packets to be forwarded at the layer 2 (switching) level rather than at the layer 3 (routing) level. In addition to moving traffic faster overall, MPLS makes it easy to manage a network for quality of service (QoS).
A Label Switch Path (LSP) can be established in MPLS that crosses multiple Layer 2 transports like ATM, Frame Relay or Ethernet. Thus, one of the true promises of MPLS is the ability to create end-to-end circuits, with specific performance characteristics, across any type of transport medium, eliminating the need for overlay networks or Layer 2 only control mechanisms.
IPLC basically uses Layer 3 (Routing) to build a path for the data to flow in the network. Data routing in an IPLC is done using complex route lookups based on the destination IP address. The routing hardware finds the shortest path between the source and destination IP addresses to send data. This can be a hardware intensive task in times of heavy traffic leading to slower data traffic speeds. With hardware becoming more powerful every day, this is not such a major issue.
However, IPLC has major drawbacks in situations where traffic engineering and setting performance characteristics for different classes of traffic are required. Factors like delay and jitter also come into the picture in an IPLC connection that can cause major drops in QoS levels. This can cause problems in networks where data like video-conferencing are used.
MPLS has an edge over IPLC on this front since it provides network administrators the ability to set the path traffic will take through the network, and set performance characteristics for a class of traffic.

If your network requirements are such that you only need point-to-point connectivity, an IPLC typically will cost less than an MPLS circuit. Since an IPLC is your own private circuit, you can use your managed switches to prioritize traffic. But if you have any near future to add a third node to this network, MPLS will be the best way to go

MPLS could provide at least 2 types of link for this.
a) You can have a layer 2 MPLS (which sort of pretends to be an Ethernet WAN link of various flavours).
this type of service normally needs Ethernet access at each site -so you can connect directly to your LAN switches (but you shouldstill route over the WAN to control what is going on).

Or go for a L3 service - tends to cost more, but more flexible, and likely to allow other services if you want them.
Then you have to decide whether you run the CE routers on the service, or get that bundled, or hook direct to your WAN switches.
Then decide what QoS you want if any, what speed access tails and what type of connections, then possibly how much bandwidth to be rate limited.

The flip side with MPLS is someone else is looking after it for you, and you can add more sites since you have connected to a "cloud" service.

CentOS upgrade from 5.2 to 5.5 (final)

How to upgrade CentOS

#ps auxwww | grep -i yum
#kill -9
Remove any excluded packages by commenting out any exclude=XXXXX lines in /etc/yum.conf
#yum -y upgrade

This will upgrade the kernal as well.

you need to reboot the machine to reflect the new kernel.

If you just want to upgrade the kernel not the OS packages.


#yum upgrade kernel
or
#yum upgrade kernel-smp (4+ gb ram)

when the kernel upgrade completes edit the grub.conf

nano /boot/grub/grub.conf

default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (2.6.18-194.32.1.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-194.32.1.el5 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-194.32.1.el5.img
title CentOS (2.6.18-92.1.13.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-92.1.13.el5 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-92.1.13.el5.img
title CentOS (2.6.18-92.el5)
root (hd0,0)
kernel /boot/vmlinuz-2.6.18-92.el5 ro root=LABEL=/ rhgb quiet
initrd /boot/initrd-2.6.18-92.el5.img


here point to note
Grub starts at 0, so "default=0".

reboot the machine by
shutdown -r now
or
init 6

When it comes back up run uname -a to make sure it has the new kernel.


If you want to use your old kernel then set "default=1"

Monday, January 17, 2011

How to install xdebug & MysqlND on CentOS

1. yum install php-pear

2. Yum install php-devel

The pecl command can then be found at /usr/bin/pecl

You can just use the pecl command to install new extensions like

3.sudo pecl install xdebug

Build process completed successfully

Installing '/var/tmp/pear-build-root/install-xdebug-2.1.0//usr/lib/php/modules/xdebug.so'

install ok: channel://pecl.php.net/xdebug-2.1.0

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

At this point, you should open your php.ini file an add the line as suggested, but use the zend_extension directive as follows:

zend_extension = usr/lib/php/modules/xdebug.so

How to Test it

vim xdebug.php

function test(){

echo "Called @ ".xdebug_call_file().

":".xdebug_call_line()." from".

xdebug_call_function();

}

test();

?>

:wq (Save and exit)

now

# php -e xdebug.php

should return like

Called @ /root/phpscript.php:8 from{main}

wow, you are done....

mysqlnd is a 5.3 feature

MySQLnd will most likely be the database driver for both the PDO MYSQL extension

and mysqli extension in PHP 5.3. It is still under development, but there are

currently releases for the mysqli extension.

The MySQL native driver for PHP is part of the official PHP source code repository at

http://php.net. It is contained in the PHP source code as of PHP 5.3.

If you are compiling PHP yourself, please use the configure options

--with-mysql=mysqlnd, --with-mysqli=mysqlnd and --with-pdo-mysql=mysqlnd

to compile PHP with mysqlnd support.

Let’s see how PHP and MySQL works together. Here is the list of three extensions which PHP uses to connect to MySQL.

mysql
mysqli
pdo mysql

All of the above mentioned extensions are rely on MySQL’s client library libmysql. Mysqlnd is an another and alternative way of connecting PHP 5 and PHP 6 to the MySQL Server. Now the question arises why use Mysqlnd instead of other extensions ?

Here is the list of advantages of Mysqlnd library over other mentioned extensions.

  • It is very easy to compile, it does not have any dependencies issues with mysql client programming support.
  • It performs much better then libmysql in certain cases.
  • It provides persistent connections for mysqli.
  • It key feature is that it uses PHP memory management and it supports PHP memory limit.
  • It is famous for reducing memory footprint because it stores every row only once in memory while in the case of libmysql it is saved twice in memory.

By default the MySQL database extensions are configured to use MySQL Client Library. In order to use the MySQL Native Driver, PHP needs to be built specifying that the MySQL database extensions are compiled with MySQL Native Driver support. This is done through configuration options prior to building the PHP source code.

For example, to build the MySQL extension, mysqli and PDO MYSQL using the MySQL Native Driver, the following command would be given:

./configure --with-mysql=mysqlnd \

--with-mysqli=mysqlnd \

--with-pdo-mysql=mysqlnd \

[other options]

As most of the pre-packaged PHP binary installations may not have the support for mysqlnd enabled by default, it is recommended to build PHP and the required database extensions with mysqlnd from the source code


Upgrade PHP 5.1 to 5.3 on CentOS 3

# yum install yum-priorities

# rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh http://dl.iuscommunity.org/pub/ius/stable/Redhat/5/i386/ius-release-1.0-6.ius.el5.noarch.rpm

# yum install httpd

# yum remove php php-*

# yum install php53u-pear php53u php53u-cli php53u-common php53u-devel php53u-gd php53u-mbstring php53u-mcrypt php53u-mysql php53u-pdo php53u-soap php53u-xml php53u-xmlrpc php53u-bcmath php53u-pecl-apc php53u-pecl-memcache php53u-snmp

# vi /var/www/html/phpinfo.php




// Show all information, defaults to INFO_ALL
phpinfo();

// Show just the module information.
// phpinfo(8) yields identical results.
phpinfo(INFO_MODULES);

?>

# service httpd restart

Finally browse to your phpinfo.php http://x.x.x.x/phpinfo.php and view your newly configured PHP 5.3.3 Apache server.





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