UnixServerAdmin

Server Administration & Management

JBOSS – Introduction

Q:- Difference between servlets and applets?

Servlets executes on Servers while Applets executes on browser, Unlike applets, servlets have no graphical user interface.

Q:- What is an Applet?

An applet is a small server side application that can be loaded and controlled on the browser by the client application.  An applet has limited access to resources in order to ensure security.

Q: – What is Jboss ?

JBoss is a popular open source application server based on JEE technology. Being JEE based, the JBoss supports cross-platform java applications. It was embedded with Apache Tomcat web server. It runs under any JVM of 1.3 or later versions. JBoss supports JNDI, Servlet/JSP (Tomcat or Jetty), EJB, JTS/JTA, JCA, JMS, Clustering (JavaGroups), Web Services (Axis), and IIOP integration (JacORB).

Q: – What is JBoss cache ?

JBoss cache is a product. Frequently accessed Java objects are cached by utilzing JBoss cache to improve the performance of e-business applications. JBoss decreases the network traffic and increases the scalability of applications by eliminating unnecessary database acces.Fully transactional features and highly configurable set of options which are to deal with concurrent data access, are provided by JBoss cache in an efficient manner possible for the applications.

Advertisements

December 21, 2011 Posted by | Tomcat | , , | Leave a comment

How to rename package names on cPanel server

Many time we like to rename package name for our hosting accounts but as hosting account is assigned to large number of user and we can’t reassign package one by one to all users as its time consuming process at that time we can refer following steps to secure time. First login in to shell as root user.

# cd /var/cpanel/packages/

Now rename package for test purpose, we are renaming test_test package to test_support package.

# mv test_test test_support

Now make sure that you reassign package to your users who are currently using test_test package.

# cd /var/cpanel/users

Now search users who are currently using test_test package.

# grep test_test * -R
admin12:PLAN=test_test
test12:PLAN=test_test

Now simply run following command to replace all instance for test_test package in users file with new package name test_support

# grep test_test * -R -l > rename-packages

The above command will store all users name who currently using test_test package in rename-packages file.

# cat rename-packages
admin12
test12

Now create new file packages.sh with the following code.

# vi packages.sh
===================================
#!/bin/sh
dir=”/var/cpanel/users/”
fstr=”test_test”
rstr=”test_support”
exec 3<&0
exec 0<”/var/cpanel/users/rename-packages”
while read LINE ; do
sed -i “s/$fstr/$rstr/” “$LINE”
done
===================================
Set executable permission to file packages.sh file

#chmod 755 packages.sh

Before running packages.sh file check one of the users file and check package name.

# cat admin12
# cPanel — If you edit this file directly you must run /scripts/updateuserdomains afterwards to rebuild the system caches
BWLIMIT=unlimited
CONTACTEMAIL=
CONTACTEMAIL2=
DEMO=0
DNS=server.com
FEATURELIST=default
HASCGI=1
IP=xx.xx.xx.xx
LANG=english
LOCALE=en
MAXADDON=5
MAXFTP=0
MAXLST=0
MAXPARK=0
MAXPOP=0
MAXSQL=0
MAXSUB=0
MTIME=1283914039
MXCHECK-server.com=0
OWNER=root
PLAN=test_test
RS=x3
STARTDATE=1269778722
USER=admin12

Now run file packages.sh

# ./packages.sh

After running packages.sh file you can check user file name and found out that package name is changed.

# cat admin12
# cPanel — If you edit this file directly you must run /scripts/updateuserdomains afterwards to rebuild the system caches
BWLIMIT=unlimited
CONTACTEMAIL=
CONTACTEMAIL2=
DEMO=0
DNS=server.com
FEATURELIST=default
HASCGI=1
IP=xx.xx.xx.xx
LANG=english
LOCALE=en
MAXADDON=5
MAXFTP=0
MAXLST=0
MAXPARK=0
MAXPOP=0
MAXSQL=0
MAXSUB=0
MTIME=1283914039
MXCHECK-server.com=0
OWNER=root
PLAN=test_support
RS=x3
STARTDATE=1269778722
USER=admin12

Note: The above steps useful to rename packages for users , it will not change any value like addon , parked domain limit etc.

December 20, 2011 Posted by | cPanel | , | Leave a comment

cPanel: rsync error

If you have issued the following command

# rsync -av rsync://rsync.cpanel.net/scripts /scripts;chown 0.0 /scripts

And resulting in the  following error message:

rsync: failed to connect to rsync.cpanel.net: Connection refused (111)
rsync error: error in socket IO (code 10) at clientserver.c(94)

Here is the fix

