Tuesday, June 11, 2013

Mysql Enterprise Monitor Server and Agent Installtion.


MEM Server:

10.0.2.1 us1-linuxcloud.in

Agent:
10.4.0.1 ind-linuxcloud.in


MEM Installtion: 10.0.2.1 us1-linuxcloud.in

cd /opt/mysql/enterprise/agent/etc/instances
mysql mysql1 sd2 sq1 sq2         (You can configure Agents here.)
E.g. cp -a sq2 sq3

then Enter in that Dir.

cd sq3/ >> Edit agent-instance.ini

And Add your agents hostname in that file:

/etc/init.d/mysql-monitor-server restart

/etc/init.d/mysql-monitor-agent restart


Agent Installation: 10.4.0.1 ind-linuxcloud.in
Create User in mysql on agent

mysql > GRANT ALL ON *.* TO 'agent'@'localhost' identified by 'agent123';

then :

cd /opt/mysql/enterprise/agent/etc/
vi mysql-monitor-agent.ini

check this config :

# Agent Parameters

agent-mgmt-hostname = https://10.0.2.1:443/heartbeat     (You need to check this if agent not connecting.)
agent-mgmt-username = agent
agent-mgmt-password = agent
mysqld-instance-dir= etc/instances

agent-item-files = share/mysql-monitor-agent/items/items-mysql-monitor.xml,share/mysql-monitor-agent/items/items-mysql-cluster.xml,share/mysql-monitor-agent/items/custom.xml

agent-uuid = 587a1d86-0a7d-46ed-bbf4-8bc2d423a97b

user = root


/etc/init.d/mysql-monitor-agent restart





Thursday, May 23, 2013

How To Upgrade The Mysql To Percona on WHM/cPanel Server.!

Imp: Please take backup of database and mysql config file my.cnf

cp -Rf /var/lib/mysql /var/lib/mysql-old
mv /etc/my.cnf /etc/my.cnf-old

Check the Mysql version:

mysql -V
mysql Ver 14.12 Distrib 5.0.77, for redhat-linux-gnu (x86_64)

We need to Disable the Mysql in cPanel:

/scripts/update_local_rpm_versions --edit target_settings.MySQL51 uninstalled

The following script will remove the mysql from your server.

/scripts/check_cpanel_rpms --fix --targets=MySQL51


Then, Download the Percoana repository and install it on server:

rpm -Uhv http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm

Retrieving http://www.percona.com/downloads/percona-release/percona-release-0.0-1.x86_64.rpm
Preparing...                ########################################### [100%]
   1:percona-release        ########################################### [100%]

After that you can install the Percona server and req. pacakges.

 yum install Percona-Server-client-55 Percona-Server-server-55 Percona-Server-devel-55 Percona-Server-shared-55 Percona-Server-55-debuginfo.x86_64   Percona-Server-test-55.x86_64

Start the Percona Mysql:
/etc/init.d/mysql start

Upgrade your data with Percona: It will shows you "OK" if its done successfully.
mysql_upgrade

Then again restart the Mysql:
/etc/init.d/mysql restart

Now, For PHP and Apache you have to rebuild the Apache and PHP using following script:
/scripts/easyapache --build

After completion it will shows you.

!!
!! Build Complete! !!

Good You Done IT..Now you can have well optimized PerconaDB.. and you can Enjoy the performance :)

Tuesday, April 9, 2013

Nginx-php-fpm Installation With Yum on Centos.


Install Nginx with php-FPM
 rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

yum install nginx  php-fpm php-cli php-mysql php-gd php-imap php-ldap php-odbc php-pear php-xml php-xmlrpc php-xcache php-magickwand php-magpierss php-mbstring php-mcrypt php-mssql php-shout php-snmp php-soap php-tidy

vi /etc/nginx/conf.d/domain.conf
server {
   listen 80;
   server_name www.domain domain;
   root /usr/share/nginx/html;
   location / {
       index  index.html index.htm index.php;
   }
   location ~ \.php$ {
       include /etc/nginx/fastcgi_params;
       fastcgi_pass  127.0.0.1:9000;
       fastcgi_index index.php;
       fastcgi_param  SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
   }
}

