db2-v10.1配置安装

329711120 贡献于2016-10-12

作者 Administrator  创建于2016-10-12 06:39:00   修改者Administrator  修改于2016-10-12 06:39:00字数9377

文档摘要:
关键词:

db2 安装文档 1.上传介质并解压: [root@localhost ~]# mkdir -p /db2home/ibm/db2 [root@localhost ~]# cd /db2home/ibm/db2/ [root@localhost db2]#tar -zxvf db2_v101_linuxx64_expc.tar.gz 2.创建db2相关用户及组 [root@localhost ~]# groupadd -g 999 db2agrp [root@localhost ~]# groupadd -g 998 db2fgrp [root@localhost ~]# groupadd -g 997 db2grp [root@localhost ~]# useradd -u 600 -g db2agrp -m -d /home/db2inst1 db2inst1 [root@localhost ~]# useradd -u 601 -g db2fgrp -m -d /home/db2fenc1 db2fenc1 [root@localhost ~]# useradd -u 602 -g db2grp -m -d /home/dasusr1 db2dasusr1 [root@localhost ~]# passwd db2inst1 密码(123456) [root@localhost ~]# passwd db2fenc1 密码(123456) [root@localhost ~]# passwd db2dasusr1 密码(123456) 3. 安装db2 使用root用户,进入解压目录的server目录安装 [root@localhost ~]#cd /db2home/ibm/db2/expc/ (9.7的安装目录位置)cd /db2home/ibm/db2/server/) [root@localhost ~]# ./db2_install 之后10.1版本的直接输入“是”即可。默认安装位置/opt/ibm/db2/V10.1 之后会让你选择是否更换安装目录,这里默认安装目录是/opt/ibm/db2/V9.7 可不更改,就选择“否”,然后输入“ESE”这个表示安装企业版本 查看是否安装成功: [root@localhost ~]# cd /opt/ibm/db2/V10.1 4. 创建DAS [root@localhost ~]# cd /opt/ibm/db2/V10.1/instance/ [root@localhost instance]# ./dascrt -u db2dasusr1 若出现如下代码表示成功: SQL1092N "db2dasusr1" does not have the authority to perform the requested command or operation. DBI1070I Program dascrt completed successfully. 5. 创建实例db2inst1 [root@localhost ~]# cd /opt/ibm/db2/V10.1/instance/ [root@localhost instance]# ./db2icrt -u db2fenc1 db2inst1 若出现如下代码表示成功: DBI1070I Program db2icrt completed successfully. 6.启动db2 [root@localhost ~]# su - db2inst1 [db2inst1@localhost ~]$ db2start 若出现如下代码表示成功: SQL1063N DB2START processing was successful. 7.配置DB2实例的TCP/IP通信 [db2inst1@localhost ~]$ db2set -all 若出现如下代码表示成功: [g] DB2FCMCOMM=TCPIP6 [g] DB2SYSTEM=localhost.localdomain [g] DB2INSTDEF=db2inst1 [g] DB2ADMINSERVER=db2dasusr1 [db2inst1@localhost ~]$ db2set DB2COMM=tcpip [db2inst1@localhost ~]$ db2set -all 若出现如下代码表示成功: [i] DB2COMM=tcpip [g] DB2FCMCOMM=TCPIP6 [g] DB2SYSTEM=localhost.localdomain [g] DB2INSTDEF=db2inst1 [g] DB2ADMINSERVER=db2dasusr1 8. 更新服务器上services文件 [db2inst1@localhost ~]$ cat /etc/services |grep db2 若出现如下代码表示成功: ibm-db2 523/tcp # IBM-DB2 ibm-db2 523/udp # IBM-DB2 questdb2-lnchr 5677/tcp # Quest Central DB2 Launchr questdb2-lnchr 5677/udp # Quest Central DB2 Launchr qdb2service 45825/tcp # Qpuncture Data Access Service qdb2service 45825/udp # Qpuncture Data Access Service DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END 60003/tcp 9.更新服务器数据库管理文件 [db2inst1@localhost ~]$ db2 get dbm cfg |grep SVCENAME 若出现如下代码表示成功: TCP/IP Service name (SVCENAME) = SSL service name (SSL_SVCENAME) = [db2inst1@localhost ~]$ db2 update dbm cfg using SVCENAME 60000 若出现如下代码表示成功: DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completed successfully. [db2inst1@localhost ~]$ db2 get dbm cfg |grep SVCENAME 若出现如下代码表示成功: TCP/IP Service name (SVCENAME) = 60000 SSL service name (SSL_SVCENAME) = 10.验证通信端口状态 [db2inst1@localhost ~]$ db2start (大概需要一分钟左右的等待时间)若出现如下代码表示成功: 09/01/2016 12:59:29 0 0 SQL1063N DB2START processing was successful. SQL1063N DB2START processing was successful. [db2inst1@localhost ~]$ netstat -an |grep 60000 (查看是否已打开监听)若出现如下代码表示成功: tcp 0 0 :::60000 :::* LISTEN 11.查看实例信息 [root@localhost ~]# cd /opt/ibm/db2/V9.7/instance [root@localhost instance]# ./db2ilist 若出现如下代码表示成功: db2inst1 12.创建用户数据库: 生产系统为安全和性能考虑,一般将DB2实例目录、日志目录、归档日志目录、表空间目录区分开,此处可建立目录: [root@localhost instance]# mkdir /opt/ibm/skdata [root@localhost instance]# mkdir /opt/ibm/skdata/log [root@localhost instance]# mkdir /opt/ibm/skdata/arclog [root@localhost instance]# mkdir /opt/ibm/skdata/db [root@localhost instance]# cd /opt/ibm/skdata/ [root@localhost skdata]# ls arclog db log 创建skdata数据库: [root@localhost skdata]# chmod -R 777 /opt/ibm/skdata/db/ 给db文件777的权限 [root@localhost skdata]# ll 总用量 12 drwxr-xr-x. 2 root root 4096 9月 1 13:10 arclog drwxrwxrwx. 2 root root 4096 9月 1 13:10 db drwxr-xr-x. 2 root root 4096 9月 1 13:10 log [root@localhost skdata]# su - db2inst1 [db2inst1@localhost ~]$ db2 "CREATE DATABASE skdata on /opt/ibm/skdata/db USING CODESET GBK TERRITORY CN" 若出现如下代码表示成功: DB20000I The CREATE DATABASE command completed successfully. 13.创建缓冲池 [db2inst1@localhost ~]$ db2 connect to skdata 若出现如下代码表示成功: Database Connection Information Database server = DB2/LINUXX8664 9.7.6 SQL authorization ID = DB2INST1 Local database alias = SKDATA 如报一下错误。 [db2inst1@NISEC-0045 home]$ db2 connect to skdata SQL1116N A connection to or activation of database "SKDATA" cannot be made because of BACKUP PENDING. SQLSTATE=57019 需要对数据库做离线全库备份,使状态恢复正常 db2 backup db skdata to /db2home/db2backup 更改缓存池的大小: [db2inst1@localhost ~]$ db2 "ALTER BUFFERPOOL IBMDEFAULTBP SIZE 2000" 若出现如下代码表示成功: DB20000I The SQL command completed successfully. 创建2g大小的bufferpool 格式如下: CREATE BUFFERPOOL SIZE PAGESIZE 以下创建32K页面,2G大小的缓冲池 [db2inst1@localhost ~]$ db2 "CREATE BUFFERPOOL bp32k SIZE 65536 PAGESIZE 32K" 若出现如下代码表示成功: DB20000I The SQL command completed successfully. 更改Buffer pool大小命令 [db2inst1@localhost ~]$ db2 update db cfg for skdata using buffpage 20 若出现如下代码表示成功: DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. SQL1363W One or more of the parameters submitted for immediate modification were not changed dynamically. For these configuration parameters, the database must be shutdown and reactivated before the configuration parameter changes become effective. 查看缓冲池大小: [db2inst1@localhost ~]$ db2 "select * from SYSCAT.BUFFERPOOLS" [db2inst1@localhost ~]$ db2 " select bpname,npages,pagesize from syscat.bufferpools" 若出现如下代码表示查看成功: BPNAME NPAGES PAGESIZE ---------------------------------------------------------------------------------------------------------------------------- ----------- ----------- IBMDEFAULTBP 2000 4096 BP32K 2000 32768 2 record(s) selected. 14.更改数据库和实例的配置 [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOGPRIMARY 16" 若出现如下代码表示成功(successfully表示成功的意思) DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. 以下是表示: [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOGPRIMARY 16" 若出现如下代码表示成功了,但是一个或多个参数提交立即修改,没有动态改变。对于这些配置参数,数据库之前,必须关闭和重新激活配置参数变化成为有效的。 DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. SQL1363W One or more of the parameters submitted for immediate modification were not changed dynamically. For these configuration parameters, the database must be shutdown and reactivated before the configuration parameter changes become effective. [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOGSECOND 4" 若出现如下代码表示成功: DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOGFILSIZ 51200" 若出现如下代码表示成功:但是一个或多个参数提交立即修改,没有动态改变。对于这些配置参数,数据库之前,必须关闭和重新激活配置参数变化成为有效的。 DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. SQL1363W One or more of the parameters submitted for immediate modification were not changed dynamically. For these configuration parameters, the database must be shutdown and reactivated before the configuration parameter changes become effective. [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOCKLIST 204800" 若出现如下代码表示成功: DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. 不成功案例: [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOCKLIST 204800" 若出现如下代码表示不成功:报错表示数据库管理器不能接受新的请求,终止所有请求,或终止指定的请求,因为一个错误或被迫中断。 SQL1224N The database manager is not able to accept new requests, has terminated all requests in progress, or has terminated the specified request because of an error or a forced interrupt. SQLSTATE=55032 [db2inst1@localhost ~]$ db2 "update db cfg for skdata using MAXLOCKS 30" 若出现如下代码表示成功: DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. 不成功案例: [db2inst1@localhost ~]$ db2 "update db cfg for skdata using MAXLOCKS 30" 若出现如下代码表示不成功:报错提示:没有启动数据库管理器命令。 SQL1032N No start database manager command was issued. SQLSTATE=57019 [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOGBUFSZ 512" 若出现如下代码表示成功:但是数据库必须释放和激活在改变之前,一个或多个配置参数将是有效的。 DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. SQL1363W Database must be deactivated and reactivated before the changes to one or more of the configuration parameters will be effective. 不成功案例: [db2inst1@localhost ~]$ db2 "update db cfg for skdata using LOGBUFSZ 512" 若出现如下代码表示不成功:报错表示:没有启动数据库管理器命令。 SQL1032N No start database manager command was issued. SQLSTATE=57019 15.修改归档方式(可选项) [db2inst1@localhost ~]$ db2 update db cfg for skdata using LOGARCHMETH1 'disk:/opt/ibm/skdata/arclog' 若出现如下代码表示成功:但是数据库必须释放和激活在改变之前,一个或多个配置参数将是有效的。 DB20000I The UPDATE DATABASE CONFIGURATION command completed successfully. SQL1363W Database must be deactivated and reactivated before the changes to one or more of the configuration parameters will be effective. 不成功案例: [db2inst1@localhost ~]$ db2 update db cfg for skdata using LOGARCHMETH1 'disk:/opt/ibm/skdata/arclog' 若出现如下代码表示不成功:报错表示:没有启动数据库管理器命令。 SQL1032N No start database manager command was issued. SQLSTATE=57019 NEWLOGPATH参数 无需执行:[db2inst1@localhost ~]$ db2 update db cfg for skdata using NEWLOGPATH '/opt/ibm/skdata/log' 若出现如下代码不表示成功:报错表示:没有启动数据库管理器命令。 SQL1032N No start database manager command was issued. SQLSTATE=57019 16.创建表空间(一般使用32K页面的大) [db2inst1@localhost ~]$ db2 "CREATE LARGE TABLESPACE skfwq pagesize 32k MANAGED BY DATABASE USING (file '/home/db2inst1/skfwq.data' 1G) bufferpool bp32k" 若出现如下代码表示成功: DB20000I The SQL command completed successfully. 扩展表空间: [db2inst1@localhost ~]$ db2 "alter tablespace skfwq resize (file '/home/db2inst1/skfwq.data' 1G)" 若出现如下代码表示成功: DB20000I The SQL command completed successfully. 查看创建的表空间信息 [db2inst1@localhost ~]$ db2 list tablespaces show detail [db2inst1@localhost ~]$ db2 list tablespaces [db2inst1@localhost ~]$ db2pd -tablespaces -db skdata 17.创建应用用户: [root@localhost ~]# groupadd skdata [root@localhost ~]# useradd -g skdata skdata [root@localhost ~]# passwd skdata 18.授予用户skdata权限: [db2inst1@localhost ~]$ db2 GRANT DBADM,CREATETAB,BINDADD,CONNECT,CREATE_NOT_FENCED_ROUTINE,IMPLICIT_SCHEMA,LOAD,CREATE_EXTERNAL_ROUTINE,QUIESCE_CONNECT,SECADM ON DATABASE TO USER skdata 若出现如下代码表示成功: DB20000I The SQL command completed successfully. 19.使用新用户skdata连接数据库: -格式: db2 connect to 数据库名字 user 用户名 using 密码 [db2inst1@localhost ~]$ db2 connect to skdata user skdata using skdata 若出现如下代码表示成功: Database Connection Information Database server = DB2/LINUXX8664 10.1.0 SQL authorization ID = SKDATA Local database alias = SKDATA

下载文档到电脑,查找使用更方便

文档的实际排版效果,会与网站的显示效果略有不同!!

需要 10 金币 [ 分享文档获得金币 ] 1 人已下载

下载文档