Wednesday 27 May 2015

Openvz live migration

This is a quick and easy guide to moving OpenVZ virtual servers around your SolusVM cluster:


1.Run the following code on the node that hosts the container you want to migrate:

wget http://files.soluslabs.com/solusvm/scripts/keyput.sh chmod a+x keyput.sh ./keyput.sh destination_node_ip destination_node_port
  • <destination_node_ip> should be replaced with the IP address of the node you want to migrate the virtual server to
  • <destination_node_port> should be replaced with the SSH port of the node you want to migrate the virtual server to
2. Find the container ID (CTID) of the VPS you want to move and start the migration using vzmigrate:
vzmigrate -v --ssh="-p destination_node_port" destination_node_ip container_id
3.  Update your SolusVM Master when the restore is complete so it knows where the VPS has been moved to. Run the following on your SolusVM Master:

/scripts/vm-migrate [VSERVERID] [NEWNODEID]
 
For example:

/scripts/vm-migrate 150 4
 
 

Openvz node full, 100%

[root@node~]# df -Th
Filesystem     Type  Size  Used Avail Use% Mounted on
/dev/sda5      ext4  1.1T  1.1T 1001M 100% /
/dev/sda2      ext4  2.9G  4.6M  2.9G   1% /tmp
/dev/sda1      ext4  479M  184M  295M  39% /boot


Find the container and their disk usage
============================

find /vz/private/  -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'

/vz/private/402/root.hdd/root.hdd: 15G
/vz/private/367/root.hdd/root.hdd: 22G
/vz/private/448/root.hdd/root.hdd: 6.2G
/vz/private/392/root.hdd/root.hdd: 50G
/vz/private/391/root.hdd/root.hdd: 18G
/vz/private/436/root.hdd/root.hdd: 11G
/vz/private/432/root.hdd/root.hdd: 1.4G
/vz/private/416/root.hdd/root.hdd: 16G
/vz/private/387/root.hdd/root.hdd: 50G
/vz/private/386/root.hdd/root.hdd: 20G
/vz/private/405/root.hdd/root.hdd: 23G
/vz/private/443/root.hdd/root.hdd: 8.9G
/vz/private/427/root.hdd/root.hdd: 31G

===================
Delete unwanted space using files like backup files
===========
 for i in `cat /proc/vz/veinfo | awk '{print $1}'|egrep -v '^0$'`; do echo "Container $i"; vzctl exec $i find . -name "*backup*.tar.gz" -type f -delete; done
===========

Find the space usage in containers  >> vzctl enter container ID then
==========
 find /home -type f -size +500000k -exec ls -lh {} \; | awk '{ print $9 ": " $5 }'


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

If the issue still not under control try the below command via node on the containers that have space issues
====
Run this command vzctl compact ctid
===================================


Last method >> migrate any two containers to some other location using openvz live migration
======

https://documentation.solusvm.com/plugins/servlet/mobile#content/view/557438 
 

Friday 22 May 2015

Inode usage 100% making the system down

Inode is a data structure that keeps track of all the information about a file. You keep your information in a file and the OS stores the information about a file in an inode. Information about files is sometimes called metadata. We can say that an inode is metadata of the data.


How does the structure of an inode look like?

A directory with it’s corresponding inodes looks like this:

Inodes             Directory/file names

4204851            ./  
4203424            ../ 
4195429            dir1/ 
4205752            dir2/
4205722            file1
4205723            file2
4194941            .hidden_dir/
4205589            .hidden_file1
======================================   
Inode structure of a directory consists of a name to inode mapping of files and directories in that directory.
In the above example, you probably noticed the first two entries of ./ [dot] and ../ [dot dot]. You might have seen them whenever you list the contents of a directory. You might also know that executing the command

cd .   
cd .  will change the directory to the current directory itself and the command

cd ..   
cd ..will take you to the previous directory (the parent directory of the current directory).
Why that happens?
Let’s use an example. Let’s have a look at our test directory:
user@sree ~/tmp/Anchal % ls -i
4204851 ./         4205723 file2
4203424 ../        4195429 folder1/
4205722 file1      4205752 folder2/

Let’s have a look at the inode numbers of . (dot) and .. (dot dot):

. (dot) = 4204851
.. (dot dot) = 4203424

We’ll do the same for ~/tmp/ directory and note the inodes there:
user@sree ~/tmp/Anchal % ls -i
4203424 ./ 
3816836 ../ 
4204851 test/
The inode numbers of ~/tmp/test/ directory and . (dot) from the directory listing of ~/tmp:

. (dot) = 4203424
~/tmp/test/ = 4204851

You can see that inode number of . (dot) inside ~/tmp/test/ directory is equal to inode of test directory – 4204851. And inode of .. (dot dot) inside ~/tmp/test/ is equal to inode of . (dot) inside ~/tmp/ directory – 4203424.


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







