Saturday, May 1, 2010

Resource control hardware node

Resource control hardware node :

The root cause of this problem was high "MLAT" value in his container
(as shown by vzstat). This was happening due to this resource setting
of his VPS: cpulimit = 50% & cpus = 4. I have now changed his cpulimit
to 400%. After some research, I found that cpulimit works on PER-CPU
basis. So, for 1 CPU, cpulimit = 100% means "fully use 1 CPU". But
when you have 4 CPUs, you must specify cpulimit = 400% to "fully use
ALL 4 CPUs".

So, if there are 16 CPUs , cpulimit = 1600% ie CPULIMIT = 1600 "fully use
ALL 16 CPUs".

=====
processor at HW Node : 4 (2000.304Mhz each, 1024 KB cache, Dual-Core AMD), 7 GB RAM , 1 GB SWAP
No of processor at Each CT : 1 (each CT RAM = 1 GB)
So, each CT should have CPULIMITS =100, for 4 processor it'll be 400
BURST_CPULIMIT="0" //for each CT

=========

[root@node3 scripts]#for i in `vzlist | awk '{print $1 }'`; do grep CPULIMIT /etc/vz/conf/$i.conf; done //command to check CPUlimit of the container.

Tune CTs :

[root@node3 conf]# for i in `vzlist -a| awk '{print $1 }'`; do sed -i -e 's/CPULIMIT="0"/CPULIMIT="1600"/g' /etc/vz/conf/$i.conf; done
[root@node3 conf]# for i in `vzlist -a| awk '{print $1 }'`; do sed -i 's/BURST_CPULIMIT="1600"/BURST_CPULIMIT="0"/g' /etc/vz/conf/$i.conf; done

[root@node3 conf]#for i in `vzlist -a|grep stopped | awk '{print $1 }'`; do sed -i -e 's/CPUS="0"/CPUS="16"/g' /etc/vz/conf/$i.conf; done

[root@node4 log]# for i in `vzlist -a|awk '{print $1 }'`; do sed -i -e 's/CPUS="2"/CPUS="16"/g' /etc/vz/conf/$i.conf; done


check cpuunits in node and containers :

vzcpucheck and

for i in `vzlist | awk '{print $1 }'`; do grep CPUUNITS /etc/vz/conf/$i.conf; done

=========
In the following example, Container 102 is guaranteed to receive about 2% of the CPU time even if the Hardware Node is fully used, or in other words, if the current CPU utilization equals the power of the Node. Besides, CT 102 will not receive more than 4% of the CPU time even if the CPU is not fully loaded:

# vzctl set 102 --cpuunits 1500 --cpulimit 4 --save
Configuring Number of CPUs Inside Container : # vzctl set 101 --cpus 2 --save

List iptable rules

List iptable rules:
iptables -n -L (-n prevents slow reverse DNS lookup)

Reject all from an IP Address:
iptables -A INPUT -s 136.xxx.xxx.xxx -d 136.xxx.xxx.xxx -j REJECT

Allow in SSH:
iptables -A INPUT -d 136.xxx.xxx.xxx -p tcp --dport 22 -j ACCEPT

If Logging - Insert Seperate Line *BEFORE* the ACCEPT / REJECT / DROP
iptables -A INPUT -d 136.xxx.xxx.xxx -p tcp --dport 3306 -j LOG
iptables -A INPUT -d 136.xxx.xxx.xxx -p tcp --dport 3306 -j ACCEPT
Block All:
iptables -A INPUT -j REJECT

===============
Remove / Delete an individual /single Iptable Rule
iptables -D INPUT -s 127.0.0.1 -p tcp --dport 111 -j ACCEPT
// -D = delete appropriate rule. If you dont know the exact syntax of the rule to delete do the following:
iptables -L
//count down the number of lines until you reach the rule you wish to delete
iptables -D INPUT 4
//format = iptables -D CHAIN #Rule_No

