暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

【DB2】ACTIVATE DATABASE详解

1395

The ACTIVATE DATABASE command activates the specified database and starts up all necessary database services so that the database is available for connection and use by any application.


Scope

This command activates the target database on all members in the instance. In a Db2® pureScale® environment, if the command was issued by a client using the TCP/IP protocol, this command activates only the members included in the member subset that is associated with the database alias. If one or more of these members encounters an error during activation, a warning is returned. The database remains activated for all members on which the command succeeds.


A database is activated either implicitly or explicitly. The activation of a database driven by a first user connection is known as implicit activation. Activation of a database that is based on issuing the activate database command is known as explicit activation.


Authorization

One of the following authorities:

SYSADM

SYSCTRL

SYSMAINT


Required connection

None


Command syntax

Command parameters

DATABASE | DB database-alias

    Specifies the alias of the database to be started.

USER username

    Specifies the user starting the database.

USING password

    Specifies the password for the user name.


Usage notes

Database administrators can use the ACTIVATE DATABASE command to start the selected databases. This eliminates any application time spent on database initialization. The ACTIVATE DATABASE command is the only way to explicitly activate a database.


In a Db2 pureScale environment, when the ACTIVATE DATABASE command is issued by a client using the TCP/IP protocol, the command is assigned to a member subset which includes a set of members in the instance. If the database alias used is not associated with any user defined member subset, the command is assigned to the default member subset which includes all members in the instance. Database administrators can use this functionality to activate a database on a subset of the members in the instance.


Databases initialized by the ACTIVATE DATABASE command can be shut down by using the DEACTIVATE DATABASE or db2stop command.


The application issuing the ACTIVATE DATABASE command cannot have an active database connection to any database.


If a database is started by issuing a CONNECT statement (or an implicit connect) and subsequently an ACTIVATE DATABASE command is issued for that same database, then the DEACTIVATE DATABASE command must be used to shut down that database. If the ACTIVATE DATABASE command was not used to start the database, the database will shut down when the last application disconnects. However, in an Db2 pureScale environment, an active database on a member can only be deactivated on that member by issuing a DEACTIVATE DATABASE command. 


In an Db2 pureScale environment, neither the ACTIVATE DATABASE command nor the CONNECT statement can be used to restart a database. In this case, the database is automatically restarted depending on the autorestart database configuration parameter. See the autorestart configuration parameter for database connection behavior when the target database is in an inconsistent state.


总结

1. 在Db2 pureScale集群环境下,一个member下手动激活某数据库,会自动激活所有member下的该数据库;

2. 应用第一次连库会默认隐式激活库,手动执行activate database命令是显式激活库;

3. 手动显式激活数据库,能够消除应用连库时初始化的时间,避免应用首次连库过慢;

4. 在数据库被隐式激活后,再次尝试执行activate database也是能够成功的,这样下次停库时需要执行deactivate database;

5. 如果没有使用activate database显式激活数据库,当最后一个应用连接断开时,数据库会自动shutdown,即去激活;

6. 在Db2 pureScale集群环境下,一个member只能手动去激活,即执行deactivate database,意思是当最后一个应用连接断开时,数据库也不会自动shutdown。

(实践证明并不是这样的,结论6存疑)




参考: https://www.ibm.com/docs/zh/db2/11.5?topic=commands-activate-database

最后修改时间:2022-09-05 12:10:17
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论