Title Migrate Topaz databases from One Server to Another Author: Olivier Lauret Date: November 2004 Modified: Category: Topaz/BAC Version: Topaz 4.5.2, BAC 5.0 and BAC 5.1 Migrate Topaz databases from One Server to Another This document shows how to migrate Topaz databases (management and profile) from one server to another using the backup databases process. The backup process allows using a copy of the real data and then avoiding possible data loss. The integrity of the data on the new server should be checked before deleting the database on the original server. Note: To facilitate the explanation of this document, we are calling server1 the server from where the databases were moved and server2 the new server that will host the databases. Identically, database1 is the (management or/and profile) databases from server1 you want to migrate to server2 and database2 is the database you have migrated into server2. The procedure describes a migration of an MS SQL Server and an Oracle server, however in our lab only the SQL server scenario was tested. The success for the Oracle procedure is not guaranteed but the indication in this document could be of great help for achieving the migration. 1/10
Information needed before starting to process: Concerning the servers (for MS SQL Server): Server - Name of the server1 Database Names names of the existing Topaz Management and Profile databases The sa or equivalent user password on MS SQL Server1. Server - Name of the server2 Concerning the servers (for Oracle Server): User Name and Password (for user schema) the name and password of the existing Topaz Management user schema, or that you will give the new user schema (for example, TOPAZ_MANAGEMENT). TNS Name the TNS name, as specified in the tnsnames.ora file of the local Oracle Client. (For information on the tnsnames.ora file, refer to the Topaz Database Reference Guide.) Oracle Machine Name the name of the host machine on which Oracle Server is installed. Port the Oracle listener port, if different from the default value, 1521 (can also be 1526). SID the Oracle instance name that uniquely identifies the instance of the Oracle database being used by Topaz, if different from the default value, orcl. In addition, if you are creating a new user schema, you need the following information: User Name and Password (for administrator connection) the name and password of a user with administrative permissions on Oracle Server. Default Tablespace the name of the dedicated default tablespace you created for Topaz user schemas (for details on creating a dedicated Topaz tablespace, refer to the Topaz Database Reference Guide). If you did not create, and do not require, a dedicated default tablespace, specify an alternative tablespace (the default Oracle tablespace is called users). Temporary Tablespace the name of the dedicated temporary tablespace you created for Topaz user schemas. If you did not create, and do not require, a dedicated temporary tablespace, specify an alternative tablespace (the default Oracle temporary tablespace is called temp). Concerning the capacity of the server: Make sure that you have enough space in each server to contain the backup databases. 2/10
Step 1: Stop Topaz It is important to check if Topaz is not running. To stop Topaz, select Start > Programs > Topaz > administration > Stop Topaz. Stopping Topaz won t have any consequence on the data. The agents will buffer the data that will be sent when the connection with the Agent server will be active again. Note: Don t stop or restart any of the agents if you don t want to loose data and have continuity in your reports. If Topaz is running and you start the backup session, the backuped databases (when restoring) won t be identical to database1. Here is the reason: during the moment you backup database1 and the moment you connect Topaz to the database2, the agents keep sending data to the database1. You ll need a more complex procedure to recover the lost data (see troubleshooting). 3/10
Step 2: backup the databases Using MS SQL Server: Note: This procedure is only one of the options you have and you can use another option if you find it more convenient like doing it from the Enterprise Manager GUI. Select Start > Programs > Microsoft SQL Server > Query Analyser and type the script bellow. This script execute backup for list of databases (the location for type the DB name is in red) and put the files in some path on the SQL server (in green). After executing this script, just navigate to the path on the SQL server and grab your files. DECLARE @db_name VARCHAR(60) DECLARE @db_path VARCHAR(64) DECLARE @str VARCHAR(512) DECLARE DBs_cur CURSOR FOR SELECT NAME FROM sysdatabases WHERE NAME in('db_name%') --in the 'Name in' section, please fill the db names that you want to backup set @db_path = 'e:\' --set the path to the backup device here OPEN DBs_cur FETCH NEXT FROM DBs_cur INTO @db_name WHILE @@fetch_status = 0 BEGIN SET @str = 'BACKUP DATABASE ' + @db_name + ' TO DISK = ''' + @db_path + @db_name + '.bak''' EXEC (@str) PRINT 'Database ' + @db_name + ' Finished backup!' FETCH NEXT FROM DBs_cur INTO @db_name END DEALLOCATE DBs_cur GO Using Oracle Server: The oracle client that should be used for backup/restore MUST be of 8.1.7 version or higher Just run the next command with correct parameters from the command line: EXP [user_name]/[password]@[server] FILE=[full path+filename +.bak] GRANTS=N BUFFER=10000000 4/10
Step 3: Move the backup databases to server2 Move the file *.bak you just created from the server1 to a temporary file in the server2. This manipulation may take several hours depending on the size of the database. 5/10
Step 4: restore the databases Using MS SQL Server: This step allows users to restore the databases for the Microsoft SQL Server. First of all execute the next query from within the SQL Query Analyzer: restore filelistonly from disk='[full path + file name]' The result of the execution will be small table with 2 rows of data in it. We are interested in the first column of both rows, named LogicalName. Insert the logical names in the query below and complete all the rest of the parameters according to your DB s properties: drop database [Database name] restore database [Database name] from disk= [Full path + file name]' with move [First Logical name] to [Full path to SQL server s data dir+ restored DB name +.mdf]', move [Second Logical name] to [Full path to SQL server s data dir+ restored DB name +.ldf]' Execute this query and the DB s will appear in the list of the SQL server. Using Oracle Server: To restore Oracle DB s, just run the next command with correct parameters from the command line: IMP [user_name]/[password]@[server] FILE=[full path+filename +.bak] FULL=Y GRANTS=N BUFFER=10000000 To restore Topaz Profile/Management on Oracle, make sure that the Oracle databases don t already exist. If exist, you should delete it before following the next manipulation. To restore any Topaz profile/management database on Oracle server, you should create the user with correct grants on the oracle server. You can execute the next script from the oracle SQLPLUS utility (after connected as SYSTEM/MANAGER to the server): create user [New User Name] identified by [Password] default tablespace topaz temporary tablespace temp; 6/10
GRANT "CONNECT" TO [New User Name] ; GRANT CREATE ANY INDEX TO [New User Name] ; GRANT CREATE ANY SEQUENCE TO [New User Name] ; GRANT CREATE ANY TABLE TO [New User Name] ; GRANT CREATE ANY TRIGGER TO[New User Name] ; GRANT UNLIMITED TABLESPACE TO [New User Name] ; GRANT CREATE ANY VIEW TO [New User Name] ; GRANT CREATE ANY PROCEDURE TO [New User Name] ; ALTER USER [New User Name] DEFAULT ROLE ALL; After execution of the user creation script, you can execute the restore command from the command prompt as described above. As the Username/Password you should give the new created user s parameters. 7/10
Step 5: Modification in Topaz Modification in the management database: In the Management database of Topaz, which is located in the server2, open the sessions table (if using Microsoft SQL Server, you can open the table by using Start > Programs > Microsoft SQL Server > Enterprise Manager). You notice that the values of SESSION_DB_SERVER and SESSION_DB_HOST have to be changed. To do so, open a SQL pane (in Enterprise Management) and execute the following queries: UPDATE SET WHERE UPDATE SET WHERE SESSIONS SESSION_DB_SERVER = <name of the server2 in MS SQL Server or TNS name of the database2 in Oracle Server > SESSION_DB_SERVER = <name of the server1 in MS SQL Server or TNS name of the database1 in Oracle Server > SESSIONS SESSION_DB_HOST = <host name of the machine where server2 is running> SESSION_DB_HOST = <host name of the machine where server1 is running> If the username and/or the password changed execute also these queries: -- Execute this if the username has changed UPDATE SESSIONS SET SESSION_DB_UID = <new username> WHERE SESSION_DB_UID = <old username> -- Execute this if the password has changed (1/2) UPDATE SESSIONS SET SESSION_DB_PWD = <new password> WHERE SESSION_DB_PWD = <old password> -- Execute this if the password has changed (2/2) UPDATE SESSIONS SET SESSION_DBETYPE = 0 WHERE SESSION_DBETYPE = 1 8/10
Note: You need to run the 2 queries one after the other before you close the session to this table. A SESSION_DBETYPE set to 1 means that the password is encoded. If you enter a password without setting this value to 0, Topaz will try to decode a non-encoded word and won t understand. The password will be considered as wrong. For Oracle, SESSION_DB_SID should be changed to reflect the sid of the new Oracle instance Finally, check if the SESSION_DB_PORT is 1433 for SQL and 1521 for Oracle. Connect to database. Please follow the Topaz to connect Topaz to the new server. 9/10
Step 6: Start Topaz Now, you can start Topaz and everything should work like before. Troubleshooting Problem I didn t stop Topaz before starting the backup of the databases and now some data are missing when I connect to the new server. Solution One of the solutions to recover the data is to submit these data to the transaction buffer a second time. Thus, the data will be sent to the database. 1. Open the folder <Topaz server root folder>\transaction_buffers\processed. 2. Cut all *.bfr files where the modified time corresponds to the time you lost your data and paste them in the folder <Topaz server root folder>\transaction_buffers. 3. Wait few minutes until these files are moved automatically to the Processed folder. Your data are now recovered. 10/10