======================
Saving ALL IPTABLE Rules
It seems that the method for saving & loading iptable rules from /etc/init.d/iptables load|save active|inactive does not save NAT rules.
The command for saving iptable rules manually is:
root:~# iptables-save > rules-saved
There is also command called iptables-restore. It is:
root:~# iptables-restore rules-saved

Virtuozzo Command Line Utilities

Virtuozzo Command Line Utilities :
The table below contains the full list of Virtuozzo command-line utilities.
General utilities are intended for performing day-to-day maintenance tasks:
vzctl
Utility to control Containers.
vzlist
Utility to view a list of Containers existing on the Node with additional information.
vzquota
Utility to control Virtuozzo Containers disk quotas.

Licensing utilities allow you to install a new license, view the license state, generate a license request for a new license:
vzlicview
Utility to display the Virtuozzo license status and parameters.
vzlicload
Utility to manage Virtuozzo licenses on the Hardware Node.
vzlicupdate
Utility to activate the Virtuozzo Containers installation, update the Virtuozzo licenses installed on the Hardware Node, or transfer the Virtuozzo license from the Source Node to the Destination Node.

Container migration tools allow to migrate Containers between Hardware Nodes or within one Hardware Node:
vzmigrate
Utility for migrating Containers from one Hardware Node to another.
vzmlocal
Utility for the local cloning or moving of the Containers.
vzp2v
Utility to migrate a physical server to a Container on the Node.
vzv2p
Utility to migrate a Container to a physical server.

Container backup utilities allow to back up and restore the Container private areas, configuration files, action scripts, and quota information:
vzbackup
Utility to back up Containers.
vzrestore
Utility to restore backed up Containers.
vzabackup
Utility to back up Hardware Nodes and their Containers. As distinct from vzbackup, this utility requires the Parallels Agent software for its functioning.
vzarestore
Utility to restore backed up Hardware Nodes and Containers. As distinct from vzrestore, this utility requires the Parallels Agent software for its functioning.

Template management tools allow the template creation, maintenance and installation of applications into a Container:
vzpkg
Utility to manage OS and application EZ templates either inside your Containers or on the Hardware Node itself.
vzmktmpl
Utility to create OS and application EZ templates.
vzveconvert
Utility to convert Containers based on Virtuozzo standard templates to EZ template-based Containers.
vzpkgproxy
Utility to create caching proxy servers for handling OS and application EZ templates.
vzrhnproxy
Utility to create RHN proxy servers for handling the packages included in the RHEL 4 and RHEL 5 OS EZ templates.
vzpkgls
Utility to get a list of templates available on the Hardware Node and in Containers.
vzpkginfo
Utility to get the information on any template installed on the Hardware Node.
vzpkgcreat
Create a new package set from binary RPM or DEB files.
vzpkgadd
Utility to add a new template to a Container.
vzpkglink
Utility to replace real files inside a Container with symlinks to these very files on the Node.
vzpkgrm
Utility to remove a template from a Container.
vzpkgcache
Update a set of preinstalled Container archives after new template installation.

