Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Startup and shutdown of db2 database

2025-01-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Under a DB2 instance, you can create multiple database (how many database can be created under each instance, which can be viewed through DB2 GET DBM CFG. Once the database is established, it can be manipulated. However, before creating objects in the database or accessing objects (data) in the database, you must know how to start and stop the database.

This section briefly describes how db2 database starts and stops through command line.

Activate the database

If you use connect to database_name or implicit connections in the application before database is activated, the application will have to wait until the database manager starts the database to which you want to connect. Generally speaking, the first application will incur all the overhead of waiting for the database manager to perform database startup.

We can also use commands such as activate database database_name to start a specific database. This command eliminates the time spent waiting for database initialization when the first application connects. In general, DB2 DBA activates all necessary databases in advance.

Note: 1) if the application that issued the activate database command has established an active database connection with a database, an error message will be returned.

2) if the database that needs to be restarted (restart) accepts an activate database command, then the activate database command will work like a connect to or an implicit connection.

3) if the database is configured

Enabled automatic restart (AUTORESTART) = ON

Then the database will restart before the activate database command initializes it.

View the configuration parameters of the specified database

-- default

DB2 GET DB CFG FOR study

-split screen display

DB2 GET DB CFG FOR study | More

-- Save the display result in the study.txt file

DB2 GET DB CFG FOR study > study.txt

Here is an example. I created three database under the current DB2 instance, and I activated them one by one using the activate command

The D:DB2BIN > db2 db2start DB20000I DB2START command completed successfully. D:DB2BIN > number of entries in the db2 list database directory system database directory = 3 Database 1 entry: database alias = TEST database name = TEST local database directory = D:DB2test database distribution level = c.00 comment = test directory entry type = indirect catalog database partition number = 0 standby server hostname = standby server port number = database 2 entry: Database alias = BANK database name = BANK local database directory = D:db2bank database distribution level = c.00 comment = bank directory entry type = indirect directory database partition number = 0 standby server host name = standby server port number = database 3 entry: database alias = STUDY database name = STUDY local database directory = D:db2study database distribution level = c.00 comment = STUDY directory entry type = indirect directory database partition number = 0 alternate server hostname = standby server port number = D:DB2BIN > db2 list active databases SQL1611W Database system Monitor did not return any data. The D:DB2BIN > db2 activate database study DB20000I ACTIVATE DATABASE command completed successfully. D:DB2BIN > db2 list active databases active database name = STUDY currently connected application = 0 database path = D:db2studyDB2NODE0000SQL00001 D:DB2BIN > db2 activate database bank DB20000I ACTIVATE DATABASE command completed successfully. D:DB2BIN > db2 list active databases active database name = STUDY currently connected application = 0 database path = D:db2studyDB2NODE0000SQL00001 database name = BANK current connection The application = 0 database path = D:db2bankDB2NODE0000SQL00001 D:DB2BIN > db2 activate database test DB20000I ACTIVATE DATABASE command completed successfully. D:DB2BIN > db2 list active databases active database name = STUDY currently connected application = 0 database path = D:db2studyDB2NODE0000SQL00001 database name = BANK current connection Application = 0 database path = D:db2bankDB2NODE0000SQL00001 database name = TEST currently connected application = 0 database path = D:DB2testDB2NODE0000SQL00001 D:DB2BIN >

Stop the database

The database initialized by the activate database command can be closed by the deactivate database command or by terminating the database manager by the stop database manager (or db2stop) command.

If you initialize a database with the activate database command, the last application disconnected from the database will not shut down the database. You must use deactivate database. In this case, stop database manager (or db2stop) shuts down the database and terminates the instance.

If you use connect to or implicitly connect to start the database, and then another application issues the activate database command against the same database, then you must use the deactivate database command to shut down the database. If you don't start the database with activate database, the database will shut down when the last application disconnects from the database.

Example 1: database started by connect to

D:DB2BIN > db2 list active databases

The SQL1611W Database system Monitor did not return any data.

D:DB2BIN > db2 connect to study-connecting to the study database will automatically activate the study database

Database connection information

Database server = DB2/NT 9.5.0

SQL authorization ID = ZHANGRP

Local database alias = STUDY

D:DB2BIN > db2 list active databases

Active database

Database name = STUDY

Currently connected application = 1

Database path = D:db2studyDB2NODE0000SQL00001

Description: the database is activated and an application is connected (just the connect to study operation above)

D:DB2BIN > db2 connect reset-disconnect

The DB20000I SQL command completed successfully.

D:DB2BIN >

D:DB2BIN > db2 list active databases

The SQL1611W Database system Monitor did not return any data.

D:DB2BIN >

Note: it can be found that after the above connection is disconnected, the database study stops automatically (because the study database is activated by connect to)

Example 2: database started by activate database

D:DB2BIN > db2 list active databases-the database SQL1611W Database system Monitor, which was not started at this time, did not return any data. D:DB2BIN > db2 activate database study-- the DB20000I ACTIVATE DATABASE command to activate the study database with activate database completed successfully. D:DB2BIN > db2 list active databases-you can see that the study data has been activated But there is no application connection to the active database name = STUDY the currently connected application = 0 database path = D:db2studyDB2NODE0000SQL00001 D:DB2BIN > db2 connect to study-initiate a connection To study database connection information database server = DB2/NT 9.5.0 SQL authorization ID = ZHANGRP local database alias = STUDY D:DB2BIN > db2 list active databases-- take a look at the active database again Found an application on the study database connected to the active database name = STUDY the currently connected application = 1 database path = D:db2studyDB2NODE0000SQL00001 D:DB2BIN > db2 connect reset-close the connection See if the database automatically shuts down the DB20000I SQL command to complete successfully. D:DB2BIN > db2 list active databases-the database is still started Although there is no connection to the active database name = STUDY the currently connected application = 0 database path = D:db2studyDB2NODE0000SQL00001 D:DB2BIN > db2 deactivate database study-the DB20000I DEACTIVATE DATABASE command to shut down the database using the deactivate database command completed successfully. D:DB2BIN > D:DB2BIN > db2 list active databases SQL1611W Database system Monitor did not return any data. D:DB2BIN >

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report