Plesk : Upgrading failed with error while trying to execute SQL query

Symptoms
Upgrade version 8.6 failed. The following error is shown in upgrade log:

/tmp/psa_8.6.0_cos4.build86080722.02_upgrade.090611.00.57.log
—>8—
ERROR while trying to execute SQL query, the query was: DELETE FROM mysql.user WHERE user = ”; FLUSH PRIVILEGES;

Aborting…

STOP psa-8.6.0-cos4.build86080722.02 upgrading AT Thu Jun 11 00:57:52 CDT 2009
—8<---

What does the error mean and how to resolve the problem?

Cause
Execution of query “FLUSH PRIVILEGES” is not possible because table ‘mysql.procs_priv’ is missing in database ‘mysql’.
To verify login to mysql and try the command:

mysql> flush privileges;
ERROR 1146 (42S02): Table ‘mysql.procs_priv’ doesn’t exist

mysql>

Resolution
In MySQL 5.0 you may create the table with the following query:

mysql> CREATE TABLE `procs_priv` (
`Host` char(60) collate utf8_bin NOT NULL default '',
`Db` char(64) collate utf8_bin NOT NULL default '',
`User` char(16) collate utf8_bin NOT NULL default '',
`Routine_name` char(64) collate utf8_bin NOT NULL default '',
`Routine_type` enum('FUNCTION','PROCEDURE') collate utf8_bin NOT NULL,
`Grantor` char(77) collate utf8_bin NOT NULL default '',
`Proc_priv` set('Execute','Alter Routine','Grant') character set utf8 NOT NULL default '',
`Timestamp` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
PRIMARY KEY (`Host`,`Db`,`User`,`Routine_name`,`Routine_type`),
KEY `Grantor` (`Grantor`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin COMMENT='Procedure privileges'

After the table was created you may continue upgrading.

It is recommended to download Plesk distributive from Parallels website, unpack it and install packages with “rpm -Uvh”.

Note: Before executing this command, make sure that you have taken the full backup of MySQL.

OR

cat /usr/share/mysql/mysql_fix_privilege_tables.sql | mysql --no-defaults --force --user=admin -p --host=localhost --database=mysql

[How to] How to configure containers to not apply Microsoft updates installed on Virtuozzo host.

Symptoms

By default Microsoft updates installed on Virtuozzo host are applied in containers during next containers start.

Resolution

If auto applying Microsoft updates in containers is unnecessary option it is possible to configure containers to not install updates even if its are on Virtuozzo host.

The following example shows how to disable this auto applying option for container 100:

vzcfgt set 100 DisableWindowsUpdates 1

If this option is set to “1” no more windows updates will be applied to the container 100.

But you can still manually install or remove windows updates to this container by using Container Update Manager.

To find Container Update Manager click Start button on the node and go to All Programs, Parallels, Parallels Virtuozzo Containers.

The command below enables auto applying option for container 100:

vzcfgt set 100 DisableWindowsUpdates 0

Also it’s possible to disable auto applying option for all newly created containers on a node:

vzcfgt set 0 DisableWindowsUpdates 1

Note: If it’s necessary to enable the auto installation of windows updates back in containers you should re-configure each container separately.

How to change time zone in Linux !

1. Log in as root, check which timezone your machine is currently using by executing `date`. You’ll see something like “Mon Feb 12 05:09:00 CST 2007″, CST in this case is the current timezone.

2. Change to the directory to /usr/share/zoneinfo, here you will find a list of time zone regions. Choose the most appropriate region. If you live in Canada or the US this directory is the “Americas” directory.

3. If you wish, backup the previous timezone configuration by copying it to a different location. Such as `mv /etc/localtime /etc/localtime-old`.

4. Create a symbolic link from the appropiate timezone to /etc/localtime. Example: `ln -s /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime`.

5. If you have the utility rdate, update the current system time by executing `rdate -s time.nist.gov` or `rdate -s rdate.cpanel.net`

6. Synchronize hardware clock with system clock by executing: ` /sbin/hwclock –systohc`

🙂

Plesk 8.x error : Unable to remove hosting: Unable to delete system user: SysUser->systemRemove() failed: usermng failed: Unknown error 0xC00CE558 (COM Error C00CE558) at execute command del” while deleting the domains

I faced a issue while deleted few domains from Plesk 8.6.

Error While deleting a domain from Plesk :

Unable to remove hosting: Unable to delete system user: SysUser->systemRemove() failed: usermng failed: Unknown error 0xC00CE558 (COM Error C00CE558) at execute command del” while deleting the domains

Every domains showed a COM error when tried to delete it. Here is a fix which I found :

Find a file name “DeferredRemovalStorage.xml” under directory %plesk_dir%\etc\ open it in notepad and you will see it empty, add the code as in the file and save :

<?xml version=”1.0″ encoding=”UTF-8″ standalone=”no” ?>

<Entries />

 

Now you will be able to delete the domains fine. If it still not work you can try

cd %plesk_bin%
mchk.exe --domain --domain-name=domain.com --fix=all

What is APF (Advanced Policy Firewall)? APF Firewall

APF is a policy based iptables firewall system designed for ease of use and configuration. It employs a subset of features to satisfy the veteran Linux user and the novice alike. Packaged in tar.gz format and RPM formats, make APF ideal for deployment in many server environments based on Linux. APF is developed and maintained by R-fx Networks: http://www.rfxnetworks.com/apf.php

This guide will show you how to install and configure APF firewall, one of the better known Linux firewalls available.10

Requirements:
– Root SSH access to your server

Lets begin!
Login to your server through SSH and su to the root user.

cd /root/downloads or another temporary folder where you store your files.

2. wget http://www.rfxnetworks.com/downloads/apf-current.tar.gz

3. tar -xvzf apf-current.tar.gz

4. cd  apf-9.6-5/ or whatever the latest version is.

5. Run the install file: ./install.sh
You will receive a message saying it has been installed

Installing APF 9.6-5: Completed.
Installation Details:
Install path:         /etc/apf/
Config path:          /etc/apf/conf.apf
Executable path:      /usr/local/sbin/apf
Other Details
Listening TCP ports: 53,2086,2087,3306
Listening UDP ports: 53,39437

Note: These ports are not auto-configured; they are simply presented for information purposes. You must manually configure all port options.

6. Lets configure the firewall: nano -w /etc/apf/conf.apf
We will go over the general configuration to get your firewall running. This isn’t a complete detailed guide of every feature the firewall has. Look through the README and the configuration for an explanation of each feature.

We like to use DShield.org’s “block” list of top networks that have exhibited
suspicious activity.
FIND: USE_DS="0"
CHANGE TO: USE_DS="1"

7. Configuring Firewall Ports:

Cpanel Servers
We like to use the following on our Cpanel Servers

Common ingress (inbound) ports
# Common ingress (inbound) TCP ports -3000_3500 = passive port range for Pure FTPD
IG_TCP_CPORTS="21,22,25,53,80,110,143,443,2082,2083, 2086,2087, 2095, 2096,3000_3500"
#
# Common ingress (inbound) UDP ports
IG_UDP_CPORTS="53"

Common egress (outbound) ports
# Egress filtering [0 = Disabled / 1 = Enabled]
EGF="1"

# Common egress (outbound) TCP ports
EG_TCP_CPORTS="21,25,80,443,43,2089"
#
# Common egress (outbound) UDP ports
EG_UDP_CPORTS="20,21,53"

Ensim Servers
We have found the following can be used on Ensim Servers – although we have not tried these ourselves as I don’t run Ensim boxes.

Common ingress (inbound) ports
# Common ingress (inbound) TCP ports
IG_TCP_CPORTS="21,22,25,53,80,110,143,443,19638"
#
# Common ingress (inbound) UDP ports
IG_UDP_CPORTS="53"

Common egress (outbound) ports
# Egress filtering [0 = Disabled / 1 = Enabled]
EGF="1"

# Common egress (outbound) TCP ports
EG_TCP_CPORTS="21,25,80,443,43"
#
# Common egress (outbound) UDP ports
EG_UDP_CPORTS="20,21,53"

Save the changes: Ctrl+X then Y

8. Starting the firewall
/usr/local/sbin/apf -s

Other commands:
usage ./apf [OPTION]
-s|--start ......................... load firewall policies
-r|--restart ....................... flush & load firewall
-f|--flush|--stop .................. flush firewall
-l|--list .......................... list chain rules
-st|--status ....................... firewall status
-a HOST CMT|--allow HOST COMMENT ... add host (IP/FQDN) to allow_hosts.rules and
immediately load new rule into firewall
-d HOST CMT|--deny HOST COMMENT .... add host (IP/FQDN) to deny_hosts.rules and
immediately load new rule into firewall

9. After everything is fine, change the DEV option
Stop the firewall from automatically clearing itself every 5 minutes from cron.
We recommend changing this back to “0” after you’ve had a chance to ensure everything is working well and tested the server out.

nano -w /etc/apf/conf.apf

FIND: DEVM="1"
CHANGE TO: DEVM="0"

10. Checking the APF Log

Will show any changes to allow and deny hosts among other things.
tail -f /var/log/apf_log


What’s new in Plesk 9?

Whats new in Plesk 9.0?

With it’s new multilevel control, Parallels Plesk 9 makes it easy to automate web hosting solutions for small business and resellers. There are five login levels to the control panel each level having its own permissions and features.

Administrator – This user has the highest level of permissions. Can be used to easily and quickly setupsystem services, and manage server users.
Reseller – This user has all the same functionality of the administrator except the ability to manage system services.
Client – Third tier login which has the permissions to create domains.
Domain Owner – Fourth tier login with permissions for single domain administration.
Mail User – Individual mail account users can manage passwords, spam filters and antivirus settings.

Resellers level. The resellers level is a new addition in Plesk 9, giving resellers the ability to manage and create their own clients and domains. Resellers can also distribute other services such as application hosting and databases on a per client basis.

Plesk Billing 6.0. Formerly Modernbill, Plesk 6.0 billing is a basic feature included in the installation with Plesk 9. Fully integrated with smooth nagivation between Plesk and Plesk Billing makes this software extremely efficient and easy to use.

APS Catalog. The new APS Catalog, provides the ability to download packages directly from Parallels website and make them available to your customers. Files are downloaded in APS format and added to the server application vault.Permissions for these applications can be provided to everyone or to select customers according to hosting plans.

Postfix Support. An alternative solution to qmail for unix based Plesk.

New Backup Tool. The new backup solution offers on-the-fly restoration conflicts which offer a variety of ways to resolve conflicts prior to a backup restoration.

Overselling/Overuse Capabilities.With the administrator and reseller users you may oversell your system resources to allow for flexibility and growth.

Plesk API 1.6. The updated API further improves the ability to integrate your software solutions with Plesk 9. Updates to the API include support for all new features included in Plesk 9.

Alternative Webmail. Plesk 9 offersfree Atmail Webmail Light 1.0, as a new webmail client, as well as commercial Atmail 5.5 support.

MSSQL 2008 Support. Parallels 9.0 for Windows offers Microsoft SQL Server 2008 support.

Merak 9.3.2 support. Parallels Plesk 9.0 for Windows offers Merak 9.3.2 Mail Server support.

For a full list of new features please see the following URL:

http://www.parallels.com/r/pdfs/Plesk/parallels_plesk_panel9_whatsnew.pdf

DDOS Check !

A quick and usefull command for checking if a server is
under ddos is:

netstat -anp |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c | sort -n

cPanel/WHM cannot be accessed using IP/whm and IP/cpanel

The reason for this issue due to missing some lines in httpd.conf.

Fix
====

1) Open the apache configuration file(httpd.conf) in your favorite editor.

2) Add the following lines in the httpd.conf.

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