Supplementary tools perform a number of miscellaneous tasks in the Hardware Node and Container context:
vzup2date
Utility to update your Virtuozzo software and templates.
vzup2date-mirror
Utility to create local mirrors of the Virtuozzo official repository.
vzfsutil
Utility for the VZFS optimization and consistency checking.
vzcache
Utility to gain extra disk space by caching the files identical in different Containers.
vzsveinstall
Utility to create the Service Container on the Hardware Node.
vzsveupgrade
Utility to update the packages inside the Service Container.
vzps and vztop
Utilities working as the standard ps and top utilities, with Container-related functionality added.
vzsetxinetd
Utility to switch some services between a standalone and xinetd-dependent modes.
vzdqcheck
Print file space current usage from quota's point of view.
vzdqdump and vzdqload
Utilities to dump the Container user/group quota limits and grace times from the kernel or the quota file or for loading them to a quota file.
vznetstat
Utility that prints network traffic usage statistic by Containers.
vzcpucheck
Utility for checking CPU utilization by Containers.
vzmemcheck
Utility for checking the Hardware Node and Container current memory parameters.
vzcalc
Utility to calculate resource usage by a Container.
vzcheckovr
Utility to check the current system overcommitment and safety of the total resource control settings.
vzstat
Utility to monitor the Hardware Node and Container resources consumption in real time.
vzpid
Utility that prints Container id the process belongs to.
vzsplit
Utility to generate Container configuration file sample, "splitting" the Hardware Node into equal parts.
vzcfgscale
Utility to scale the Container configuration.
vzcfgvalidate
Utility to validate Container configuration file correctness.
vzcfgconvert
Utility to convert Virtuozzo 2.0.2 Container configuration files to Virtuozzo 2.5.x format.
vzstatrep
Utility to analyze the logs collected by vzlmond and to generate statistics reports on the basis of these logs (in the text and graphical form).
vzreport
Utility to draw up a problem report and to automatically send it to the Parallels support team.
vzhwcalc
Utility to scan the main resources on any Linux server and create a file where this information will be specified.
vzveconvert
Utility to convert the Containers based on Virtuozzo standard OS templates to the EZ template-based ones.
vznetcfg
Utility to manage network devices on the Hardware Node.
vzmtemplate
Utility to migrate the installed OS and application templates from the one Hardware Node to another.

Virtuozzo Configuration Files

Virtuozzo Configuration Files :
There are a number of files responsible for the Virtuozzo system configuration. Most of the files are located in the /etc directory on the Hardware Node. However, some configuration files are stored in the /etc directory inside the Service Container, on the Backup Node, inside a Container, or on a dedicated server. In case a configuration file is located in a place other than the Hardware Node, we point clearly the exact position (the Service Container, etc.) where it can be found.

