.162.64.78 ?OSS-ZYGL-294
# /opt/ibm/db2/V10.5/instance/db2icrt -a server -p 9999 -u db2fenc1 db2inst1
DBI1446I ?The db2icrt command is running.
DB2 installation is being initialized.
......
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.9284".
DBI1070I ?Program db2icrt completed successfully.
# /opt/ibm/db2/V10.5/instance/db2ilist
db2inst1
启动实例: ?--切换到db2inst1用户
配置环境变量 ?--root用户和db2inst1用户
# vi ~/.bash_profile
$ vi ~/.bash_profile
PATH=$PATH:$HOME/bin:/opt/ibm/db2/V10.5/bin
# source ~/.bash_profile
$ source ~/.bash_profile
$ db2start
01/23/2017 13:36:37 ? ? 0 ? 0 ? SQL1063N ?DB2START processing was successful.
SQL1063N ?DB2START processing was successful.
8.创建DB
$ db2 "create db RESDB on /oradata4 using codeset UTF-8 territory cn"
DB20000I ?The CREATE DATABASE command completed successfully.
批注:创建数据库时若为指定路径,将使用默认路径,数据库用户的家目录,如下查看:
$ db2 get dbm cfg | grep -i DFTDBPATH
?Default database path ? ? ? ? ? ? ? ? ? ? ? (DFTDBPATH) = /home/db2inst1
9.参数调整
$ db2 connect to resdb
$ db2iauto -on db2inst1 ? --设置数据库实例开机自启动
9.1参数调整
$ db2 update dbm cfg using SVCENAME 9999 DFT_MON_BUFPOOL on DFT_MON_UOW on NUM_POOLAGENTS 4100
DB20000I ?The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully.
SQL1362W ?One or more of the parameters submitted for immediate modification
were not changed dynamically. Client changes will not be effective until the
next time the application is started or the TERMINATE command has been issued.
Server changes will not be effective until the next DB2START command.
批注:需要重启数据库生效
9.2日志调整
--日志位置和大小调整
$ db2 update db cfg for RESDB using NEWLOGPATH /db2log
$ db2 update db cfg for RESDB using LOGARCHMETH1 disk:/db2arch
$ db2 update db cfg for RESDB using LOGFILSIZ 25600 LOGPRIMARY 13 LOGSECOND 12 ?CATALOGCACHE_SZ 2048 LOGBUFSZ 4096 UTIL_HEAP_SZ 10240 DB_MEM_THRESH 100 DLCHKTIME 5000 LOCKTIMEOUT 15
9.3其他参数调整
db2set DB2_PARALLEL_IO=*
db2set DB2_SKIPINSERTED=YES
db2set DB2_USE_ALTERNATE_PAGE_CLEANING=YES
db2set DB2_eva lUNCOMMITTED=YES
db2set DB2_ANTIJOIN=EXTEND
db2set DB2_SKIPDELETED=YES
db2set DB2CODEPAGE=1208
参数调整完毕,数据库重启:
$ db2stop
01/23/2017 13:48:24 ? ? 0 ? 0 ? SQL1025N ?The database manager was not stopped because databases are still active.
SQL1025N ?The database manager was not stopped because databases are still active.
$ db2 force application all
DB20000I ?The FORCE APPLICATION command completed successfully.
DB21024I ?This command is asynchronous and may not be effective immediately.
$ db2stop
01/23/2017 13:49:39 ? ? 0 ? 0 ? SQL1064N ?DB2STOP processing was successful.
SQL1064N ?DB2STOP processing was successful.
$ db2start
01/23/2017 13:50:13 ? ? 0 ? 0 ? SQL1063N ?DB2START processing was successful.
SQL1063N ?DB2START processing was successful.
此时需要调整/etc/security/limits.conf配置文件
db2list1 ?soft nofile 65536
db2inst1 ?hard nofile 65536
db2inst1 ?soft nproc ?65536
db2inst1 ?hard nproc ?65536
重新连接数据库:
$ db2 connect to resdb
SQL1116N ?A connection to or activation of database "RESDB" failed because the
database is in BACKUP PENDING state. ?SQLSTATE=57019
批注:若修改数据里LOGRETAIN参数,从循环日志模式改为归档模式,则会导致数据库BACKUP PENDING,如下处理
$ db2 update db cfg for resdb using LOGRETAIN RECOVERY ?
SQL1597N ?Configuring the DB2 environment failed because the specified DB2
configuration parameter is discontinued.
此时无法连接,需要对数据库做离线全备,使状态恢复正常,以便能够访问。
$ db2 backup db resdb to /dev/null
Backup successful. The timestamp for this backup image is :