cPanel has discontinued the use of rsync and all syncs need to be done using using the following command. Run these commands as root:

# /scripts/cpanelsync httpupdate.cpanel.net /cpanelsync/RELEASE/scripts /scripts

December 19, 2011 Posted by | cPanel | , | Leave a comment

pgsql_backup.sh

##################################################
# pgsql_backup.sh
##################################################
#!/bin/bash
# Location of the backup logfile.
logfile=”/path/to/logfile.log”
# Location to place backups.
backup_dir=”/directory/to/place/backups”
touch $logfile
timeslot=`date +%H-%M`
databases=`psql -h localhost -U postgres -q -c “l” | sed -n 4,/eof/p | grep -v rows) | awk {‘print $1’}`

for i in $databases; do
timeinfo=`date ‘+%T %x’`
echo “Backup and Vacuum complete at $timeinfo for time slot $timeslot on database: $i ” >> $logfile
/server/pgsql/bin/vacuumdb -z -h localhost -U postgres $i >/dev/null 2>&1
/server/pgsql/bin/pg_dump $i -h 127.0.0.1 | gzip > “$backup_dir/postgresql-$i-$timeslot-database.gz”
done
##################################################

December 18, 2011 Posted by | PgSQL, Shell Script | , | Leave a comment

cPanel JailShell, Unmount and Clean Virtfs [Jailshell virtfs]

NOTE:- Be careful! Don’t remove any folder which is inside /home/virtfs, NEVER. this folder links back to your systems root file system.

You might end up screwing up your server if you attempt it.

NEVER DELETE ANY FILES FROM /home/virtfs/

/home/virtfs is used to chroot the user into jailed shell. cPanel will hard link files into this directory so deleting files in /home/virtfs will also delete the files on the server in the actual location.

Example: rm /home/virtfs/user/etc/exim.pl will delete /etc/exim.pl

If you’re a sysadmin of cPanel server, you might be aware of the JailShell. Its nothing but a User Shell with limited privileges. Users requesting for shell access to the webhosting server are provided with such shell instead of bash (Which provides root level privileges to users) .

Jailshell limits the users access to their home directory and keeps rest of the file system safe. Still there are chances of such users breaking into your system, so be sure of providing shell access to your servers. Jailshell mounts the filesystems of the users, who login via SSH under a directory called /home/virtfs.  This contains users home directory and a false file system which links back to system directories like /bin, /usr etc.

So, we got to know that the Jailshell provides a restricted shell access to users and mounts the home directory temporarily at /home/virtfs.

Now, what if you still see the directories of different users mounted under /home/virtfs?

Right, this normally happens when users forget to logout properly from their SSH sessions. As a system admin,
you’re responsible to unmount these directories safely.

How do I do that?

You can find all the virtfs mounts in /proc/mounts. Run cat /proc/mounts.

# cat /proc/mounts

Now, its time to unmount them one by one. For that you have to take the second column of the output Or write a simple for loop as follows.

for i in `cat /proc/mounts | grep /home/virtfs | cut -d ‘ ‘ -f 2 ` ; do umount $i ; done

If a user is reporting double the quota and it is from /home/virtfs then we need to umount or kill and hanging jailshell process.  To do this run

# ps aufx |grep user |grep jailshell

If there are no jailshell processes then run

# cat /proc/mounts

It will show,
/dev/root /home/virtfs/user/lib ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/lib ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/sbin ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/share ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/bin ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/man ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/X11R6 ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/kerberos ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/libexec ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/local/bin ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/local/share ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/local/Zend ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/include ext3 rw,data=ordered,usrquota 0 0
/dev/sda2 /home/virtfs/user/usr/local/lib ext3 rw,data=ordered,usrquota 0 0
/dev/sda3 /home/virtfs/user/var/spool ext3 rw,noatime,nodiratime,data=ordered,usrquota 0 0
/dev/sda3 /home/virtfs/user/var/lib ext3 rw,noatime,nodiratime,data=ordered,usrquota 0 0
/dev/sda3 /home/virtfs/user/var/run ext3 rw,noatime,nodiratime,data=ordered,usrquota 0 0
/dev/sda3 /home/virtfs/user/var/log ext3 rw,noatime,nodiratime,data=ordered,usrquota 0 0
/dev/sda6 /home/virtfs/user/tmp ext3 rw,nosuid,nodev,noexec,data=ordered 0 0
/dev/root /home/virtfs/userbin ext3 rw,data=ordered,usrquota 0 0

You will need to unmount each of these by running

# umount /home/virtfs/user/tmp

and so on

You can also run

for i in `cat /proc/mounts |grep virtfs |grep user |awk ‘{print$2}’`; do umount $i; done

