Sunday, 5 September 2021

How to generate relocate.template file from IBM DB2

 

 
Generate relocate.template from IBM DB2
 
This section describes prerequisites and preparation steps that you have to perform for IBM Db2 for Linux, UNIX, and Windows before starting the system rename procedure.

Prerequisites:

  •     The database instance must be either stopped or - if it is running - there must not be any database connections.
  •     During the procedure it will be started and stopped automatically if required. After the preparation it will be stopped.
  •     Pleases ensure patch level of db6util is patch level 10 or higher. For more information.
  •     The patch level of the brdb6brt tool is patch level 32 or higher.
    If tool brdb6brt does not exist within the /sapmnt/<SAPSID>/exe directory, download and install it.

    IBM Db2 for Linux, UNIX, and Windows V10.1 and Higher only:

    Make sure that your <sapsid>adm user has execute permission for function sysproc.admin_get_storage_paths by running the following command on your source system as user db2<dbsid>:

    db2 "grant execute on specific function sysproc.admin_get_storage_paths to user <sapsid>adm"

    The version of SAP Host Agent must be 7.21 PL 26 or higher.

    If your operating system is Solaris SPARC or Solaris X86_64, the database version must be 9.7 FP7 or higher.

Procedure:

    Make sure that the SAP system is stopped. Use the below command to Create the relocate.template file. This file is required in the tool dialog phase.
 
        On the source system, log on as user db2<dbsid> and create the directory sapdbctrl-config under /tmp. This does not apply if the directory already exists.
        Note

        If directory /tmp does not exist, you must create it before you perform the steps listed below.

        Proceed as follows:

  •         Execute cd /tmp.
  •         Execute mkdir ./sapdbctrl-config
  •         Log off from the system.
  •         Log on again as user root on the source system.
  •         Execute cd /usr/sap/hostctrl/exe.
  •         Execute ./saphostctrl -function PrepareDatabaseCopy -dbname <DBSID> -dbtype db6 -dbconfdir /tmp/sapdbctrl-config/ -dbinstance db2<dbsid> -copymethod Offline -dostatechange.
        The system creates the relocate.template file in the /tmp/sapdbctrl-config directory.

        Check if the file relocate.template contains one or more entries for CONT_PATH or STORAGE_PATH. If not you must not start the system rename procedure.

        This is an example of the files created in the sapdbctrl-config directory:

        root@Techrelam01[Linux]/tmp/sapdbctrl-config > ls -la
        -rw-r----- 1 db2thr dbthradm 2584 Sep 05 19:23 db2thr.cfg
        -rw-r--r-- 1 root   root            46     Sep 05 19:23 db2thr.net
        -rw-r--r-- 1 root   root            8810 Sep 05 19:23 relocate.template

Provide all database-related directories on the target system. This includes the following directories:

    /db2/<DBSID>/

    The file system of the home directory of db2sid (default:/db2/db2<dbsid>).

To provide the required directories, use one of the following methods:
 
Note:
 
The commands below are given as an example if your home directory is db2<dbsid>. You have to adjust them for all required directories.

    If the source and the target system are located on one and the same host, proceed as follows:

    If you want to adjust or rename your SAP system on the same host, keep all directories at their locations.

    The tool will find and move them to the correct directory and set the required ownerships and permissions.

    Note

    If /db2/db2<dbsid> or /db2/<DBSID> is a mount point or there are mount points under these directories proceed as follows:

        Stop the SAP system including its instance agents.

        Unmount the mount points.

        Before you start the system rename, mount the file systems under the target <DBSID> or db2<dbsid>.

    If the source and the target system are located on different hosts, proceed in one of the following ways:

        Mount all file systems manually on the target system
        Recommendation

        This is the recommended option.
        Note

        If /db2/db2<dbsid> or /db2/<DBSID> is a mount point or there are mount points under these directories, then mount the file systems under the target <DBSID> or db2<dbsid>.

        Copy the directories using the copy command of the operating system.
        Note

        When you provide required database related directories on the target host, use the source <DBSID> within the directory names. The tool will find and move them to the correct location and set the required ownership and permissions.

        To keep the current ownership of the directory and softlinks, use an archiving tool as follows:

        source host:~ # tar -cpf /tmp/db2<dbsid_source>.tar /db2/db2<dbsid_source>

        source host:~ # tar -cpf /tmp/<DBSID_source>.tar /db2/<DBSID_source>

        source host:~ # scp /tmp/db2<dbsid_source>.tar <user>@<dbsid_source>:/tmp

        source host:~ # scp /tmp/<DBSID_source>.tar <user>@<target host>:/tmp

        target host:~ # tar -xvf /tmp/db2<dbsid_source>.tar /db2/db2<dbsid_source>

        target host:~ # tar -xvf /tmp/<DBSID_source>.tar /db2/<DBSID_source>

Make sure the contents of the db6_update_db.SAR archive attached to SAP Note 1365982 Information published on SAP site are available in the sapdbctrl-config directory.
Note

Make sure the permissions of file db6_update_db.sh and db6_update_db.jar are rwxr-xr-x. To check the file permissions, enter the following command:

ls -l db6_update_db.sh db6_update_db.jar.

To change the file permission enter the following command:

chmod 755 db6_update_db.sh db6_update_db.jar.

Make sure that you stop all system and database processes before you start the system rename procedure. To check that they are stopped, enter the following command: ps -ef | grep db2  
 
 
 
 
 
 Reference from : Help dot SAP