DB2常用实验环境搭建步骤
db2 创建实例

db2 创建实例DB2是一种功能强大的关系数据库管理系统,它可以用于创建和管理数据库实例。
在本文中,我们将探讨如何使用DB2来创建一个实例。
让我们来了解一下什么是数据库实例。
数据库实例是数据库管理系统在内存中加载和运行的一个副本。
它包含了数据库的所有元数据,例如表、索引、视图等。
通过创建一个实例,我们可以在同一台服务器上同时运行多个独立的数据库。
要创建一个DB2实例,我们需要按照以下步骤进行操作:1. 安装DB2软件:首先,我们需要从IBM官方网站上下载并安装DB2软件。
安装过程相对简单,只需按照安装向导的指示进行操作即可。
2. 创建实例用户:在安装完DB2软件后,我们需要创建一个用于运行实例的用户。
这个用户将拥有管理和操作数据库的权限。
可以使用操作系统的命令或DB2提供的图形界面工具来创建用户。
3. 配置实例环境:在创建用户后,我们需要为实例配置环境变量。
这些环境变量包括数据库的名称、位置、日志文件路径等。
可以使用DB2提供的命令行工具或编辑相应的配置文件来设置这些环境变量。
4. 创建数据库:一旦实例环境配置完成,我们可以使用DB2提供的命令或图形界面工具来创建一个新的数据库。
在创建数据库时,我们可以指定数据库的名称、大小、字符集等参数。
5. 启动实例:在创建数据库后,我们需要启动实例以使其运行。
可以使用DB2提供的命令或图形界面工具来启动实例。
一旦实例启动,我们就可以开始在数据库上执行各种操作,如创建表、插入数据、查询等。
6. 连接到数据库:最后,我们可以使用DB2提供的各种客户端工具来连接到数据库。
这些工具可以让我们通过图形界面或命令行与数据库进行交互。
需要提供正确的数据库名称、用户名和密码来连接到数据库。
通过以上步骤,我们可以成功地创建一个DB2实例并连接到数据库。
一旦连接成功,我们就可以开始使用DB2的强大功能来管理和操作数据库。
总结起来,创建DB2实例是一个相对简单的过程。
我们只需按照上述步骤进行操作,就能够成功地创建一个实例并连接到数据库。
db2安装及新建实例配置

DB2安装手册(Windows)、安装数据库运行setup.exeT宜u.■e安装产品/■^k・出-saWfFfi--:«?:r=*ep=nfiyt俣:士*mn通加=艮急■演而立・力・朔图1a.I J}«.同降言同"EffiEi^rai市如划CH归,s密国ms:苑国南症章&■石,"■—■■鼻..则利・MET*5?吗LMHU跖四|£.■工件4隙期片胸电工DB2仁LeiOiMXtUft-Kia^跑知的或I.孙:JH=GE■正任■#》[从f CR.if.€JHl日图OPU:i n山UL UhIXEWrfM?/弄■_匕口出主篁I快M.8用不01鲍氏毒企史胤tSLE斑3ms.珀螂司蜗射皿TF=大再好讣针苦H SHH*.SEH I聒?式.4Hr况壬*ME■EtE3・・£把口鼻麻二立工.S«M7制他的两足・烟砂西拜・嗟古开丁访即同"开元Effi冷E:呼闲.mftlSfffiBSSNUe.gWs晌月4■町『口出金IdVEja金航匕用产五口UH0M.**登.地0甘U30河^>3啪幽啊ffl;幅WSFIB1L号加件加皿JtaEEELHl,:I1HfcttjOJ二|W高辑里界日七江机口上)319上航工局11£+1工=于C€?K Mm,3iMmiKT用户KUlKHE工世:IL而口ED??—Q^_耐,箱E>BH亚<A-5C1O-.COlE.iCU JDDOS匚L」OLEEC HETPUP n PariU ftunr r EHn事昭咫1・q库丁口国E4M丽叫&»uin।Ki酬」盍汨总・I:C L P J rFimE・m8WiJD£MSE£j-ZfllW«¥::Hl»^lJMC..HET.PHPIDRltT^□0»ii4.Jddna faiX*ail皿知3015.阜联5ED:前1匚与《疾聚基*5hEF二羽弓叼东笳鼻IBMEUUMU-JkSfl-lhil:»r WtUM晶但蛆7DH下一步下一步点DB2空装-D02EnterpriseServerEdition-DB2COPY1软件许可协议请仔细阅读下列讦可证协议。
DB2 pureScale 实战