/etc/init.d/nginx restart

 /etc/init.d/php-fpm restart

You can check php-fpm if it is running
[root@yo html]# netstat -anltup | grep php-fpm
tcp        0      0 127.0.0.1:9000              0.0.0.0:*                   LISTEN      23249/php-fpm

Thursday, April 4, 2013

PV Name unknown device


If you allocate the one volume to one VM and you did created PV after that you did dettach the volume without unmounting the volume.
So here is the procedure how to troubleshoot with it.

[root@localhost ~]#  pvdisplay
  --- Physical volume ---
  PV Name               /dev/sda2
  VG Name               VolGroup00
  PV Size               19.89 GB / not usable 19.49 MB
  Allocatable           yes (but full)
  PE Size (KByte)       32768
  Total PE              636
  Free PE               0
  Allocated PE          636
  PV UUID               KhAEcp-48eH-a3nz-HFzF-sXPt-4duo-Vl0NAa

  --- Physical volume ---
  PV Name               unknown device
  VG Name               VolGroup00
  PV Size               10.00 GB / not usable 32.00 MB
  Allocatable           yes
  PE Size (KByte)       32768
  Total PE              319
  Free PE               319
  Allocated PE          0
  PV UUID               7CeL4J-wKL1-EigZ-YpWc-qufr-Gbwp-UcFOne


[root@localhost ~]# vgreduce --removemissing --force

Now just check following things.. your issue is resolved.
[root@localhost ~]# vgdisplay
 
  --- Volume group ---
  VG Name               VolGroup00
  System ID
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  4
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                2
  Open LV               2
  Max PV                0
  Cur PV                2
  Act PV                1
  VG Size               29.84 GB
  PE Size               32.00 MB
  Total PE              955
  Alloc PE / Size       636 / 19.88 GB
  Free  PE / Size       319 / 9.97 GB
  VG UUID               7o4aWW-Euef-k2Ti-n4rt-QTB0-6RZr-4u7Y9w

Wednesday, February 27, 2013

Clean up old backup files.


For clean up old backup files.

cat  /backup/backup_forcleanup.sh

#find /backup/scripts -type d -mtime +10 -name "2009*" -exec rm -rf {} \;
find /backup/scripts/201* -type d -mtime +10 -exec rm -rf {} \;

mail -s "Daily Report for `hostname`"  shrikant.lokhande@example.in < /home/shrikant/daily_report/D_Report_$(date +\%d\%b\%y-\%H%M).txt


mail -s "Hourly Check Result of `hostname` " shrikant.lokhande@example.in < /home/shrikant/daily_logs/oraprod_$(date +\%d\%b\%y-\%H\%M).txt


mail -s "Syslog check of `hostname`"    shrikant.lokhande@example.in <  /home/shrikant/chksyslog/oraprod1_$(date +\%d\%b\%y-\%H\%M)

Tuesday, January 22, 2013

History command With Date and Time In Linux.



Add the line at end of file.

[root@neonserv ~]# vi  /etc/bashrc

# vim:ts=4:sw=4
##
test -s /etc/bash.bashrc.local && . /etc/bash.bashrc.local


Create one file name  "/etc/bash.bashrc.local"  and edit like as follows.

[root@neonserv ~]# vi /etc/bash.bashrc.local

#local bashrc mods
#
# turn on date time stamps in history
#
export HISTTIMEFORMAT="%h/%d - %H:%M:%S "
export HISTCONTROL=ignoreboth
export HISTSIZE=2000

---------------------------
So when you will fire command output will be like this:
[root@neonserv ~]# history
 1033  Jan/22 - 15:30:44 accton
 1034  Jan/22 - 15:31:16 /etc/init.d/psacct start
 1040  Jan/22 - 15:32:06 lastcomm shrii
 1041  Jan/22 - 15:32:10 lastcomm root
 1042  Jan/22 - 15:32:38 lastcomm
 1043  Jan/22 - 15:32:48 lastcomm rm
 1044  Jan/22 - 15:32:51 lastcomm ls
 1045  Jan/22 - 15:32:53 lastcomm root
 1050  Jan/22 - 21:49:44 history
