Sunday, December 28, 2014

Unable to remove an IP address "Error: The IP address is already used for hosting"

APPLIES TO:
Parallels Plesk 11.5 for Linux
Parallels Plesk 11.5 for Windows

Symptoms
An attempt to delete an IP address from Parallels Plesk Panel failwith the following error:
Error: The IP address `<ip_address>` is already used for hosting. 
However, in Tools & Settings > IP Addresses, no sites are shown to use this IP address.

Cause
This is caused by a Plesk database inconsistency. The psa.IpAddressesCollections table
was not correctly updated when IP addresses were changed for domains.
Resolution
Create a psa database backup.

Windows:
"%plesk_dir%\MySQL\bin\mysqldump.exe" -uadmin -P8306 -p<PleskPasswordHere> psa > c:\psadump.sql
Linux: 
   mysqldump -uadmin -pcat /etc/psa/.psa.shadow psa > /tmp/psa.date +%F_%H.%M.sql

Find out which id is assigned to the IP address in question, and find any (sub)domains that have this IP address assiged:

mysql> select @ip_id := id from IP_Addresses where ip_address='10.10.10.10';
mysql> SELECT d.name, d.webspace_id, ipac.ipCollectionId,ip.ip_address FROM DomainServices ds INNER JOIN IpAddressesCollections ipac ON ds.ipCollectionId = ipac.ipCollectionId INNER JOIN domains d ON d.id = ds.dom_id  JOIN IP_Addresses ip on ipac.ipaddressid=ip.id WHERE (ds.type = 'web' OR ds.type = 'mail') and ipac.ipAddressId = @ip_id;

Make sure the 10.10.10.10 IP address is replaced with the one to be deleted. 

Find records in the IpAddressesCollections table that correspond to the IP address in question:

mysql> select * from IpAddressesCollections where ipaddressid=@ip_id;

Find out which id is assigned to the IP address that
 should be used for the (sub)domains from the previous output, then 
update the corresponding records of the IpAddressesCollections table:

For example, the 10.10.10.11 IP address should be assigned to example.com:

mysql> set @domain_name := 'example.com';
mysql> select @ip_id_new := id from IP_Addresses where ip_address='10.10.10.11';
mysql> update IpAddressesCollections ipac  INNER JOIN DomainServices ds ON ds.ipCollectionId = ipac.ipCollectionId INNER JOIN domains d ON d.id = ds.dom_id  JOIN IP_Addresses ip on ipac.ipaddressid=ip.id set ipac.ipAddressId=@ip_id_new WHERE (ds.type = 'web' OR ds.type = 'mail') and ipac.ipAddressId = @ip_id and d.name=@domain_name;

Ref:http://kb.sp.parallels.com/en/122207


No comments:

Post a Comment