DB2 pureScale 实战简介:本文介绍了 DB2 pureScale 软件的安装配置方法及步骤、常见问题及解决方案,帮助读者快速有效地搭建 DB2 pureScale 环境;通过对客户实际生产中经常采用的 Websphere Application Server + DB2 方案、CICS + DB2 方案、多线程 DB2 CLI 应用程序 + DB2,着重介绍 DB2 pureScale 在这些典型应用场景中如何配置和优化,对于读者今后实战起到指导作用;通过客户实际生产系统等典型应用进行测试,验证 DB2 pureScale 的高可用性及负载均衡能力、高性能,以及高扩展性,增强读者对 DB2 pureScale 的信心。
)DB2 pureScale 软件安装配置及常见问题解决硬件环境要求DB2 pureScale 采用了和业界联机事务处理“黄金”标准的 DB2/zOS 相同的共享存储体系架构、集中式缓存和锁管理,硬件配置上要求能够通过 SAN 网络访问数据库共享磁盘,需要高性能、低延迟的 InfiniBand 交换机和板卡。
DB2 pureScale 目前支持的服务器包括 IBM Power 6-550 和 595,IBM Power7 全系列服务器。
由于 IBM Power6-570 服务器没有 GX+ 插槽,无法安装Infiniband 网卡,因此不被 DB2 pureScale 支持,DB2 pureScale 后续版本将提供对 IBM PC 服务器的支持。
DB2 pureScale 支持的存储为所有 GPFS 文件系统支持的存储,具体参见:/infocenter/clresctr/vxrx/index.jsp?topi c=/com.ibm.cluster.gpfs.doc/gpfs_faqs/gpfsclustersfaq.htmlDB2 pureScale 强烈推荐使用支持 SCSI-3 协议的存储,尽管 DB2 pureScale 也可以支持非 SCSI-3 协议的存储,但是发生故障时,IO 屏蔽的时间将大为延长,这将严重影响宕机时数据库受影响数据的恢复时间。
DB2 - 创建实例