--------------------------


Monday, January 21, 2013

How To Lock/Unlock and Check The User In Linux.


## You can use this command to lock the User: shrii.

[root@localhost ~]# passwd -l shrii
Locking password for user shrii.
passwd: Success

##  This command shows you particular user status. If it is locked or unlock.

[root@localhost ~]# passwd -S shrii
shrii PS 2013-01-21 0 99999 7 -1 (Password set, MD5 crypt.)

## Using this command it will give you list.
[root@localhost ~]# cat /etc/passwd | cut -d : -f 1 | awk '{ system("passwd -S " $0) }' 

test PS 2012-12-27 0 99999 7 -1 (Password set, MD5 crypt.)
shrii PS 2013-01-21 0 99999 7 -1 (Password set, MD5 crypt.)
shrikant LK 2013-01-21 0 99999 7 -1 (Password locked.)
yo LK 2013-01-21 0 99999 7 -1 (Password locked.)


## Using the -u option you can unlock the user.
[root@localhost ~]# passwd -u shrii
Unlocking password for user shrii.
passwd: Success.

####### Another way to lock/unlock the user is "usermod".

## For Locking user.

usermod -L username

## for Unlocking the user.
usermod -U username

Friday, January 18, 2013

One Click Centralized Application Deployment With Webistrano.

One Click Centralized Application Deployment With Webistrano.

We mostly heard the name Hudson, Jenkin, Bamboo, etc. when we talk about application deployment. 

And above all mostly use for Java (For Continuous Integration). 
So what for Ruby on Rails, PHP, Wordpress, Magento, etc. yes we have best option and that is Webistrano. 
Its Open source and stable tool and if you utilize it properly for Application deployment you can have peace of mind and good sleep :) which is rare in this days. 
The back-end of Webistrano is most famous Capistrano. So yes its bug-less and rocking.


Advantages:
- User friendly and simple to use.

- Remote Multi-host deployment.
- One click and Centralize. 
- We can create Custom Recipes. 
- Much secure. 
- Deploy option with SVN and Git. 
- User Management. 
- Access Management. Limited Access for Developers who deploying application.
- Rollback option available. 
- you can deploy unlimited project in it. Same for Recipes, Host, Users.
- Its keeps history that no one can delete any more. 
- Interactive Deployment. So you can see and check the log what happening. 
- You can manage Min-Max Releases. 
- Failed build will never deploy on any server it just keep in history.
- Developers do not need to login to server any more. You can add task(recipes) for 
   checking logs Application and Apache etc. 
- Ready made default task available for Ruby on Rails.

Security:

- Project Wise Access. 
- Stage wise access available.  If you have Stage Environment Prod, Stage and Dev. You can 
  give access by stage wise. 
  Like:  For System admin – Prod.
            For Developers - Stage and Dev. 
- Read only Access also available for user.


Custom Recipes:
- You can add the Trigger After and Before deploy.

- It create the revision of recipes. So if we need older recipes we can have that any time in our
   hand. 
- If you have same environment for Staging, Production, Development you can use only one 
   recipe for all, No need to create individual recipes for each Stage. 

Manage Maintenance Page:
- By default there is recipes/task web-enable and web-disable 
   which is same Capistrano.
- You need to just made necessary entries is Apache Virtual Config and just run the task. 
- So you can add the web enable and web disable task in After and Before Trigger.
   So that it will run After and Before deployment.

Tips: If you using Capistrano you should try Webistrano and feel the Fun choose more  
          convenient  
way. 

Thursday, January 17, 2013

rc.local script in Opensuse 11.


If you have commands and you wanted that while boot. In RHEL/CENTOS /etc/rc.d/rc.local but the same file is not exists in Opensue by default you have to create that using following steps.

Create the file  /etc/rc.d/rclocal
# file content #! /bin/sh


## This script simulates redhat's rc.local (Add commands at the end)

