3. Force all applications and users off the database. You require SYSADM or SYSCTRL authority to force users Restrictions: The db2stop command can only be run at the server. No database connections are allowed when running this command; however, if there are any instance attachments, they are forced off before DB2 is stopped Note: If command line processor sessions are attached to an instance, you must run the terminate command to end each session before running the db2stop command The db2stop command stops the instance defined by the db2iNStance environment variable Pr rocedure To stop a DB2 instance on your system, use one of the following methods dstop Stop the service using the Control Center 1. Expand the object tree until you find the Instances folder. 2.Click each instance you want to stop. 3. Right-click any of the selected instances, and select stop from the pop-up menu 4.On the Confirm stop window, click OK. Stop using the"NET STOP"command Stop the instance from within an application. Recall that when you are using DB2 in a partitioned database environment, each database partition server is started as a service. Each service must be stopped Related reference: db2stop-Stop DB2" in the Command reference Preparing to Create a Database There are many concepts and tasks you should consider as part of the work to be done before you actually create a database. These concepts and tasks include designing your database and establishing the instance, the directories, and the other support files needed to work with a database. These topics are Designing Logic gical and Physical Database Characteristics · Instance creation Chapter 1. Before Creating a Database 17
3. Force all applications and users off the database. You require SYSADM or SYSCTRL authority to force users. Restrictions: The db2stop command can only be run at the server. No database connections are allowed when running this command; however, if there are any instance attachments, they are forced off before DB2 is stopped. Note: If command line processor sessions are attached to an instance, you must run the terminate command to end each session before running the db2stop command. The db2stop command stops the instance defined by the DB2INSTANCE environment variable. Procedure: To stop a DB2 instance on your system, use one of the following methods: v db2stop v Stop the service using the Control Center 1. Expand the object tree until you find the Instances folder. 2. Click each instance you want to stop. 3. Right-click any of the selected instances, and select stop from the pop-up menu. 4. On the Confirm stop window, click OK. v Stop using the “NET STOP” command. v Stop the instance from within an application. Recall that when you are using DB2 in a partitioned database environment, each database partition server is started as a service. Each service must be stopped. Related reference: v “db2stop - Stop DB2” in the Command Reference Preparing to Create a Database There are many concepts and tasks you should consider as part of the work to be done before you actually create a database. These concepts and tasks include designing your database and establishing the instance, the directories, and the other support files needed to work with a database. These topics are covered here: v Designing Logical and Physical Database Characteristics v Instance creation Chapter 1. Before Creating a Database 17
Environment Variables and the Profile Registry DB2 Administration Server Creating a node configuration file Creating the database configuration file Fast communications manager(FCM)communications Designing Logical and Physical Database Characteristics You must make logical and physical database design decisions before you create a database. To find out more about logical and physical database design, refer to Administration Guide: Planning Instance creation n instance is a logical database manager environment where you catalog databases and set configuration parameters. Depending on your needs, you can create more than one instance. You can use multiple instances to do the following Use one instance for a development environment and another instance for a roduction environment Pr Tune an instance for a particular environment Restrict access to sensitive information Control the assignment of SYSADM, SYSCTRL, and SYSMAINT authority for each instance Optimize the database manager configuration for each instance Limit the impact of an instance failure. In the event of an instance failure, only one instance is affected. Other instances can continue to function normally It should be noted that multiple instances have some minor disadvantages Additional system resources(virtual memory and disk space) are required More administration is required because of the additional instances to The instance directory stores all information that pertains to a database instance. You cannot change the location of the instance directory once it created. The directory contains The database manager configuration file The system database directory The node directory The node configuration file(db2nodes. cfg) 18 Administration Guide: Implementation
v Environment Variables and the Profile Registry v DB2 Administration Server v Creating a node configuration file v Creating the database configuration file v Fast communications manager (FCM) communications Designing Logical and Physical Database Characteristics You must make logical and physical database design decisions before you create a database. To find out more about logical and physical database design, refer to Administration Guide: Planning. Instance creation An instance is a logical database manager environment where you catalog databases and set configuration parameters. Depending on your needs, you can create more than one instance. You can use multiple instances to do the following: v Use one instance for a development environment and another instance for a production environment. v Tune an instance for a particular environment. v Restrict access to sensitive information. v Control the assignment of SYSADM, SYSCTRL, and SYSMAINT authority for each instance. v Optimize the database manager configuration for each instance. v Limit the impact of an instance failure. In the event of an instance failure, only one instance is affected. Other instances can continue to function normally. It should be noted that multiple instances have some minor disadvantages: v Additional system resources (virtual memory and disk space) are required for each instance. v More administration is required because of the additional instances to manage. The instance directory stores all information that pertains to a database instance. You cannot change the location of the instance directory once it is created. The directory contains: v The database manager configuration file v The system database directory v The node directory v The node configuration file (db2nodes.cfg) 18 Administration Guide: Implementation
Any other files that contain debugging information, such as the exception or register dump or the call stack for the DB2 processes On UNIX operating systems, the instance directory is located in the INSTHOME/sq1]ib directory, where INSTHOME is the home directory of the instance owner On Windows operating systems, the instance directory is located in the /sqllib sub-directory, in the directory where DB2 was installed n a partitioned database system, the instance directory is shared between all database partition servers belonging to the instance. Therefore, the instance directory must be created on a network share drive that all machines in the instance can access As part of your installation procedure, you create an initial instance of DB2 called"DB2". On UNIX, the initial instance can be called anything you want within the naming rules guidelines. The instance name is used to set up the directory structure To support the immediate use of this instance, the following are set during installation: The environment variable db2iNstance is set to"DB2 The DB2 registry variable DB2INSTDEF is set to"DB2 On UNIX, the default can be called anything you want within the naming rules guidelines On Windows, the instance name is the same as the name of the service, so it should not conflict, You must have the correct authorization to create a These settings establish"DB2" as the default instance. You can change the instance that is used by default but first you have to create an additional instance Before using DB2, the database environment for each user must be updated so that it can access an instance and run the DB2 programs. This applies to all users(including administrative users On UNIX operating systems, sample script files are provided to help you set the database environment. The files are: db2profile for Bourne or Korn shell, and db2cshrc for C shell. These scripts are located in the sqllib subdirectory nder the home directory of the instance owner. The instance owner or any Chapter 1. Before Creating a Database 19
v Any other files that contain debugging information, such as the exception or register dump or the call stack for the DB2® processes. On UNIX® operating systems, the instance directory is located in the INSTHOME/sqllib directory, where INSTHOME is the home directory of the instance owner. On Windows® operating systems, the instance directory is located in the /sqllib sub-directory, in the directory where DB2 was installed. In a partitioned database system, the instance directory is shared between all database partition servers belonging to the instance. Therefore, the instance directory must be created on a network share drive that all machines in the instance can access. As part of your installation procedure, you create an initial instance of DB2 called “DB2”. On UNIX, the initial instance can be called anything you want within the naming rules guidelines. The instance name is used to set up the directory structure. To support the immediate use of this instance, the following are set during installation: v The environment variable DB2INSTANCE is set to “DB2”. v The DB2 registry variable DB2INSTDEF is set to “DB2”. On UNIX, the default can be called anything you want within the naming rules guidelines. On Windows, the instance name is the same as the name of the service, so it should not conflict. You must have the correct authorization to create a service. These settings establish “DB2” as the default instance. You can change the instance that is used by default, but first you have to create an additional instance. Before using DB2, the database environment for each user must be updated so that it can access an instance and run the DB2 programs. This applies to all users (including administrative users). On UNIX operating systems, sample script files are provided to help you set the database environment. The files are: db2profile for Bourne or Korn shell, and db2cshrc for C shell. These scripts are located in the sqllib subdirectory under the home directory of the instance owner. The instance owner or any Chapter 1. Before Creating a Database 19
user belonging to the instance's SYSADM group can customize the script for all users of an instance. Alternatively, the script can be copied and customized for each user The sample script contains statements to Update a user's PATH by adding the following directories to the existing search path: the bin, adm, and misc subdirectories under the sqllib subdirectory of the instance owners home directory Set the db2INStaNce environment variable to the instance name Related concepts Multiple instances on a UNIX operating system"on page 22 Multiple instances on a Windows operating system"on page 23 Related tasks Add an Instance"on page 27 UNIX Details When Creating Instances"on page 2. Windows Details When Creating Instances"on page 26 Setting the current instance"on page 28 Auto-starting instances"on page 29 Running multiple instances concurrently"on page 29 Listing instances" on page 28 Creating additional instances"on page 2 Setting the DB2 environment automatically on UNIX By default, the scripts that set up the database environment when you create an instance affect the user environment for the duration of the current session only. You can change the. profile file to enable it to run the db2profil script automatically when the user logs on using the Bourne or Korn shell For users of the C shell, you can change the. login file to enable it to run the db2shrc script file Procedure Add one of the following statements to the. profile or. login script files For users who share one version of the script, add INSTHOME/sqllib/db2profile (for Bourne or Korn shell) ource INSTHOME/sqllib/db2cshrc (for C shell) where INSTHOME is the home directory of the instance that you wish to use For users who have a customized version of the script in their home directory add: 20 Administration Guide: Implementation
user belonging to the instance’s SYSADM group can customize the script for all users of an instance. Alternatively, the script can be copied and customized for each user. The sample script contains statements to: v Update a user’s PATH by adding the following directories to the existing search path: the bin, adm, and misc subdirectories under the sqllib subdirectory of the instance owner’s home directory. v Set the DB2INSTANCE environment variable to the instance name. Related concepts: v “Multiple instances on a UNIX operating system” on page 22 v “Multiple instances on a Windows operating system” on page 23 Related tasks: v “Add an Instance” on page 27 v “UNIX Details When Creating Instances” on page 25 v “Windows Details When Creating Instances” on page 26 v “Setting the current instance” on page 28 v “Auto-starting instances” on page 29 v “Running multiple instances concurrently” on page 29 v “Listing instances” on page 28 v “Creating additional instances” on page 24 Setting the DB2 environment automatically on UNIX By default, the scripts that set up the database environment when you create an instance affect the user environment for the duration of the current session only. You can change the .profile file to enable it to run the db2profile script automatically when the user logs on using the Bourne or Korn shell. For users of the C shell, you can change the .login file to enable it to run the db2shrc script file. Procedure: Add one of the following statements to the .profile or .login script files: v For users who share one version of the script, add: . INSTHOME/sqllib/db2profile (for Bourne or Korn shell) source INSTHOME/sqllib/db2cshrc (for C shell) where INSTHOME is the home directory of the instance that you wish to use. v For users who have a customized version of the script in their home directory, add: 20 Administration Guide: Implementation
for Bourne or Korn shell) source USERHOME/db2cshrc (in C shell) where USERHOME is the home directory of the user Related tasks: Setting the DB2 Environment Manually on UNIX" on page 21 Setting the DB2 Environment Manually on UNIX Procedure To choose which instance you want to use, enter one of the following statements at a command prompt. The period(-)and the space are required For users who share one version of the script, add INSTHOME/sq1lib/db2profile (for Bourne or Korn shell) source INSTHOME/sqllib/db2cshrc (for C shell) where INSTHOME is the home directory of the instance that you wish to use For users who have a customized version of the script in their home directory, add: USERHOME/db2profile (for Bourne or Korn shell) source USERHOME/db2cshrc (in C shell) where USERHOME is the home directory of the user. If you want to work with more than one instance at the same time, run the script for each instance that you want to use in separate windows. For example, assume that you have two instances called test and prod, and their home directories are /u/test and /u/prod In window 1 In bourne or korn shell, enter: /u/test/sqllib/db2profil · In C shell, enter: source /u/test/sqllibdb2cshrc In bourne or korn shell. enter /u/prod/sqllib/db2profile · In c shell enter: source//prod/sqllib/db2cshrc Chapter 1. Before Creating a Database 21
. USERHOME/db2profile (for Bourne or Korn shell) source USERHOME/db2cshrc (in C shell) where USERHOME is the home directory of the user. Related tasks: v “Setting the DB2 Environment Manually on UNIX” on page 21 Setting the DB2 Environment Manually on UNIX Procedure: To choose which instance you want to use, enter one of the following statements at a command prompt. The period (.) and the space are required. v For users who share one version of the script, add: . INSTHOME/sqllib/db2profile (for Bourne or Korn shell) source INSTHOME/sqllib/db2cshrc (for C shell) where INSTHOME is the home directory of the instance that you wish to use. v For users who have a customized version of the script in their home directory, add: . USERHOME/db2profile (for Bourne or Korn shell) source USERHOME/db2cshrc (in C shell) where USERHOME is the home directory of the user. If you want to work with more than one instance at the same time, run the script for each instance that you want to use in separate windows. For example, assume that you have two instances called test and prod, and their home directories are /u/test and /u/prod. In window 1: v In Bourne or Korn shell, enter: . /u/test/sqllib/db2profile v In C shell, enter: source /u/test/sqllib/db2cshrc In window 2: v In Bourne or Korn shell, enter: . /u/prod/sqllib/db2profile v In C shell, enter: source /u/prod/sqllib/db2cshrc Chapter 1. Before Creating a Database 21