InstName is the name of the instance.被创建的实例名。
在本实验中,创建的实例名为db2test,命令如下:
-d turn debug mode on.打开调试状态
-a AuthType is the authentication type (SERVER, CLIENT, DCS,
DCE, SERVER_ENCRYPT, DCS_ENCRYPT, or
DB2 - 创建实例(Instance)
创建DB2 实例(Instance)
[DB2安装路径]:本实验中DB2的安装路径为:/usr/lpp/db2_07_01
本实验将采用两种方法来建立实例,并将详细阐述两种建立方法的不同。
方法一:采用DB2SETUP
# mkdir db2test
2. 创建用户和组
创建用户,本实验中使用用户名:db2test
保持root身份登陆,使用命令:
# smitty user
进入smitty界面,创建db2test用户,注意以下细节:
new User name: db2test
The log file can be found in /tmp/db2setup.log.
DB2 Services Creation
DB2 Instance
DB2 Instance Creation SUCCESS
Create new entry in /etc/services SUCCESS
实例使用的端口名或端口号
DB2创建数据库和表空间

实验二创建数据库和表空间一.目的1.掌握建立数据库的操作。
2.掌握建立表空间的操作。
3.掌握对数据库进行编目的操作。
二.内容1.使用命令编辑器,建立一个数据库。
2.打开资源管理器,查看数据库在物理存储空间的结构。
3.使用控制中心,在默认实例中“配置参数” “管理”下查看DFTDBPATH 参数的值,说明此参数的值的含义。
包含用来在实例下创建数据库的缺省文件路径。
如果创建数据库时没有指定路径,则将在此参数指定的路径中创建该数据库。
4. 在命令编辑器中创建一个SMS管理的表空间,这个表空间由两个数据容器构成,每页的大小为4k。
指定一个数据容器使用16页后开始使用下一个数据容器。
5.在命令编辑器中创建一个DMS管理的表空间,这个表空间有两个数据容器构成,每页的大小为4k。
指定一个数据容器使用16页后开始使用下一个数据容器。
6.在命令编辑器中运行命令查看新建的数据库中表空间的信息以及每个表空间的容器信息。
list tablespaces7.通过“创建表空间向导”为新建数据库建立一个额外的SMS管理的表空间sms02,容器为c:\sms\sms02,并查看生成的SQL语句。
8.通过“创建表空间向导”为新建数据库建立一个额外的DMS管理的表空间dms02,容器为c:\dms\dms02,并查看生成的SQL语句。
9. 使用命令窗口,创建样本数据库sample00,并指出数据库被存储在了什么位置?10.在命令窗口,运行连接sample00样本数据库的命令,并指定连接数据库的用户名和密码。
11. 使用命令编辑器创建自动存储的数据库mydb1,并存放在 D: 驱动器上,指出数据库的存储路径是什么?数据库路径是什么?Mydb1存储路径 sql00001数据库路径12.使用命令编辑器创建数据库mydb2,指定存储路径为d:\test,数据库路径为D:\13.使用命令编辑器,建立一个支持XML数据类型的数据库。
14. 使用命令编辑器,建立与数据库mydb1的连接。
如何在Linux虚拟环境下搭建DB2数据库DPF

如何在Linux虚拟环境下搭建DB2数据库DPFDB2的分区架构一般适合于统计类和分析的应用,主要用来为大规模数据处理、高并发数据访问提供支持。
DPF是DB2的多分区数据库,那么DPF要怎么搭建呢?下面小编就给大家介绍下如何在Linux虚拟化环境搭建DB2数据库DPF,给不知道怎么搭建的朋友做个指导。
如何在Linux虚拟环境下搭建DB2数据库DPF一、创建用户和组1、使用root用户添加系统用户/usr/sbin/groupadd -g 1997 db2igrp#instance所在的group,加入这个group的所有用户都具有DBA权限/usr/sbin/groupadd -g 1998 db2fgrp#fenced用户所在的group/usr/sbin/useradd -u 1997 -g db2igrp -d /cbusdb/db2inst1 db2inst1#db2inst1用户/usr/sbin/useradd -u 1998 -g db2fgrp -d /cbusdb/db2fenc1 db2fenc1#db2fenc1用户/usr/sbin/groupadd db2fadmin/usr/sbin/useradd -g db2fadmin db2admin2、使用root用户添加数据库账号/opt/ibm/db2/V10.5/instance/db2icrt -s ese -u db2fenc1 db2inst1#在所有的机器上,使用root用户,建立db2 admin server:/opt/ibm/db2/V10.5/instance/dascrt -u db2admin#启动db2 admin server:db2admin start3、修改节点配置文件#vim /cbusdb/db2inst1/sqllib/db2nodes.cfg0 cbusdb01 01 cbusdb01 12 cbusdb02 03 cbusdb02 14、修改实例参数su - db2inst1db2iauto -on db2inst1db2set DB2_SKIPINSERTED=ondb2set DB2_USE_ALTERNATE_PAGE_CLEANING=ondb2set DB2_EVALUNCOMMITTED=ondb2set DB2_SKIPDELETED=ondb2set DB2COMM=TCPIPdb2set DB2FCMCOMM=TCPIP4db2set DB2RSHCMD=/bin/rsh#注意如果配置的ssh则此处需要修改成db2set DB2RSHCMD=/usr/bin/sshdb2set DB2CODEPAGE=1386db2set DB2TERRITORY=86db2set DB2_PARALLEL_IO=*5、配置服务端口DB2c_db2inst1 61000/tcpDB2_db2inst1 61001/tcpDB2_db2inst1_1 61002/tcpDB2_db2inst1_2 61003/tcpDB2_db2inst1_3 61004/tcpDB2_db2inst1_4 61005/tcpDB2_db2inst1_END 61008/tcp6、调整系统参数,设置dpf所需的资源/sbin/sysctl -w kernel.sem=“250 32000 32 1024”/sbin/sysctl -w kernel.msgmnb=16384/sbin/sysctl -w kernel.msgmni=1024/sbin/sysctl -w kernel.msgmax=8192/sbin/sysctl -w kernel.shmmni=4096/sbin/sysctl -w kernel.shmall=2097152/sbin/sysctl -w kernel.shmmax=10737418247、修改环境变量cat 。
DB2实验报告

吉林大学DB2实验报告班级:姓名:学号:□演示性实验□验证性实验操作性实验□综合性实验执行SQL语句结果如下:2. Verify the creation of your ARTISTS table and the table description.Important: Ensure the definition of your table is correct. It could cause unexpected failures in later labs if your definitionsare not done correctly.Show your work below by printing screen.3. You will create the remainder of the tables required usinga script file called crtables. For Windows, it is located in the C:\labfiles\cf23 directory.Examine the DB2 statements in the file and answer the following questions.In which table space will both the indexes and data for table STOCK be placed For CONCERTS For REORDER4. Execute the crtables script to create the tables. Show your work below by printing screen5. Verify that all tables (ALBUMS, STOCK, CONCERTS, and REORDER) were created successfully.Show your work below by printing screen.6. Information about each column in a table can be found by accessing the view.Enter an interactive SQL statement to select the columns TABNAME, COLNAME, and TYPENAME from for all tables with the TABSCHEMA of ‘student’, order the data by TABNAME and COLNO, and pipe the output to a file named .Show your sql statements and your work below by printing screen for the last step.7. Check your output against the file.Ensure that there are no differences between your output and the master output or the following labs may not work correctly!Show your work below by printing screen.8. Information about a table's definition to a table space can be found by accessing the view. Enter an SQL statement to select9. Check your output against the file.Ensure that there are no differences between your output and the master output, or the following labs may not work correctly!Show your work below by printing screen.10. Grant select privilege on tables that are owned by student to public by executing a script file, grants (an operating systemcommand file) for local administration.Show your work below by printing screen.Section 2 - Create Indexes1. Create an index called ITEM on the ITEMNO column in STOCK table.Show your work below by printing screen.2. Create a unique index called ITEMNO on the ITEMNO column in ALBUMS table.Show your work below by printing screen.3. Select the information from the catalog tables about your indexes. The columns you should select are the first 18 characters of TABNAME, UNIQUERULE, the first 18 characters of INDNAME, and the first 30 characters of COLNAMES from , where INDSCHEMA is student, order by TABNAME and INDNAME.If UNIQUERULE = "U", then only unique values are allowed.If UNIQUERULE = "D", then duplicate values are allowed.If UNIQUERULE = "P", then it is a Primary key.Show your work and your new indexes below by printing screen.4. Use the select you executed in the previous step and route the output to . Check your results against .Ensure that there are no differences between your output and the master output, or the following labs may not work correctly!Show your work below by printing screen.Section 3 - Create Views1. Create a view called music that will select title, classification, name from albums, artists where = .Show your work below by printing screen.2. Create another view called inventory by executing the script file, crview.Show your work below by printing screen.3. Information about views can be found in the and views. Tables and views for the current user can be shown with a LIST TABLES statement. A TYPE of V is a view.Issue one of the following statements and verify your views are listed.• LIST TABLES statement OR• Select columns TABSCHEMA, TABNAME, and TYPE from the view with a TABSCHEMA of student OR• Select columns VIEWSCHEMA, VIEWNAME from with DEFINER of student Show your work below by printing screen.Section 4 - Create Alias1. Create an alias called singers for the ARTISTS table, and an alias called emptystock for the REORDER table.Show your work below by printing screen.2. Information about aliases can be found in the view. Tables, views, and aliases for the current user can also be shown with the LIST TABLES statement. A TYPE of A is an alias. Issue one of the following statements and verify your aliases are listed.• LIST TABLES statement OR• Select columns TABNAME and TYPE from the view with a TABSCHEMA of student.Show your work below by printing screen.Section 5 - Add Referential Integrity1. Alter the ALBUMS table and define referential integrity relationships it has with other tables.• Add a primary key on the itemno column•Add a foreign key called fkartno on the artno column which references a primary key in the ARTISTS table• The delete rule between ARTISTS and ALBUMS should be delete cascade Show your work below by printing screen.2. Now alter the STOCK table to define its referential integrity relationships, by executing the script file, crri.Show your work below by printing screen.3. Information about referential integrity can be found by accessing the view. Table dependencies can also be accessed through the view. Enter an interactive SQL statement to select CONSTNAME, TABNAME, REFTABSCHEMA, REFTABNAME, DELETERULE from the view with a TABSCHEMA of student.Show your work below by printing screen.。
配置db2

db2 => catalog database demo as demo2 at node n1 authentication server
DB20000I CATALOG DATABASE命令成功完成。
DB21056W 只有在刷新目录高速缓存以后,目录更改才会生效。
db2 => terminate
successfully.
[db2inst2@localhost ~]$ db2 get dbm cfg | grep SVC
TCP/IP Service name (SVCENAME) = db2c_db2inst2
SSL service name (SSL_SVCENAME) =
ERROR: The length of the fenced user name inst2Fence is invalid. It mustnot be longer than 8.
我们再创建一个名字较短的用户,以满足要求:
[root@localhost instance]# ./db2icrt -a server -p 55555 -s ese -u Fence2 db2inst2
-u FencedID InstName
4、发现需要指定FencedID和InstName参数,而这两个参数,实际上就是要指定两个用户名,FencedID用户主要管理用户定义的函数(UDF)和受防护存储过程。而InstName是新实例的名称,也是我们新实例的管理员的用户名。下面我们,分别新建这两个用户:
DBI1070I Program db2icrt completed successfully.
6、切换用户登陆,查看下系统当前的默认实例:
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
提示:个人的笔记本电脑上可以安装 Windows 版本的 DB2。
如何在 AIX 上安装 DB2
选择 DB2 inamge(TSC DB2 实验环境上):路径/db2data/db2_image/
DB2 安装文件:v9.7fp8_aix64_server.tar 解压安装文件 /db2/db2inst/server/ 执行#./db2_install, 指定安装目录: /opt/IBM/db2/V9.7.8
指定安装版本:ESE
开始安装
. .
安装完毕
安装 DB2 软件 license 创建 DB2 实例
问题解决步骤: 检查 db2diag.log,没有发现有用的信息
Client side 5. NFS share 目录下创建.rhosts 文件
15. 修改归档方式
mkdir ʹp /NFS/db2home/dpfxiao/dpfxiao/NODE0000/SQL00001/SQLOGDIR/archivelog mkdir ʹp /NFS/db2home/dpfxiao/dpfxiao/NODE0001/SQL00001/SQLOGDIR/archivelog mkdir ʹp /NFS/db2home/dpfxiao/dpfxiao/NODE0002/SQL00001/SQLOGDIR/archivelog mkdir ʹp /NFS/db2home/dpfxiao/dpfxiao/NODE0003/SQL00001/SQLOGDIR/archivelog
protocols failed to start successfully. However, core database manager functionality started
successfully.
SQL1063N DB2START processing was successful.
问题解决步骤:
db2
update
db
cfg
for
sample
using
LOGARCHMETH1
'DISK:/NFS/db2home/dpfxiao/dpfxiao/NODE0000/SQL00001/SQLOGDIR/archivelog'
配置 DPF 过程中遇到的问题
连接数据库报错: db2 connect to sample SQL1116N A connection to or activation of database "SAMPLE" cannot be made because of BACKUP PENDING. SQLSTATE=57019 解决方法: db2_all "db2 backup database sample compress"
DB2 常用实验环境搭建步骤
DB2 常用实验环境搭建步骤 ...........................................................................................................1 DB2 标准环境搭建 ...................................................................................................................1 DB2 测试环境配置 ...........................................................................................................1 如何在 AIX 上安装 DB2....................................................................................................2 安装 DB2 软件 license......................................................................................................3 创建 DB2 实例 ..................................................................................................................3 创建数据库 ....................................................................................................................... 4 设置 DB2 client 远程连接数据库服务器 ................................................................................5 设置 DB2 client 远程连接数据库服务器 ........................................................................6 配置过程中遇到的问题 ................................................................................................... 9 如何建立 DPF 分区环境 ........................................................................................................11 建立 DPF 分区环境的步骤 ............................................................................................11 配置 DPF 过程中遇到的问题 ........................................................................................16 如何配置 DB2 HADR 环境......................................................................................................17 配置 DB2 HADR 步骤......................................................................................................17 HADR 测试 ......................................................................................................................20 HADR 接管方式: ..........................................................................................................21 使用 HADR 过程中应注意的问题 .................................................................................21
案例一:
在远程节点 xyzdb2 上重启 db2 服务发现错误:
[db2inst2@xyzdb2:/home/db2users/db2inst2/]#db2start
06/30/2014 02:17:49
0 0 SQL5043N Support for one or more communications
4. Stop and restart the instance to make the changes you made in the previous steps effective.
远程节点配置步骤: 提示 1: 如果远程节点还没有创建实例,执行 db2 命令会报错:
配置过程中遇到的问题
检查 db2diag.log
db2 update dbm config using SVCENAME db2testc
执行 db2stop,db2start
案例二: 在远程节点 xyzdb2 上远程连接 sample 数据库时,xyzdb2 节点 hang: #db2 connect to sample user db2inst using db2inst SQL30081N A communication error has been detected. Communication protocol being used: "TCP/IP". Communication API being used: "SOCKETS". Location where the error was detected: "10.20.30.111". Communication function detecting the error: "connect". Protocol specific error code(s): "79", "*", "*". SQLSTATE=08001
50003/tcp