Make sure to replace user with the cPanel username in the above command. This will then clear up the files in /home/virtfs and the quota should return to normal. If you want to unmount the virtfs of a perticular user, you can simply add an another pipe to for condition with grep username.

Now, you’re done with cleaning of your virtfs.

December 17, 2011 Posted by | cPanel | , | 1 Comment

How to fix error in Mailing list

Error:-

Bug in Mailman version 2.1.9.cp2
We’re sorry, we hit a bug!
Please inform the webmaster for this site of this problem. Printing of traceback and other system information has been explicitly inhibited, but the webmaster can find this information in the Mailman error logs.

Fix:-

1. Go to /usr/local/cpanel/3rdparty/mailman

# cd /usr/local/cpanel/3rdparty/mailman

# ls -al

#chmod -R 2775 ./*

Check if this has fixed the issue, If not run the fixmailman script.

# /scripts/fixmailman

If this wont fix the issue.

# /scripts/reinstall mailman

December 16, 2011 Posted by | cPanel, Mail | , , , | Leave a comment

How to change language for Roundcube webmail

1. Edit Roundcube main config (/usr/local/cpanel/base/roundcube/config/main.inc.php)

# vi /usr/local/cpanel/base/roundcube/config/main.inc.php

To change language from English to Portuguese Brasil

Find

$rcmail_config[‘locale_string’] = ‘en’;

Replace it to

$rcmail_config[‘locale_string’] = ‘pt_BR’;

You can see the installed languages such as fr(french), en_US(english US) from the folder /usr/local/cpanel/base/roundcube/program/localization.

December 15, 2011 Posted by | cPanel, Mail | , , , | Leave a comment

How to add nameservers from shell

Most of the time on cPanel dedicated server we add nameservers from WHM but some time we are not able to access WHM. In that case we can add nameservers from shell by using root login details.

Login in to server as root user and run following commands.

# /scripts/adddns –domain ns1.your_domain.com –ip=X.X.X.X

# /scripts/adddns –domain ns2.your_domain.com –ip=X.X.X.X

You can use your domain name instead of your_domain.com in above command with the respective ips which you want to use for your nameservers.

# /etc/init.d/named restart

December 14, 2011 Posted by | DNS | , | Leave a comment

How to run processes with cpuwatch on cPanel

We can run certain processes like account packaging or account restores with certain cpuwatch value to make sure the server load remains in control and thus normal server operations continue to work during the cpu intensive restore or package processes. This can be achieved by using below command :

# /usr/local/cpanel/bin/cpuwatch 10 /scripts/restorepkg USERNAME

We can keep cpuwatch to 10 , or lower or higher value depending on the specifications of the server and our requirements. As acceptable load values depends on server specifications specially the number of cores.

December 13, 2011 Posted by | cPanel | , , | Leave a comment

Fantastico Showing Blank Page

Fantastico is showing blank page after installation. New installation was  also giving the blank page.

FIX:- Change the following on config.php file.

#define(“PLUGIN_ROOTDIR”,”/tmp”);
define(“PLUGIN_ROOTDIR”,”plugins”);

CAUSE:-

The server is PHP-SUEXEC enabled so the plugin_rootdir should be given as “plugins” in config.php file.

December 12, 2011 Posted by | cPanel | , | Leave a comment

How to close openDNS server

Here is the steps to close the openDNS in the server:-

1. login to your server as root

2. Open the named configuration file.

# vi /etc/named.conf

3. Look for // query-source address * port 53;  below this add the following line:

recursion no;

4. save the file and restart named service.

# service named restart

December 11, 2011 Posted by | DNS | , | Leave a comment

How to fix the time drift issue on a cPanel linux server

Many times you may notice a time drift problem on the server. It is common with some of the AMD Processor server series as well.  In most cases its impact is not very high and it can be controlled by setting up a cron to run each minute to make sure the time remains close to accurate.

e.g. you can setup below cron in either root cron file at /var/spool/cron or in /etc/crontb

*/1 * * * * rdate -s rdate.cpanel.net

This basically syncs the time using rdate, you can use cPanel’s rdate server or any of other public rdate servers.

Another way to fix it is by setting up ntpd (Network Time Protocol Daemon) on the server and is a method to achieve more accurate results. You can install ntp using following simple commands :

# yum install ntp

Edit /etc/ntp.conf for choice of your server

# vi /etc/ntp.conf

The default timer servers should work too , or you can update them as per your liking. The service can be controlled using below simple/standard commands :

# service ntpd start

# service ntpd stop

# service ntpd restart