ErrorDocument 400 /400.shtml
ErrorDocument 401 /401.shtml
ErrorDocument 403 /403.shtml
ErrorDocument 404 /404.shtml
ErrorDocument 500 /500.shtml
ScriptAlias /cgi-sys/ /usr/local/cpanel/cgi-sys/ Alias /sys_cpanel/ /usr/local/cpanel/sys_cpanel/ Alias /java-sys/ /usr/local/cpanel/java-sys/ Alias /img-sys/ /usr/local/cpanel/img-sys/ Alias /akopia/ /usr/local/cpanel/3rdparty/interchange/share/akopia/

Alias /neo-images/ /usr/local/cpanel/base/neomail/neo-images/
ScriptAliasMatch ^/cpanel/(.*) /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAlias /cpanel /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAlias /whm /usr/local/cpanel/cgi-sys/whmredirect.cgi
ScriptAlias /securewhm /usr/local/cpanel/cgi-sys/swhmredirect.cgi
ScriptAlias /webmail /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/webmail/(.*) /usr/local/cpanel/cgi-sys/wredirect.cgi
ScriptAliasMatch ^/kpanel/(.*) /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAlias /controlpanel /usr/local/cpanel/cgi-sys/redirect.cgi
ScriptAlias /securecontrolpanel /usr/local/cpanel/cgi-sys/sredirect.cgi
Alias /mailman/archives/ /usr/local/cpanel/3rdparty/mailman/archives/public/
ScriptAlias /mailman/ /usr/local/cpanel/3rdparty/mailman/cgi-bin/
Alias /pipermail/ /usr/local/cpanel/3rdparty/mailman/archives/public/
Alias /interchange/ /usr/local/cpanel/3rdparty/interchange/share/interchange/
Alias /interchange-5/ /usr/local/cpanel/3rdparty/interchange/share/interchange-5/

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