A list of configuration files is presented in the table below:
/etc/vz/vz.conf
The Virtuozzo global configuration file. This file keeps system-wide settings, affecting Container and Virtuozzo template default location, global network settings and so on.
/etc/vz/conf/.conf
The private configuration file owned by a Container numbered . The file keeps Container specific settings – its resource management parameters, location of private area, IP address and so on.
/etc/vz/conf/ve-.conf.sample
Sample files, containing a number of default Container configurations, which may be used as a reference for Container creation. The following samples are shipped with Virtuozzo: basic, cpanel, confixx, slm.plesk, slm.256MB, slm.512MB, slm.1024MB, slm.2048MB. You may also create your new samples customized for your own needs.
/etc/vz/conf/dists/.conf
scripts :
/etc/sysconfig/vz-scripts/dists/scripts
/backetc/sysconfig/vz-scripts/dists/scripts
The configuration files used to determine what scripts are to be run on performing some operations in the Container context (e.g. on adding a new IP address to the Container). These scripts are different from Virtuozzo action scripts and depend on the Linux version the given Container is running.
/etc/sysconfig/vzsve
The configuration file used for the Service Container creation by vzsveinstall.
/etc/sysconfig/vzagent/
Parallels Agent configuration files.
/etc/vz/conf/networks_classes
The definition of network classes, used by traffic shaping and bandwidth management in Virtuozzo.
/etc/sysconfig/vzup2date/vzup2date.conf
This file specifies the default connection parameters for the vzup2date utility.
//.conf
This configuration file specifies the default connection parameters for the vzup2date-mirror utility. It should be located on the computer where you are planning to run vzup2date-mirror.
/etc/cron.d/vereboot
The configuration file for the cron daemon. Using this file, Virtuozzo emulates the "reboot" command working inside a Container.
/etc/vzvpn/vzvpn.conf
The configuration file used to define the parameters for establishing a private secure channel to the Parallels support team server.
/etc/vzreport.conf
The configuration file used to define the parameters for sending your problem report to the Parallels support team.
/etc/sysctl.conf
Kernel parameters. Virtuozzo adjusts a number of kernel sysctl parameters, and modifies the default /etc/sysctl.conf file.
/etc/vzredirect.d/*.conf
These files define the offline management modes for controlling Containers by Container administrators.
/etc/vzlmond.conf
This configuration file defines the parameters used by the vzlmond daemon to collect information on the main Hardware Node resources consumption.
/etc/vzstat.conf
The file lists the warning and/or error levels for a number of resource control parameters. If a parameter hits the warning or error value, the vzstat utility will display this parameter in yellow or red.
/etc/vzstatrep.conf
This configuration file is located on the Monitor Node and used by the vzstatrep utility when generating statistic reports and graphics on the Hardware Node resource consumption and sending these reports to the Node administrator.
/etc/vzbackup.conf
The global configuration file residing on the Backup Node and determining the global Container backup settings.
/etc/vz/pkgproxy/rhn.conf
The Red Hat Network (RHN) Proxy Server configuration file used by the vzrhnproxy utility when setting up the RHN Proxy Server. This file can be located on any computer where the vzrhnproxy package is installed.
/etc/vzpkgpoxy/vzpkgproxy.conf
This configuration file is used by the vzpkgproxy utility when creating special caching proxy servers for OS and application EZ templates. The file can be located on any computer where the vzpkgproxy package is installed.
/etc/vztt/vztt.conf
This configuration file is used by the vzpkg utility when managing OS and application EZ templates.

===========

Thursday, April 29, 2010

Install xen virtual server on linux platform

Before installing xen on the linux (centos or Redhat), please check the compatiblity. Then check whether the server has already installed xen. There packages should be checked. I checked using RPM.

.1 xenserver# rpm -qa |grep xen
xen-libs-3.1.0-13.el5
xen-3.1.0-13.el5
xenserver #rpm -qa |grep kernel-xen
kernel-xen-2.6.21-2950.el5
xenserver-dev #rpm –qa |fgrep virt-manager //for GUI
virt-manager-0.5.2-2.el5

Install :
1.
xenserver# yum install xen
xenserver # yum install kernel-xen
xenserver # yum install virt-manager

2. Edit default=1 in /boot/grub/grub.conf and make sure xen kernel will load.
3. Reboot system : [root@xenserver]# init 6
4. check kernel :
[root@xenserver]# uname -r
2.6.21-2950.el5xen
=====
To check if Xen is running use xm from command line:
[root@xensever]# xm list
Now you can create Xen virtual machines using Xen command lines or xen GUI (virt-manager):

[xenserver@ldev ~]# virt-manager

What is Ruby on Rails? Install on linux plat form

What is Ruby on Rails?
Ruby is a programming language just like Perl, Python or PHP. Rails is an open source Ruby framework for developing database-backed web applications. You could develop a web application at least ten times faster with Rails than you could with a typical Java framework. It is a web application framework written in the Ruby programming language.

We tried the installation of Ruby on Rails on a server with this configuration:
1. Red Hat Linux release 7.3
2. Plesk 5.0.5
3. Apache 1.3.27
4. PHP 4.3.4 # Run as an Apache Module
Install Ruby
Before installing Ruby, first check if zlib is installed in PHP. You can do this by running a simple script with this code.

Now you are all set to start the installation.
cd /usr/local/src
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.2.tar.gz
tar xvzf ruby-1.8.2.tar.gz
cd ruby-1.8.2
./configure
make
make install
ruby rubytest.rb
If the installaiton is successful, then you will get a message “test succeeded”.
Install RubyGems
cd /usr/local/src
wget http://rubyforge.org/frs/download.php/5207/rubygems-0.8.11.tgz
tar xvzf rubygems-0.8.11.tgz
cd rubygems-0.8.11
ruby setup.rb all
This step involves execution of `ruby setup.rb` with arguments `config / setup / install` all together
gem query --local
OR
gem q -L
Listing all installed gems
Install Rails
gem install rails OR # (Enter Y for all dependencies)
gem install rails --include-dependencies
Install FastCGI
wget http://fastcgi.com/dist/fcgi-2.4.0.tar.gz
tar -xvzf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure
make
make install
Install mod_fastcgi
wget http://www.fastcgi.com/dist/mod_fastcgi-2.4.2.tar.gz
tar -xvzf mod_fastcgi-2.4.2.tar.gz
cd mod_fastcgi-2.4.2
/path/to/apxs -o mod_fastcgi.so -c *.c
/path/to/apxs -i -a -n fastcgi mod_fastcgi.so
In Apache’s httpd.conf, add this line.
Include /path/to/httpd/conf/fastcgi.conf
Now, add this text to fastcgi.conf
cat > /path/to/httpd/conf/fastcgi.conf
User apache
Group apache

FastCgiConfig -idle-timeout 900
AddHandler fastcgi-script .fcgi .fpl .rb
FastCgiIpcDir /tmp/fastcgi_ipc/
FastCgiSuexec /usr/sbin/suexec
To make FastCGI run as suexec. Use path to suexec


Ctrl + D
mkdir /tmp/fastcgi_ipc/
chown -R apache.apache /tmp/fastcgi_ipc
chmod 700 /tmp/fastcgi_ipc/
service httpd restart
NOTE : In some systems, the ownership of fastcgi_ipc is done by Apache itself, but its safe to include these steps in your routine.
Related files: /usr/local/lib/ruby/gems/1.8/gems/rails-1.0.0/dispatches/dispatch.fcgi # OR ~USER//public/dispatch.fcgi # Log file declaration & all
Install gem bindings
To install gem bindings for Fastcgi and MySQL
gem install fcgi
gem install mysql
Testing
1. Install Test Application
cd ~USER
rails testapp # Create a test application named 'testapp'
cd testapp/
./script/generate controller test
cd ~USER/httpdocs
ln -s ~USER/testapp/public rails
# In order to access the test application
'~USER/testapp/public' from the browser
In order to allow symlinks, enter the following in to ~USER/httpdocs/.htaccess
Options Indexes +FollowSymLinks
Now you need to set the correct ownership and permissions for the test application. I did the following for my project. You can learn from the example:
cd ~USER
chown -R USER.psacln testapp
chmod -R 755 testapp
chown -R USER.psacln httpdocs/rails
chmod -R 755 httpdocs/rails
Create Test Pages
cd ~USER
cd ~USER/testapp/app/controllers
Create a file called test_controller.rb and put in the following code:
cat > test_controller.rb
class TestController < ApplicationController
def hi
render :text => 'Hi world'
end
def hello
end
def index
render :text => 'Hi! This is the Index.'
end
end
Ctrl + D
Now create the test page.
cat > ~USER/testapp/app/views/test/hello.rhtml # The test page


Hello World


Hello from Rails!


The current time is <%= Time.now %>



Various linux commands

grep -irl saqun.com * [i=case sensitive,allow both case. r=recursive, l=list out] // search domain in /hsphere/local/config/httpd/sites/

1.check php version: php -v

2.check which php: php -i // php -i |grep php.ini

3./usr/local/cpanel/logs // logs of cpanel

4./var/cpanel/userdata // gives the user data.

5.ctrl+] // to come out from established connection

Then q enter.

7.Search customer by name or by email id:-

8.vps # vzctl enter (id of domain) // to go to root of particular domain.

9.For neural customer search from database the details. Take user & password and login from www.emcwebhosting.com site.

10.cd /dir && command

11.ls /etc | pr -T9 -W$COLUMNS // print contents in 9 columns.pr=print T9=9 column W=width.

12.find -name '*.[ch]' | xargs grep -E 'expr' //Search 'expr' in this dir and below. See also findrepo

13.find -type f -print0 | xargs -r0 grep -F 'example' //Search all regular files for 'example' in this dir and below

14.find -maxdepth 1 -type f | xargs grep -F 'example' //Search all regular files for 'example' in this dir

15.find -type f ! -perm -444 ///Find files not readable by all (useful for web site)

16.find -type d ! -perm -111 //Find dirs not accessible by all (useful for web site)

17.grep --color kamal /etc/passwd //Highlight occurances of regular expression in dictionary

18. gpg -c file //Encrypt file

gpg file.gpg //Decrypt file

19. scp -p -r $USER@$HOST: file dir/ // Copy with permissions to $USER's home directory on $HOST

20.ssh -g -L 8080:localhost:80 root@$HOST //Forward connections to $HOSTNAME:8080 out to $HOST:80

ssh -R 1434:imap:143 root@$HOST //Forward connections from $HOST:1434 in to imap:143

21.

wget -c http://www.example.com/large.file //Continue downloading a partially downloaded file

wget -r -nd -np -l1 -A '*.jpg' http://www.example.com/dir/ //Download a set of files to the current directory

22.

echo 'wget url' | at 01:00 //Download url at 1AM to current dir

wget --limit-rate=20k url //Do a low priority download (limit to 20KB/s in this case)

wget -o log url // faults r stored in log file . log=/x.txt

wget --dns-timeout=seconds url

--connect-timeout=seconds url

--read-timeout=seconds url

--limit-rate=amount url

--user=user url

--password=password url

23. ethtool eth1 // show status of ethernate 0 1

24.ip link show //List network interfaces

25.

ethtool eth0 //Show status of ethernet interface eth0

ethtool --change eth0 autoneg off speed 100 duplex full //Manually set ethernet interface speed

iwconfig eth1 //Show status of wireless interface eth1

iwconfig eth1 rate 1Mb/s fixed //Manually set wireless interface speed

iwlist scan //List wireless networks in range

ip link set dev eth0 name wan //Rename interface eth0 to wan

ip link set dev eth0 up //Bring interface eth0 up (or down)

ip addr show //List addresses for interfaces

ip addr add 1.2.3.4/24 brd + dev eth0 //Add (or del) ip and mask (255.255.255.0)

ip route show //List routing table

ip route add default via 1.2.3.254 //Set default gateway to 1.2.3.254

26.

netstat -tupl //List internet services on a system with it we can search anything by grep

netstat -tup //List active connections to/from system

27.

cal -3 // Display a calendar

cal 9 1752 // Display a calendar for a particular month year

date -d fri //What date is it this friday. See also day

28. ls -lSr ls -lS // show the file order in size.

29. df -h Show free space on mounted filesystems

• df -i Show free inodes on mounted filesystems

• fdisk -l Show disks partitions sizes and types (run as root)

30.lsof -p $$ //List paths that process id has open

tcpdump not port 22 //Show network traffic except ssh. See also tcpdump_not_me

ps -e -o pid,args --forest //List processes in a hierarchy

ps -p 1,2 //List info for particular process

watch -n.1 'cat /proc/interrupts' // Watch changeable data continuously IDs

=================================================

31.• uname -a //Show kernel version and system architecture

• head -n1 /etc/issue //Show name and version of distribution

• cat /proc/partitions //Show all partitions registered on the system

• grep MemTotal /proc/meminfo //Show RAM total seen by the system

• grep "model name" /proc/cpuinfo //Show CPU(s) info

• lspci -tv //Show PCI info

• lsusb -tv //Show USB info

• mount | column -t //List mounted filesystems on the system (and align output)

• grep -F capacity: /proc/acpi/battery/BAT0/info // Show state of cells in laptop battery

# dmidecode -q | less //Display SMBIOS/DMI information

# smartctl -A /dev/sda | grep Power_On_Hours //How long has this disk (system) been powered on in total

# hdparm -i /dev/sda //Show info about disk sda

# hdparm -tT /dev/sda //Do a read speed test on disk sda

# badblocks -s /dev/sda

=====================================================

32. pg

Used to display data one page (screenful) at a time. The command can take a number of filenames as arguments.

Pg [option] [filename] [filename2]…..

33.sort

Sort is a utility program that can be used to sort text files in numeric or alphabetical order

Sort [filename]

34.& - run a program in background mode.

=================================================

35. Get back windows admin password: "C:\Program Files\SWsoft\Plesk\admin\bin\plesksrvclient.exe" –get