• Article for your preferred language does not exist. Below is international version of the article.

Article ID: 114852, created on Sep 27, 2012, last review on Jul 19, 2016

  • Applies to:
  • Odin Business Automation Standard 4.5

Symptoms

A provider wants to move the OBAS database to a separate server to reduce the load on the OBAS backend.

This article provides a detailed description of how to move the OBAS database to a separate server, provided that the database server is a Virtuozzo Container.

Instructions for moving the OBAS database to a separate server are also provided in the OBAS Advanced Configuration Manual.

IMPORTANT

In the examples below, the following values must be replaced with real ones:

98 – Container ID of database server

10.55.47.28 – IP address of database server

pbas40db.provider.com – FQDN hostname of database server

2G – Memory limit for database server

100G – Disk space for database server

90 - Container ID of OBAS server

10.55.47.31 – IP address of OBAS server

pbas40.provider.com – FQDN hostname of OBAS server

MySQL database transfer to separate container-based server

1. Create and configure new container for database and install MySQL server here

# vzctl create 98 --ostemplate centos-5-x86
Creating Container private area (centos-5-x86)
Container is mounted
Postcreate action done
Container is unmounted
Container private area created
Container registered succesfully

Set IP address and hostname for database server:

# vzctl set 98 --save --ipadd 10.55.47.28 --hostname pbas40db.provider.com
Adding IP address(es) to pool: 10.55.47.28
Saved parameters for Container 98

Set SLM mode and memory limit to 2G for the container:

# vzctl set 98 --save --slmmode slm --slmmemorylimit 2G
Setup slm memory limit
Saved parameters for Container 98

Set other parameters:

# vzctl set 98 --save --onboot yes --offline_management no --diskspace 100G
Delete port redirection
Deleting IP address(es) from pool: 10.55.47.28
Saved parameters for Container 98

Start the container:

# vzctl start 98
Starting Container ...
Container is mounted
Setup slm memory limit
Setup slm subgroup (default)
Setting devperms 20006 dev 0x7d00
Adding IP address(es): 10.55.47.28
Hostname for Container set: pbas40db.provider.com
Container start in progress...

Add hostname of OBAS server to /etc/hosts on database server:

# echo "10.55.47.31 pbas40.provider.com" >> /vz/root/98/etc/hosts

Upload MySQL 5 and perl DB RPM packages from the OBAS distributive to the database server. Assume that the distributive is located in /root/ on the OBAS server:

# scp /vz/root/90/root/<PBAS-distributive>/packages/mysql-* /vz/root/90/root/<PBAS-distributive>/packages/perl-DBD-* /vz/root/90/root/<PBAS-distributive>/packages/perl-DB* /vz/root/98/root/

Enter the database container:

# vzctl enter 98

Execute the commands below in the database container:

  • Stop the Apache server:

    # /etc/init.d/httpd stop
    Stopping httpd:                                            [  OK  ]
    
  • Disable the Apache server:

    # chkconfig --del httpd
    
  • Set the root password:

    # passwd
    Changing password for user root.
    New UNIX password:
    Retype new UNIX password:
    passwd: all authentication tokens updated successfully.
    
  • Install the MySQL RPM packages (provided that you put them in the /root folder in the database container):

    # rpm -ihv rpm -ihv /root/mysql-* /root/perl-DB*
    warning: /root/mysql-5.0.77-4.el5_6.6.i386.rpm: Header V3 DSA signature: NOKEY, key ID e8562897
    Preparing...                ########################################### [100%]
       1:perl-DBI               ########################################### [ 25%]
       2:mysql                  ########################################### [ 50%]
       3:perl-DBD-MySQL         ########################################### [ 75%]
       4:mysql-server           ########################################### [100%]
    
  • Start MySQL:

    # /etc/init.d/mysqld start
    
  • Exit from the container:

    # logout
    exited from Container 98
    

2. Transfer OBAS database to separate container

Use the script hspc-cluster.pl -b with a few additional actions. The script performs the following actions:

  • Stops and disables local MySQL service in OBAS server
  • Transfers /var/lib/mysql directory using rsync to the database server
  • Enables network access to MySQL on database server (so it is worthwhile to use private IP network or close access to MySQL on database server from outside by firewall)
  • Configures MySQL users for remote access from OBAS host to the database server

Execute the following commands inside OBAS server:

Add IP address of the database server to /etc/hosts in OBAS server:

# echo "10.55.47.28 pbas40db.provider.com" >> /etc/hosts

Stop Service Monitor:

# /etc/init.d/servicemon stop
Stopping HSPcomplete Service Monitor:                      [  OK  ]

Stop Task Manager:

# /etc/init.d/taskmand stop
Stopping HSPcomplete Task Manager:                         [  OK  ]

Run the script /usr/sbin/hspc-cluster. Make sure to enter the proper values when requested:

# hspc-cluster.pl -b
Using /etc/hspc/hspc.conf as configuration file
Configure main database? [yes]:
Configuring MAIN database.
Enter hostname for MAIN database[localhost]: pbas40db.provider.com
Enter user for MAIN database [aspcomplete]:
Enter name for MAIN database [aspc]:
Enter password for MAIN database [*********]:
Configure mutex database? [yes]:
Configuring MUTEX database.
Enter hostname for MUTEX database [pbas40db.provider.com]:
Enter user for MUTEX database [aspcomplete]:
Enter name for MUTEX database [aspc_mutex]:
Enter password for MUTEX database [*********]:
Configure session database? [yes]:
Configuring SESSION database.
Enter hostname for SESSION database [pbas40db.provider.com]:
Enter user for SESSION database [aspsession]:
Enter name for SESSION database [dbsession]:
Enter password for SESSION database [*********]:
Configure sk database? [yes]:
Configuring SK database.
Enter hostname for SK database [pbas40db.provider.com]:
Enter user for SK database [aspcsk]:
Enter name for SK database [sk]:
Enter password for SK database [*********]:
Configure ss database? [yes]:
Configuring SS database.
Enter hostname for SS database [pbas40db.provider.com]:
Enter user for SS database [aspcss]:
Enter name for SS database [ss]:
Enter password for SS database [*********]:
Stopping HSPcomplete Service Monitor:                      [  OK  ]
Configure database on a separate node now?[no]: yes
Enter hostname of the database node[]: pbas40db.provider.com
Generating public/private dsa key pair.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_dsa.
Your public key has been saved in /root/.ssh/id_dsa.pub.
The key fingerprint is:
fd:26:af:5f:60:24:d8:56:34:ef:45:e8:04:c1:6e:54 root@pbas40.provider.com
The authenticity of host 'pbas40db.plesk.ru (10.55.47.28)' can't be established.
RSA key fingerprint is 01:fd:75:47:6f:10:d9:c7:78:49:b2:d8:e8:1a:24:a5.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'pbas40db.plesk.ru,10.55.47.28' (RSA) to the list of known hosts.
root@pbas40db.provider.com's password:
Stopping hspcd:                                            [  OK  ]
Stopping MySQL:                                            [  OK  ]
Stopping remote services ... Killing mysqld with pid 3075
Wait for mysqld to exit. done
Connection to pbas40db.provider.com closed.
done.
        8898 100%    0.00kB/s    0:00:00 0.00kB/s    0:00:00
                       ... here will be long output of the "rsync -e ssh -azrH --progress /var/lib/mysql pbas40db.provider.com:/var/lib" command" ...
        8756 100%    0.00kB/s    0:00:00
done.
Starting remote services ... Connection to pbas40db.provider.com closed.
done.
Configuring 'pbas40db.provider.com'...
Using /etc/my.cnf as configuration file
Connection to pbas40db.provider.com closed.
Old configuration file saved as /etc/hspc/hspc.conf.hspc.backup.
Saving firewall rules to /etc/sysconfig/iptables:          [  OK  ]
Firewall configuration has been successfully finished.
Restart 'hspcd' service? [yes]:yes
Stopping hspcd:                                            [FAILED]
Starting hspcd:                                            [  OK  ]
Restart 'taskmand' service? [yes]:no
Disabling service(s): 'mysqld'
Stopping MySQL:                                            [FAILED]
Starting HSPcomplete Service Monitor:                      [  OK  ]

Stop Service Monitor:

# /etc/init.d/servicemon stop
Stopping HSPcomplete Service Monitor:                      [  OK  ]

3. Verify main OBAS functionality – Open OBAS control panel and confirm that the system works

The rollback procedure occurring in this stage is provided below (perform it in the OBAS server if you see a problem with OBAS after the database is moved to the separate server).

Stop OBAS services:

# /etc/init.d/servicemon stop
Stopping HSPcomplete Service Monitor:                      [  OK  ]
# /etc/init.d/taskmand stop
Stopping HSPcomplete Task Manager:                         [  OK  ]
# /etc/init.d/vzcoll stop
Stopping HSPcomplete VZAgent Collector:                    [  OK  ]
# /etc/init.d/hspcd stop
Stopping hspcd:                                            [  OK  ]
# /etc/init.d/pdns stop
Stopping PowerDNS authoritative nameserver: Scheduling exit

Restore OBAS configuration files from backup and enable local MySQL service:

# mv /etc/hspc/hspc.conf /etc/hspc/hspc.conf.failed
# mv /etc/hspc/hspc.conf.hspc.backup /etc/hspc/hspc.conf
# chkconfig --level 2345 mysql on

Start PBA-S services:

# /etc/init.d/mysql start
# /etc/init.d/pdns start
Starting PowerDNS authoritative nameserver: started
# /etc/init.d/hspcd start
Starting hspcd:                                            [  OK  ]
# /etc/init.d/vzcoll start
Starting HSPcomplete VZAgent Collector:                    [  OK  ]
# /etc/init.d/taskmand start
Starting HSPcomplete Task Manager:                         [  OK  ]
# /etc/init.d/servicemon start
Starting HSPcomplete Service Monitor:                      [  OK  ]

4. Configure PowerDNS (if you verified that OBAS is working in the previous step)

Grant access privileges for the pdns user from the OBAS server in MySQL on the database server.

Enter the database Container #98 (or log in to it using SSH):

# vzctl enter 98
entered into Container 98

Connect to MySQL database aspc:

# mysql aspc

Run the following SQL queries:

mysql> GRANT SELECT ON dm_zone TO pdns@pbas40.provider.com;
mysql> GRANT SELECT ON dm_record TO pdns@pbas40.provider.com;
mysql> GRANT ALL ON pdns_data TO pdns@pbas40.provider.com;
mysql> FLUSH PRIVILEGES;

Check granted privileges; they should look like this:

mysql> SHOW GRANTS FOR pdns@pbas40.provider.com;
+----------------------------------------------------------------------------+
| Grants for pdns@pbas40.provider.com                                        |
+----------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'pdns'@'pbas40.provider.com'                         |
| GRANT SELECT ON `aspc`.`dm_record` TO 'pdns'@'pbas40.provider.com'         |
| GRANT ALL PRIVILEGES ON `aspc`.`pdns_data` TO 'pdns'@'pbas40.provider.com' |
| GRANT SELECT ON `aspc`.`dm_zone` TO 'pdns'@'pbas40.provider.com'           |
+----------------------------------------------------------------------------+
4 rows in set (0.00 sec)

Quit MySQL console:

mysql> quit

Log out from database server:

# logout
exited from Container 98

Switch Power DNS to the new database server:

# hspc-cluster.pl -p
Using /etc/powerdns/pdns.conf as configuration file
Enter the address of PowerDNS server's host [Enter to Skip] [pbas40.provider.com]:
Configuring MYSQL..
Configuring 'pbas40db.provider.com'...
Using /etc/my.cnf as configuration file
Connection to pbas40db.provider.com closed.
Restart 'pdns' service? [yes]:yes
Restarting PowerDNS authoritative nameserver: stopping and waiting..done
Starting PowerDNS authoritative nameserver: started

Check that there are no error records in /var/log/messages inside the OBAS server for PowerDNS.

5. Finalize database transfer – Start Task Manager and Service Monitor in OBAS server

# /etc/init.d/taskmand start
Starting HSPcomplete Task Manager:                         [  OK  ]
# /etc/init.d/servicemon start
Starting HSPcomplete Service Monitor:                      [  OK  ]

Additional information

For OBAS versions 3.x, 4.0, 4.1, 4.2: Move OBAS database to separate server (MySQL4)

Search Words

pbas install

Upgrade of PBAS system

Move PBA-S database to separate server

.

After Moving MySQL Database shop is not displayed correctly

70a5401e8b9354cd1d64d0346f2c4a3e caea8340e2d186a540518d08602aa065 400e18f6ede9f8be5575a475d2d6b0a6 624ca542e40215e6f1d39170d8e7ec75

Email subscription for changes to this article
Save as PDF