How to check Inode Utilization?
===============

user@sree  ~ % df -i
Filesystem                Inodes  IUsed    IFree IUse% Mounted on
rootfs                   5840896 659354  5181542   12% /
udev                      217137    406   216731    1% /dev
tmpfs                     220131    450   219681    1% /run
tmpfs                     220131      6   220125    1% /dev/shm
tmpfs                     220131     11   220120    1% /sys/fs/cgroup
tmpfs                     220131      6   220125    1% /run/lock
tmpfs                     220131     11   220120    1% /run/user
/dev/sda1                 124496    265   124231    1% /boot

=============================
How to access a file using inode?

"ls -i" lists the inode of a file
or
ls -ai
====================================
As you can see, our test directory contains a file with special characters (UNICODE) – µfile¤. You wouldn’t be able to access the file by it’s filename, as your keyboard most definitely doesn’t have the micro character defined. You could access the file in several ways. The harder one, would be to find the UNICODE hex code for the micro sign and this would involve looking for the UNICODE characters table. The easier way would be to use the file inode. However, the most obvious and easiest way to deal with such signs would be to use tab-completion, yet not always a file could be deleted by it’s name. Sometimes the filename contains broken characters, not recognized by the system. Here inode comes in hand. You can access and modify (delete, edit, move, etc.) the file using its inode:

# edit the file with vim
user@sree ~/tmp/test % find ./ -inum 4195034 -exec vim {} \;
# remove the file
user@sree ~/tmp/test % find ./ -inum 4195034 -exec rm {} \;
# change the file name
user@sree ~/tmp/test % find ./ -inum 4195034 -exec mv {} repaired_file \;
# edit the file with vim
user@sree ~/tmp/test % find ./ -inum 4195034 -exec vim {} \;
# remove the file
user@sree  ~/tmp/test % find ./ -inum 4195034 -exec rm {} \;
# change the file name
user@sree  ~/tmp/test % find ./ -inum 4195034 -exec mv {} repaired_file \;

You can also change directory using inode.To get the inode numbers of the directories, you can use the command:
===============================
user@machine ~ % tree -a -L 1 --inodes /
/
├── [3276801]  bin
├── [      2]  boot
├── [   1026]  dev
├── [1179649]  etc
├── [3538945]  home
├── [5505025]  lib
├── [     11]  lost+found
├── [2752513]  media
├── [3670017]  mnt
├── [1703937]  opt
├── [      1]  proc
├── [3145729]  root
The inode number for the specified directory in the brackets. To access a directory use the command:
===========================
user@sree ~ % cd $(find / -inum 1572865)
or
user@sree ~ % find -inum 1572865 -exec cd {} \;   

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




To remove unwanted inode usage by cpanel
======================

Just run the below script
====================



To find the inode usage per location (/ directory here)

for i in /*; do echo $i; find $i |wc -l; done

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


/usr/local/cpanel/bin/purge_dead_comet_files
=====================



                                                                                                          By Sreejth Anchal
 

Monday 4 May 2015

<script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>
<!-- Demo advrtisement -->
<ins class="adsbygoogle"
     style="display:block"
     data-ad-client="ca-pub-9809879499425176"
     data-ad-slot="8740242843"
     data-ad-format="auto"></ins>
<script>
(adsbygoogle = window.adsbygoogle || []).push({});
</script>

Update cPanel Failed : /scripts/upcp

Update cPanel Failed : /scripts/upcp
=====================================
[20150311.000907] Preparing... ##################################################
[20150311.000907] rpm_is_working ##################################################
[20150311.000907] Switching to version '11.42.1.31' of updatenow to perform sync.
=> Log closed Wed Mar 11 00:09:07 2015
[20150311.000907] 17% complete
=======

Fix
====

By looking into the error log, you can get the solution >> The RPM is corrupt in the server
===========
=============
[WARN] * /var/cpanel/sysinfo.config: contains 'rpm_dist_ver=unknown'.

Corrected this by running /scripts/gensysinfo, which populates the file with this info:
=============

Run the below comds

#/scripts/gensysinfo
/var/cpanel/sysinfo.config updated.

# cat /var/cpanel/sysinfo.config
# This values in this file are calculated and updated if necessary nightly. If you wish to override
# these values, populate lock= with a comma delimited list of keys you don't want updated.
# This will allow you to change those values to suit your needs.
#
# Example: if you set lock like this, then rpm_dist and rpm_arch will not be updated nightly:
# lock=rpm_dist,rpm_arch
#
ises=2
lock=
release=6.5
rpm_arch=x86_64
rpm_dist=centos
rpm_dist_ver=6
=======================

Now try /scripts/upcp  >> it will work