There are more detail configuration settings as well like drift etc, but for normal use the default settings should be fine.  Another reason for time drift ( usually a crazy one ) can be kernel specific problem. That is in this case the time drifts forward and background with a jump of 20 / 30 seconds, and this becomes a serious problem resulting in failure of different services, one server I handled had both imap and ftp services failing on it.
This was a cPanel server with courier throwing below error :

BYE Clock skew detected. Check the clock on the file server

And ftp was also failing with such a time drift as was not able to do the initial connection session. This was resolved by installing the latest CentOS5 kernel on the related sever.

So for resolving a time drift issue, your sequence would be from rdate cron, ntpd to kernel upgrade , depending on what exactly is the problem and how severe it is.

If you have to choose between cron and ntpd then ntpd solution is preferred.

December 10, 2011 Posted by | cPanel, NTP | , , | 1 Comment

How to calculate memory on Virtouzzo or OpenVZ VPS

On Virtouzzo VPS, you can calcualte the Guaranted, Buestable and other memory usage using below formula.

Guaranteed memory = barrier of vmguarpages / 1024 * 4

Burstable memory = privvmpages / 1024 x 4

Current Memory Usage = physpages held value /1024 * 4

Current Usage (RAM + SWAP) = oomguarpages held value /1024 * 4

December 9, 2011 Posted by | Virtualization, Virtuozzo | , , | Leave a comment

rmmod

The “rmmod” is used to remove the module from kernel.The module name which you wan to remove from
the Kernel (excluding the .ko) is specified to identify the module. The kernel will not remove a module that is currently being used in the kernel (a non-zero use count), but a -w option can be  specified to “rmmod” to instruct the kernel to remove it once the use-count has decreased to zero.

# rmmod your_module

# lsmod

December 8, 2011 Posted by | Tips & Tricks, Unix/Linux | , | Leave a comment

whatismyip.sh

###########################################################
## whatismyip.sh ##
###########################################################
#! /bin/bash

/bin/echo “—————————————” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “External IP: –> `wget http://www.whatismyip.org -O – -o /dev/null` ” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “External IP: Verify –> `wget -q -O – checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’ `” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “Internal IP: –> `ifconfig | grep ‘inet addr:’| grep -v ‘127.0.0.1’ | cut -d: -f2 | awk ‘{ print $1}’`” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “—————————————-” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo >> /REPORTS/liveip.log_$(date +%d%m%y)

mutt -s “External Live IP $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/liveip.log_$(date +%d%m%y) unixserv@unixserveradmin.com

December 7, 2011 Posted by | Shell Script, Tips & Tricks | , | Leave a comment

Protected: Backup_rsync.sh

This content is password protected. To view it please enter your password below:

December 6, 2011 Posted by | Shell Script, Tips & Tricks | , , | Enter your password to view comments.

How to hide your bash shell commands

Have you thought of hiding what you are doing on your linux bash shell prompt and not allowing your colleague to see what command you are entering or do you want to confuse your colleague by showing something invisible but work as visible? then read out this…

Today I came across a neat, but pointless shell command. By running the following in shell, it will hide any commands you run.

# stty -echo

In order to disable this mode, simply remove the “-” before echo.

# stty echo

I guess there really is no point to the command, though you could always mess with your coworkers if they leave their shell prompt open

December 5, 2011 Posted by | Tips & Tricks, Unix/Linux | , , | Leave a comment

How to update awstats from shell for all users in cPanel

Refer following command to update awstats for all users on your cPanel linux server but make sure that you are logged in as root user.

# cat /etc/trueuserowners | sort | cut -f 1 -d : | awk ‘{print “/scripts/runweblogs “$1}

December 4, 2011 Posted by | cPanel | , , | Leave a comment

Protected: How to configure Tomcat to run as a Service

This content is password protected. To view it please enter your password below:

December 3, 2011 Posted by | Java, Shell Script, Tips & Tricks, Tomcat | , , , , | Enter your password to view comments.

How to find the hardware id (hwid) on a server for Virtouzzo license

Parallels the vendor of Virtualization platform Virtouzzo use a hardware id to maintain and associate the Virtouzzo licenses. You will need this hardware id ( hwid ), when you install a license on new server/node or when you upgrade the license on an existing node for any reason, e.g. increasing the license from 20 vps support to 30 vps support or if you change the network card on the server.

This hardware id is located at /proc/vz/hwid and you can get the info using below command :

# cat /proc/vz/hwid

1BF8.F514.74DB.1867.C81B.07B5.74A8.A38E

In some cases it may report multiple ids, you should use the first one in that case.

December 2, 2011 Posted by | Virtualization, Virtuozzo | , , | Leave a comment