DB2数据库行学习之实例创建

创建实例

1、首先创建和实例名一样的用户及该用户所属的组

(注意实例名不能超过8个字符,实例名可以自定义)

groupadd db2icom

useradd -g db2icomm -m -d /home/db2icomm db2icomm

passwd db2icomm 

密码跟帐号一样

passwd db2fcomm 

2、/opt/ibm/db2/V10.5/instance/db2icrt -a server -u db2fcomm db2icomm 

可以通过db2_ps或ps -ef|grep -i INSTANCE查看DB2进程的状态

3、当配置DB2的运行环境:成功创建实例后,检查实例目录下的.profile是否调用db2profile

.profile中是否有:

# The following three lines have been added by IBM DB2 instance utilities.

if [ -f /home/db2icomm/sqllib/db2profile ]; then

    . /home/db2icomm/sqllib/db2profile

fi

4、db2icrt 创建的实例设置为手动启动

允许实例在每次系统重新启动后自动启动 

db2icomm@emal:~> db2iauto -on db2icomm

阻止实例在每次系统重新启动后自动启动

db2iauto -off db2icomm

5、启动实例

db2icomm@emal:~> db2start

09/10/2014 20:14:44     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.

停止实例

db2stop

6、查看当前在哪个实例下

db2icomm@emal:~/Desktop> echo $DB2INSTANCE

db2icomm

或者

db2icomm@emal:~/Desktop> db2 get instance

 The current database manager instance is:  db2icomm

7、为了对实例变量提供tcp/ip协议的支持,输入如下命令设置DB2COMM变量

db2set DB2COMM=TCPIP -i db2icomm

db2 get dbm cfg | grep SVCENAME 检查配置 SVCENAME 的值,如果 SVCENAME为空值,则需要用下面的步骤设定该值,如果是一个端口号 ( 端口号应小于 65536),则不用读取/etc/services文件中的端口定义,如果该值是一个字符串(如:db2c_db2inst1),则在实例启动时会自动读取/etc/services 中的该字符串对应的端口号来监听。

# db2  update database manager configuration using svcename db2c_db2inst1(或者为端口号如:50001) --我们也可以通过这种方式修改DB2监听的端口号.

 db2  update database manager configuration using svcename 50002

猜你喜欢

转载自blog.csdn.net/sunshine4214/article/details/88076498