### BEGIN INIT INFO
# Provides: rclocal
# Required-Start: $local_fs $remote_fs $network
# X-UnitedLinux-Should-Start: $ALL
# Required-Stop:
# X-UnitedLinux-Should-Stop:
# Default-Start: 3 5
# Default-Stop: 0 1 2 6
# Short-Description: Simulates rc.local
# Description: Simulates redhat's rc.local: contains
# commands to execute after system has booted (all services are already
# available)
### END INIT INFO

## Execute ony when service is started
case "$1" in
start)
## commands will be executed
;;
*)
exit 0
;;
esac
-----------------------------------------------------------------------------------------


Do give right permission for executable using command : chmod 777 /etc/rc.d/rclocal
Create symlink if you want ln -s  /etc/rc.d/rclocal  /etc/rc.d/rc.local

You have to Enable that service in Yast2 from command prompt, using this command.

yast2 > System > Runlevel editor > rclocal > Enable
Now you can edit file  /etc/rc.d/rc.local  add your command in script at "case $1".

Reboot and check..! Its done.!

Wednesday, January 16, 2013

Error reading block 2851259 (Invalid argument) while doing inode scan. Ignore error? yes Force rewrite? yes

If you are facing following error while shrink LVM using lvreduce command.


Error reading block 2851259 (Invalid argument) while doing inode scan.  Ignore error? yes
Force rewrite? yes

It  means  if you trying to reduce the lvm partition the partition may be corrupt.
So you can do this step by step. 


[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/data--vg-data    14G  154M   13G   2% /data

## If you reduceing the LVM 4GB you using.
 lvreduce -L -4G /dev/data-vg/data



[root@localhost ~]# e2fsck -f /dev/data-vg/data
fsck 1.39 (29-May-2006)
e2fsck 1.39 (29-May-2006)
The filesystem size (according to the superblock) is 3670016 blocks
The physical size of the device is 2621440 blocks
Either the superblock or the partition table is likely to be corrupt!
Abort? yes

## Extend LVM with the original size.
lvextend -L+4G /dev/mapper/data--vg-data

## Recheck the Partition.
e2fsck -f /dev/data-vg/data
e2fsck 1.39 (29-May-2006)
Pass 1: Checking inodes, blocks, and sizes
Pass 2: Checking directory structure
Pass 3: Checking directory connectivity
Pass 4: Checking reference counts
Pass 5: Checking group summary information
/dev/data-vg/data: 18/1835008 files (5.6% non-contiguous), 96794/3670016 blocks

### Try to resize again.
[root@localhost ~]# resize2fs -p /dev/mapper/data--vg-data
resize2fs 1.39 (29-May-2006)
The filesystem is already 3670016 blocks long.  Nothing to do!

## mount that filesystem.
[root@localhost ~]# mount /dev/data-vg/data /data/

### check again.
[root@localhost /]# df -h
Filesystem            Size  Used Avail Use% Mounted on

/dev/mapper/data--vg-data    14G  154M   13G   2% /data

### Take a backup of data with snapshot (create snapshot with minimum size of data.) and mount to
##  system.


[root@localhost /]# lvcreate -L9G  -s  -n snap-data /dev/data-vg/data
  Logical volume "snap-data" created
[root@localhost /]# mount /dev/data-vg/snap-data /snap/
[root@localhost /]# df /snap/
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/mapper/data--vg-snap--data          14449712    156824  13558888   2% /snap
[root@localhost /]# cd /snap/
[root@localhost snap]# ls -la
total 60
drwxr-xr-x  4 root root  4096 Jan 16 16:38 .
drwxr-xr-x 34 root root  4096 Jan  7 18:22 ..
-rw-r--r--  1 root root    21 Jan 16 16:37 file
-rw-r--r--  1 root root    21 Jan 16 16:38 file1
-rw-r--r--  1 root root    21 Jan 16 16:38 file2
drwx------  2 root root 16384 Jan 16 16:34 lost+found
drwxr-xr-x  2 root root  4096 Jan 16 16:39 yo

### Now you can umount data partition and reduce the original  "data" partition, remount the /data and move the snapshot backup to /data partition.

Guys, any query please let me know.