3) Now restart the httpd service in the server.

WHM locked out – cphulkd

cPHulk Brute Force Protection prevents malicious forces from trying to access your server’s services by guessing the login password for that service. BUT sometimes it becomes troublesome when you are accessing the cPanel with incorrect password and cPanel assuming you as attacker blocks you with below message :

—————————————————————————————
This account is currently locked out because a brute force attempt was detected. Please wait 10 minutes and try again. Attempting to login again will only increase this delay. If you frequently experience this problem, we recommend having your username changed to something less generic.
—————————————————————————————

To get out of such situation you can disable cphulkd protection :

login via ssh and disable cphulkd using the command below.

# /usr/local/cpanel/bin/cphulk_pam_ctl –disable

This should allow you to login to WHM and double check your cphulk settings.

You can view IP addresses that have been blocked via the WHM interface: WHM -> Security -> Security Center -> cPHulk Brute Force Protection in the Brutes table. On that screen, you can also customize brute force protection settings.

Flush DB will remove all blocked IPs:

WHM >>  Security Center >> cPHulk Brute Force Protection >> Click on Flush DB

Well the other way to this is to remove the IP’s blocked by cPHulk from its database .

ssh to the server login as root and type the following at the prompt

[root@server:] mysql

mysql> use cphulkd;

mysql>BACKUP TABLE  brutes TO ‘/path/to/backup/directory’;

mysql> SELECT * FROM brutes WHERE `IP`=’xxx.xxx.xxx.xxx’;

mysql> DELETE FROM brutes WHERE `IP`=’xxx.xxx.xxx.xxx’;

mysql>quit

🙂