### Install Db2 Instance-Owning Server (Windows Example) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=environment-setting-up-partitioned-database Example of using the setup command with the db2server.rsp response file on Windows. ```batch setup -u c:\resp_files\db2server.rsp ``` -------------------------------- ### Install Db2 Participating Server (Windows Example) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=environment-setting-up-partitioned-database Example of using the setup command with the db2server_addpart.rsp response file on Windows. ```batch setup -u c:\resp_files\db2server_addpart.rsp ``` -------------------------------- ### Start Db2 Instance (Example) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=installation-updating-node-configuration-file An example of starting the Db2 instance when the instance home directory is /db2home/db2inst1. ```bash /db2home/db2inst1/sqllib/adm/db2start ``` -------------------------------- ### Example of Silent Installation Command Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=aim-data-server-runtime-client-installation-command-line-options An example command demonstrating how to start the silent installation with a specific executable, log file, and response file path. ```bash v9.5fp4_nt32_rtcl /v"/l*v c:\DB2LOG\db2rtcl.log /qn RSP_FILE_PATH=c:\db2rtcl.rsp" ``` -------------------------------- ### Launch Db2 Setup Wizard with Logging Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=idpea-installing-db2-purescale-feature-using-db2-setup-wizard Start the Db2 Setup wizard from the extracted installation directory. This command enables detailed logging for setup and trace information. ```bash ./db2setup -l /tmp/db2setup.log -t /tmp/db2setup.trc ``` -------------------------------- ### Start Db2 Installation (C-based Application) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=file-embedding-db2-installation-image-linux-unix Use this command in a C-based installation application to start the Db2 installation process. Ensure the 'image' path points to the Db2 installable image and 'response_file' is the full path to your response file. ```bash ./InstallTester image -r response_file ``` -------------------------------- ### Install Db2 Instance-Owning Server (Linux/UNIX Example) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=environment-setting-up-partitioned-database Example of using the db2setup command with the db2server.rsp response file on Linux or UNIX. ```bash ./db2setup -r /home/db2server.rsp ``` -------------------------------- ### Start Db2 Installation (Java-based Application) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=file-embedding-db2-installation-image-linux-unix Use this command in a Java-based installation application to start the Db2 installation process. Ensure the 'image' path points to the Db2 installable image and 'response_file' is the full path to your response file. ```java java InstallTester image -r response_file ``` -------------------------------- ### Install Db2 Participating Server (Linux/UNIX Example) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=environment-setting-up-partitioned-database Example of using the db2setup command with the db2server_addpart.rsp response file on Linux or UNIX. ```bash /db2setup -r /home/db2server_addpart.rsp ``` -------------------------------- ### Start Db2 Setup Wizard Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=ids-installing-data-studio-using-db2-setup-wizard-linux Execute the db2setup command from the directory where the database product image resides to launch the Db2 Setup wizard. ```bash ./db2setup ``` -------------------------------- ### Example Permissions for Installation Directory Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=aix-preinstallation-checklist-db2-purescale-feature Ensures the installation directory and its parent directories have the correct read and execute permissions. ```shell drwxr-xr-x. ``` -------------------------------- ### Example: Install Db2 Partition Server with Specific Response File Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=lu-installing-database-partition-servers-using-response-file-linux-unix An example of the db2setup command, showing how to specify a response file named AddPartitionResponse.file located in the /db2home directory. ```bash ./db2setup -r /db2home/AddPartitionResponse.file ``` -------------------------------- ### Install Db2 Instance-Owning Server (Windows) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=environment-setting-up-partitioned-database Use the setup command with a response file to install the Db2 database product and create an instance on Windows systems. ```batch setup -u x:\\ ``` -------------------------------- ### Install Tivoli SA MP License (Example) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=adl-installation-db2-license-certificates-in-db2-purescale-environment Example command to install a specific version of the Tivoli SA MP license, such as version 3.2, from its location on the product media. ```bash samlicm -i /opt/ibm/db2/V10.5/sd/db2/linuxamd64/tsamp/license/sam32.lic ``` -------------------------------- ### Run Db2 Setup with Response File Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=file-windows Execute the Db2 setup command with the '-u' flag to specify a customized response file for an unattended installation. ```bash setup -u my.rsp ``` -------------------------------- ### Enable tracing for setup on Windows Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=installation-collecting-data-problems Run the setup command with the -t option to enable tracing and direct the output to a specified file. This is useful for diagnosing installation issues on Windows. ```batch setup -t \filepath\trace.out ``` -------------------------------- ### Run SQL Toolkit Setup Script Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=nps-installing-db-sql-extension-toolkit Execute the setup script to install the SQL Extension Toolkit. The '-schema' option specifies the schema for registration. You will be prompted for the password if not provided. ```bash [bluadmin@host - Db2wh db_sqltoolkit_x86_64]$ ./setup.py -schema sqltk [INFO] : Checking required files ... [INFO] : Connecting user bluadmin with 172.16.176.74:50000/BLUDB Enter password for bluadmin : [INFO] : STRING_UNITS detected as : SYSTEM [INFO] : The files have been uploaded. [INFO] : Registering the functions ... [INFO] : Successfully operated .. [bluadmin@host - Db2wh db_sqltoolkit_x86_64]$ ``` -------------------------------- ### Install DB2 Partition Server Using Response File (Windows) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=rf-installing-database-partition-servers-participating-computers-using-response-file-windows Execute the setup command with the '-u' flag followed by the path to your response file. This command initiates the installation of database partition servers on participating computers. ```batch setup -u responsefile_directory\response_file_name ``` ```batch setup -u c:\reponsefile\Addpart.file ``` -------------------------------- ### Start Db2 Instance and Activate Database Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=management-tutorial-db2-workload Before beginning the tutorial exercises, ensure the Db2 instance is started and the SAMPLE database is activated. This is a prerequisite for most operations. ```bash db2start db2 activate db sample ``` -------------------------------- ### Install and Start DB2 Script Daemon (Windows) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=daemon-db2script-command-options-examples Installs and then starts the DB2 script daemon on a Windows system. These commands are typically run sequentially. ```bash db2script_daemon -a install db2script_daemon -a start ``` -------------------------------- ### Example output of GET STMM TUNING command Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=acrac-get-stmm-tuning-using-admin-cmd This is an example of the result set returned by the 'get stmm tuning member' command, showing the user-preferred and current tuning member numbers. ```text Result set 1 -------------- USER_PREFERRED_NUMBER CURRENT_NUMBER -------------------- -------------- 2 2 1 record(s) selected. Return Status = 0 ``` -------------------------------- ### Example Db2 NodePort service output Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=warehouse-connecting-premise-kubernetes-through-ingress-controller This is an example of the output from the 'oc get svc' command, showing the NodePort mappings. The SSL NodePort in this example is 31235. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE c-db2inst1-db2u-engn-svc NodePort 172.30.123.45 50000:31234/TCP,50001:31235/TCP 5d ``` -------------------------------- ### Install Db2 with Response File Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=unix-installing-db2-using-response-file Use the `db2setup` command with a response file to automate the Db2 installation process. Specify log and trace file locations for debugging. ```bash db2setup -r /mydir/db2aese.rsp -l /tmp/db2setup.log -t /tmp/db2setup.trc ``` -------------------------------- ### Install with Response File and Log Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=aim-data-server-runtime-client-installation-command-line-options Use this command to perform a response file installation and create a log file for troubleshooting. Ensure the log file path is valid. ```command-line setup /v" /l*v [Full path to a log file] /qn RSP_FILE_PATH=[Full path to the response file]" ``` -------------------------------- ### Launch Db2 Setup Wizard Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=characteristics-upgrading-db2-purescale-server Launch the Db2 Setup wizard to install Db2 version 12.1. Use the 'New Install' option on the Welcome panel and select Db2 Version 11.5 Advanced Editions with Db2 pureScale. ```bash db2setup -l /tmp/db2setup.log -t /tmp/db2setup.trc ``` -------------------------------- ### Execute Db2 Product Installation with Response File Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=windows-installing-db2-product-using-response-file Run the Db2 setup command with the '-u' flag followed by the full path and file name of the response file. Ensure all instance profiles are in the same directory as the response file if generated by the response file generator. ```bash setup -u response_file ``` -------------------------------- ### Ordering Constraint for HADR Database Start Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=pacemaker-base-component Ensures the database resource starts before the primary VIP resource in an HADR setup. ```xml ``` -------------------------------- ### Example output with IP address Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=warehouse-connecting-through-loadbalancer-service-cloudprovider-kubernetes This is an example of the output from 'oc get svc' when an IP address is assigned to the LoadBalancer service. ```text NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE c-db2inst1-db2u-external LoadBalancer 172.30.123.45 52.123.45.67 50000:31234/TCP,50001:31235/TCP 2m ``` -------------------------------- ### Start GPFS Cluster Command Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=messages-dbi20000-dbi20499 Use this command to start a GPFS cluster when DBI20020E is encountered. Ensure the path is correct for your installation. ```bash /bin/db2cluster -cfs -start -all ``` -------------------------------- ### Example: Install a JAR file Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=routines-jar-file-administration Registers a JAR file located at '/home/bob/bobsjar.jar' with the database instance, identifying it as 'MYJAR'. Subsequent SQL commands will refer to this JAR using 'MYJAR'. ```sql CALL sqlj.install_jar( 'file:/home/bob/bobsjar.jar', 'MYJAR' ) ``` -------------------------------- ### Verify corosync-qdevice Package Installation Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=db2cm-installing-configuring-quorum-device Check if the corosync-qdevice package is installed on the primary and standby hosts. This is a prerequisite for quorum device setup. ```bash rpm -qa | grep corosync-qdevice ``` -------------------------------- ### Install Db2 Instance-Owning Server (Linux/UNIX) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=environment-setting-up-partitioned-database Use the db2setup command with a response file to install the Db2 database product and create an instance on Linux or UNIX systems. ```bash ./db2setup -r // ``` -------------------------------- ### Retrieve All Latches from Current Member (Example) Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=mmr-mon-get-latch-list-all-latches-in-current-member-1 This example demonstrates how to call MON_GET_LATCH to get all latches from the current member when search_args is not provided. ```sql CLOB('123') ``` -------------------------------- ### Create Server with Optional Options Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=source-create-server-statement-examples-script-wrapper Use this example to register a server definition for the script wrapper with additional options like NODE and DAEMON_PORT. ```sql CREATE SERVER server1_scriptn WRAPPER script_wrapper OPTIONS(NODE 'big_rs.company.com', DAEMON_PORT '4088'); ``` -------------------------------- ### Create and Populate Data Source Database Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=federation-configuring-high-availability-data-source-database Use these commands to create a new database and a sample table, then insert data. This is the initial setup for the data source. ```sql db2 create db ds create table t11 (i int, c char(20)); insert into t11 values (11, 'dsds'); ``` -------------------------------- ### Get Instance Keystore Settings Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=aracp-admin-get-encryption-info-get-database-encryption-settings-1 This example shows how to retrieve information about the instance's keystore settings, including the keystore file path, type, host, IP address, and IP type. ```APIDOC ## ADMIN_GET_ENCRYPTION_INFO ### Description Returns the current encryption settings for a database, focusing on keystore details. ### Authorization EXECUTE privilege on the routine. Granted by SECADM. ### Schema SYSPROC ### Information Returned - KEYSTORE_NAME (VARCHAR(255)): Absolute path of the keystore file location. - KEYSTORE_TYPE (VARCHAR(20)): Type of keystore. - KEYSTORE_HOST (VARCHAR(255)): Host name of the server where the keystore file is located. - KEYSTORE_IP (VARCHAR(40)): IP address of the server where the keystore file is located. - KEYSTORE_IP_TYPE (VARCHAR(16)): Type of the IP address of the keystore (IPV4 or IPV6). ### Example ```sql SELECT KEYSTORE_NAME, KEYSTORE_TYPE, KEYSTORE_HOST, KEYSTORE_IP, KEYSTORE_IP_TYPE FROM TABLE(SYSPROC.ADMIN_GET_ENCRYPTION_INFO()) ``` ``` -------------------------------- ### Setup Table for KML Conversion Examples Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=functions-st-askml These INSERT statements prepare the 'kmltab' table with various geometry types for use in subsequent ST_AsKML examples. ```SQL INSERT INTO kmltab VALUES (7001, db2gse.ST_Geometry('point(1 2)', 1003) ), (7002, db2gse.ST_Geometry('linestring(33 2, 34 3, 35 6)', 1003) ), (7003, db2gse.ST_Geometry('polygon((3 3, 4 6, 5 3, 3 3))', 1003)) ; ``` ```SQL INSERT INTO kmltab VALUES (7004, db2gse.ST_Geometry(' 5060 ', 1003)) ; ``` ```SQL INSERT INTO kmltab VALUES (7005, db2gse.st_geometry('multilinestring ( (33 2, 34 3, 35 6), (28 4, 29 5, 31 8, 43 12), (39 3, 37 4, 36 7) )', 1003)) ; ``` -------------------------------- ### Example seccomp configuration file Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=routines-using-seccomp-filter-syscalls This example demonstrates the syntax for a seccomp configuration file, specifying allowed syscalls and comments. Note that this is an example and should not be used directly. ```text #Seccomp config file # Used by DB2_SECCOMP_ENABLE to filter out syscalls. socket # Used by workload A getsockopt # Needed by workload B sysinfo # Need sysinfo to check msync getdents # We can have lines that are only comments, they will be ignored. capget mount 80 # Allow chdir, 80 refers to chdir on x86_64 ``` -------------------------------- ### Get Length of Date Converted to String Source: https://www.ibm.com/docs/en/db2/12.1.x?topic=functions-length Use LENGTH after converting a DATE to a CHAR type to get the string length. This example returns 10. ```SQL LENGTH(CHAR(START_DATE, EUR)) ```