API Portal 7.5.4 Installation and Upgrade Guide Replicate API Portal instances This section describes how to configure the API Portal instances for high availability. Prerequisites Configure the instances for replication Replicate the database Test the replication Secure the root user The instructions use the names Instance 1 and Instance 2 to differentiate between the two API Portal instances. Prerequisites Host the Joomla! files on a shared storage. To avoid further editing of Apache configurations, it is recommended to use the following default path: mv /opt/axway/apiportal/htdoc /opt/axway/apiportal/htdoc_temp mkdir /opt/axway/apiportal/htdoc mount -t nfs shared.storage.server.int:/mnt/myapiportal /opt/axway/apiportal/htdoc shopt -s dotglob mv /opt/axway/apiportal/htdoc_temp/* /opt/axway/apiportal/htdoc shopt -u dotglob You can adjust the NFS options or make other changes you need. Note For NFS, make sure that the UID and the GUID of the user and group that the Apache on the API Portal uses are present and have the same IDs as on the shared storage. Back up the current Joomla! database with mysqldump. If neither of your API Portal instances have custom setups, you can create a backup from either instance, otherwise you must back up the instances separately. Use the following command to create a backup, and copy the backup file to both machines running the API Portal instances for later use: mysqldump -u root --opt <your database name> <backup file> For example: mysqldump -u root --opt joomla /tmp/api_portal_joomla_db.sql Create a directory on both API Portal instances for the binary database log file. This log is used for the replication. To create the directory and set the permissions, enter the following commands: mkdir /var/log/mysql/chown -R mysql /var/log/mysql/ Configure the instances for replication On Instance 1, go to the mysql config file, and comment out or remove the bind-address line: server-id = 1log_bin = /var/log/mysql/mysql-bin.log binlog_do_db = <your Joomla! database name># bind-address = 127.0.0.1 For security purposes, your database is bound to localhost IP address (127.0.0.1) by default. When you comment out the bind-address, the database server (mysqld) listens on all interfaces (for example, * or 0.0.0.0). This is required for the replication interconnection between theAPI Portal instances. Restart the database server on Instance 1: /etc/init.d/mysqld restart Create a database user and password on Instance 1: mysql -u root << EOFcreate user '<user name>'@'%' identified by '<password>'; grant replication slave on *.* to '<user name>'@'%';flush privileges;EOF For example: mysql -u root << EOFcreate user 'replicator1'@'%' identified by 'password1'; grant replication slave on *.* to 'replicator1'@'%';flush privileges;EOF Repeat the steps on Instance 2. Tip When creating the database user on Instance 2, use a different user name and password (for example, replicator2 and password2) on Instance 1. If you later need to manually search through the logs to identify an issue, this makes it easier to see which instance is affected. Replicate the database Stop the Apache server on both API Portal instances to ensure no application is writing to the database: /etc/init.d/apache2 stop Check that you have the same database on both instances. On Instance 1, enter the following command to import the Joomla! database backup you created in Prerequisites: mysql -u root <database name> < <database backup> For example: mysql -u root joomla < /tmp/api_portal_joomla_db.sql Enter the command show master status, and take a note of the name and position of the master log file: Position and file values may vary. In this example, the master log file is mysql-bin.000003 and the position 120. These details are used to feed the replication engine on Instance 2. On Instance 2, enter the following command for the two-way replication: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '<Instance 1 IP address>', MASTER_USER = '<user name>', MASTER_PASSWORD = '<password>', MASTER_LOG_FILE = '<master log file on Instance 1>', MASTER_LOG_POS = <position on Instance 1>;start slave;EOF The user name and password are the ones you created for Instance 1. For example: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '10.0.1.6', MASTER_USER = 'replicator1', MASTER_PASSWORD = 'password1', MASTER_LOG_FILE = 'mysql-bin.000003', MASTER_LOG_POS = 120;start slave;EOF Repeat the steps 3 and 4 on Instance 2. On Instance 1, enter the following command to complete the two-way replication: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '<Instance 2 IP address>', MASTER_USER = '<user name>', MASTER_PASSWORD = '<password>', MASTER_LOG_FILE = '<master log file on Instance 2>', MASTER_LOG_POS = <position on Instance 2>;start slave;EOF The user name and password are the ones you created for Instance 2. For example: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '10.0.1.5', MASTER_USER = 'replicator2', MASTER_PASSWORD = 'password2', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 423;start slave;EOF Test the replication You can test that the replication between the API Portal instances works, before continuing configuring the HA deployment. Create a dummy table on Instance 1: mysql -u root << EOFuse <database name>;create table <database name>.justatest ('id' varchar(7));EOF For example: mysql -u root << EOFuse joomla;create table joomla.justatest ('id' varchar(7));EOF Go to Instance 2, and enter the command show tables to check that the table exists. Delete the table on Instance 2: mysql -u root << EOFuse <database name>;describe justatest;drop table justatest;EOF Go to Instance 1, and enter the command show tables to check that the table has disappeared. Secure the root user After you finish testing the configuration, complete the final steps: Enter the following to start Apache: /etc/init.d/apache2 start When the database is listening on all interfaces, set a password for the root user: UPDATE mysql.user SET Password=PASSWORD('<your secure password>') WHERE User='root';FLUSH PRIVILEGES; Related topics Configure API Portal for high availability Configure the load balancer API Portal overview Related Links
Replicate API Portal instances This section describes how to configure the API Portal instances for high availability. Prerequisites Configure the instances for replication Replicate the database Test the replication Secure the root user The instructions use the names Instance 1 and Instance 2 to differentiate between the two API Portal instances. Prerequisites Host the Joomla! files on a shared storage. To avoid further editing of Apache configurations, it is recommended to use the following default path: mv /opt/axway/apiportal/htdoc /opt/axway/apiportal/htdoc_temp mkdir /opt/axway/apiportal/htdoc mount -t nfs shared.storage.server.int:/mnt/myapiportal /opt/axway/apiportal/htdoc shopt -s dotglob mv /opt/axway/apiportal/htdoc_temp/* /opt/axway/apiportal/htdoc shopt -u dotglob You can adjust the NFS options or make other changes you need. Note For NFS, make sure that the UID and the GUID of the user and group that the Apache on the API Portal uses are present and have the same IDs as on the shared storage. Back up the current Joomla! database with mysqldump. If neither of your API Portal instances have custom setups, you can create a backup from either instance, otherwise you must back up the instances separately. Use the following command to create a backup, and copy the backup file to both machines running the API Portal instances for later use: mysqldump -u root --opt <your database name> <backup file> For example: mysqldump -u root --opt joomla /tmp/api_portal_joomla_db.sql Create a directory on both API Portal instances for the binary database log file. This log is used for the replication. To create the directory and set the permissions, enter the following commands: mkdir /var/log/mysql/chown -R mysql /var/log/mysql/ Configure the instances for replication On Instance 1, go to the mysql config file, and comment out or remove the bind-address line: server-id = 1log_bin = /var/log/mysql/mysql-bin.log binlog_do_db = <your Joomla! database name># bind-address = 127.0.0.1 For security purposes, your database is bound to localhost IP address (127.0.0.1) by default. When you comment out the bind-address, the database server (mysqld) listens on all interfaces (for example, * or 0.0.0.0). This is required for the replication interconnection between theAPI Portal instances. Restart the database server on Instance 1: /etc/init.d/mysqld restart Create a database user and password on Instance 1: mysql -u root << EOFcreate user '<user name>'@'%' identified by '<password>'; grant replication slave on *.* to '<user name>'@'%';flush privileges;EOF For example: mysql -u root << EOFcreate user 'replicator1'@'%' identified by 'password1'; grant replication slave on *.* to 'replicator1'@'%';flush privileges;EOF Repeat the steps on Instance 2. Tip When creating the database user on Instance 2, use a different user name and password (for example, replicator2 and password2) on Instance 1. If you later need to manually search through the logs to identify an issue, this makes it easier to see which instance is affected. Replicate the database Stop the Apache server on both API Portal instances to ensure no application is writing to the database: /etc/init.d/apache2 stop Check that you have the same database on both instances. On Instance 1, enter the following command to import the Joomla! database backup you created in Prerequisites: mysql -u root <database name> < <database backup> For example: mysql -u root joomla < /tmp/api_portal_joomla_db.sql Enter the command show master status, and take a note of the name and position of the master log file: Position and file values may vary. In this example, the master log file is mysql-bin.000003 and the position 120. These details are used to feed the replication engine on Instance 2. On Instance 2, enter the following command for the two-way replication: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '<Instance 1 IP address>', MASTER_USER = '<user name>', MASTER_PASSWORD = '<password>', MASTER_LOG_FILE = '<master log file on Instance 1>', MASTER_LOG_POS = <position on Instance 1>;start slave;EOF The user name and password are the ones you created for Instance 1. For example: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '10.0.1.6', MASTER_USER = 'replicator1', MASTER_PASSWORD = 'password1', MASTER_LOG_FILE = 'mysql-bin.000003', MASTER_LOG_POS = 120;start slave;EOF Repeat the steps 3 and 4 on Instance 2. On Instance 1, enter the following command to complete the two-way replication: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '<Instance 2 IP address>', MASTER_USER = '<user name>', MASTER_PASSWORD = '<password>', MASTER_LOG_FILE = '<master log file on Instance 2>', MASTER_LOG_POS = <position on Instance 2>;start slave;EOF The user name and password are the ones you created for Instance 2. For example: mysql -u root << EOFstop slave;CHANGE MASTER TO MASTER_HOST = '10.0.1.5', MASTER_USER = 'replicator2', MASTER_PASSWORD = 'password2', MASTER_LOG_FILE = 'mysql-bin.000001', MASTER_LOG_POS = 423;start slave;EOF Test the replication You can test that the replication between the API Portal instances works, before continuing configuring the HA deployment. Create a dummy table on Instance 1: mysql -u root << EOFuse <database name>;create table <database name>.justatest ('id' varchar(7));EOF For example: mysql -u root << EOFuse joomla;create table joomla.justatest ('id' varchar(7));EOF Go to Instance 2, and enter the command show tables to check that the table exists. Delete the table on Instance 2: mysql -u root << EOFuse <database name>;describe justatest;drop table justatest;EOF Go to Instance 1, and enter the command show tables to check that the table has disappeared. Secure the root user After you finish testing the configuration, complete the final steps: Enter the following to start Apache: /etc/init.d/apache2 start When the database is listening on all interfaces, set a password for the root user: UPDATE mysql.user SET Password=PASSWORD('<your secure password>') WHERE User='root';FLUSH PRIVILEGES; Related topics Configure API Portal for high availability Configure the load balancer API Portal overview