Suse9上安装DB2数据库6.1.1安装DB2数据库步骤1解压缩安装包。在/opt/software目录下执行tar-xvfDB2V8.2Linux2.6.tar命令。解压缩后在/opt/software下生成334_ESE_LNX26_32_NLV目录。步骤2执行db2setup安装程序。在/opt/software/334_ESE_LNX26_32_NLV目录下执行./db2setup命令。安装程序进入“WelcometoDB2”界面,如图6-1所示。图6-1“WelcometoDB2”界面步骤3单击“InstallProducts”选项,系统进入“UniversalDatabase”界面。选中“DB2UDBEnterpriseServerEdition”单选按钮,如图6-2所示。图6-2UniversalDatabase步骤4单击“Next”,系统自动启动DB2安装向导。步骤5单击“Next”,选中“Accept”单选按钮,如图6-3所示。图6-3SoftwareLicenseAgreement步骤6单击“Next”,选中“Custom:400–980MB”单选按钮,如图6-4所示。图6-4Selecttheinstallationtype步骤7单击“Next”,选中“InstallDB2UDBEnterpriseServerEditiononthiscomputer”复选框,如图6-5所示。图6-5Selecttheinstallationaction步骤8单击“Next”,采用默认设置,如图6-6所示。图6-6Selectthefeaturestoinstall步骤9单击“Next”,选择系统所涉及到的语言,如图6-7所示。图6-7Languages在使用数据库的过程中涉及到的所有语言都需要选择。步骤10单击“Next”,采用默认设置,如图6-8所示。图6-8SpecifythelocationoftheDB2InformationCenter步骤11为DB2管理服务器设置用户信息。1.在“SpecifythelocationoftheDB2InformationCenter”界面中,单击“Next”,选中“Existinguser”单选按钮,如图6-9所示。图6-9SetuserInformationfortheDB2AdministrationServer2.单击“”,进入“Selectuser”界面,如图6-10所示。在“Primarygroupname”下拉列表中选择“dasadm1”用户组。在“Usersinselectedgroup”中选择“dasusr1”用户。图6-10Selectuser3.单击“OK”,进入“SetuserinformationfortheDB2AdministrationServer”界面。界面显示用户名,如图6-11所示。图6-11SetuserinformationfortheDB2AdministrationServer步骤12创建DB2实例。在“SetuserinformationfortheDB2AdministrationServer”界面中,单击“Next”,进入“SetupaDB2instance”界面。选中“CreateaDB2instance”单选按钮,如图6-12所示。图6-12SetupaDB2instance步骤13单击“Next”,进入“Selecthowtheinstancewillbeused”,选中“Single-partitioninstance”单选按钮,如图6-13所示。图6-13Selecthowtheinstancewillbeused步骤14为数据库拥有者设置信息。1.单击“Next”,进入“SetuserinformationfortheDB2instanceowner”界面,选中“Existinguser”单选按钮,如图6-14所示。图6-14Setuserinformationforthefenceduser2.单击“”,进入“Selectuser”界面。在“Primarygroupname”下拉列表中选择“db2grp1”用户组。在“Usersinselectedgroup”中选择“db2inst1”用户。3.单击“OK”,系统返回到“Setuserinformationforthefenceduser”界面,如图6-15所示。图6-15SetuserinformationfortheDB2instanceowner步骤15为受防护用户设置信息。1.单击“Next”,系统进入“Setuserinformationforthefenceduser”界面。选中“Existinguser”单选按钮,如图6-16所示。图6-16Setuserinformationforthefenceduser2.单击“”,进入“Selectuser”界面。在“Primarygroupname”下拉列表中选择“db2fgrp1”用户组。在“Usersinselectedgroup”中选择“db2fenc1”用户。3.单击“OK”,系统返回到“Setuserinformationforthefenceduser”界面,如图6-17所示。图6-17Setuserinformationforthefenceduser步骤16设置数据库TCP/IP的访问。单击“Next”,系统进入“ConfigureDB2instanceTCP/IPcommunication”界面,如图6-18所示。图6-18ConfigureDB2instanceTCP/IPcommunication步骤17单击“Next”,进入“Setinstanceproperties”界面,采用默认设置,如图6-19所示。图6-19Setinstanceproperties步骤18单击“Next”,选中“Usealocaldatabase”单选按钮,如图6-20所示。图6-20PreparetheDB2toolscatalog步骤19单击“Next”,保持缺省设置。步骤20单击“Next”,选中“Local–Createacontactlistonthissystem”单选按钮,如图6-21所示。图6-21Setuptheadministrationcontactlist步骤21单击“Next”,系统将弹出“Warning”对话框,如图6-22所示。图6-22Warning步骤22无需理会警告,单击“OK”,系统将进入“Specifyacontactforhealthmonitornotification”界面,保持默认值。步骤23单击“Next”,系统将进入“Startcopyingfiles”界面,确认设置信息。若信息有误,单击“Back”,进行相应的修改。若信息正确,单击“Finish”,系统开始复制文件,显示安装进度,如图6-23所示。图6-23InstallingDB2UDBEnterpriseServer步骤24将进入DB2安装完成界面,显示安装日志报告。选择“Statusreport”页签,从报告中可以看出安装的每一步成功或失败的信息。步骤25单击“Finish”,完成安装。----结束6.1.2更新DB2环境变量任务说明执行此任务完成DB2环境变量的修改,以保证数据库系统正常运行。操作指引操作步骤如下:步骤1以db2inst1用户登录主节点。步骤2创建.cshrc文件。在db2inst1用户目录/home/db2inst1下执行vi.cshrc命令。在文件中添加:source/home/db2inst1/sqllib/db2cshrc步骤3保存后退出。步骤4使环境变量生效。在/home/db2inst1目录下执行source.cshrc命令。步骤5以db2inst1用户登录主节点,检查环境变量是否生效。在/home/db2inst1目录下执行db2命令,结果如下。db2inst1@PISA02:~db2(c)CopyrightIBMCorporation1993,2002CommandLineProcessorforDB2SDK8.2.2YoucanissuedatabasemanagercommandsandSQLstatementsfromthecommandprompt.Forexample:db2=connecttosampledb2=bindsample.bndForgeneralhelp,type:?.Forcommandhelp,type:?command,wherecommandcanbethefirstfewkeywordsofadatabasemanagercommand.Forexample:CATALOGDATABASEforhelpontheCATALOGDATABASEcommandCATALOGforhelponalloftheCATALOGcommands.Toexitdb2interactivemode,typeQUITatthecommandprompt.Outsideinteractivemode,allcommandsmustbeprefixedwith'db2'.Tolistthecurrentcommandoptionsettings,typeLISTCOMMANDOPTIONS.Formoredetailedhelp,refertotheOnlineReferenceManual.db2=6.1.3验证DB2安装结果步骤1修改db2实例db2inst1用户目录下db2pd的属性。#cd~db2inst1/sqllib/adm#chowndb2inst1db2pd#chmodug+sdb2pd步骤2安装检验。1.切换到db2inst1用户。2.创建sample数据库。执行db2sampl命令。3.检查sample表创建是否成功。执行db2listdatabasedirectory命令。显示如下信息:Database1entry:Databasealias=SAMPLEDatabasename=SAMPLELocaldatabasedirectory=/home/db2inst1Databasereleaselevel=a.00Comment=Directoryentrytype=IndirectCatalogdatabasepartitionnumber=0Alternateserverhostname=Alternateserverportnumber=表明创建成功。4.启动DB2数据库。执行db2start命令。05/08/200723:15:5600SQL1063NDB2STARTprocessingwassuccessful.SQL1063NDB2STARTprocessingwassuccessful.5.连接sample数据库。执行db2connecttosample命令。DatabaseConnectionInformationDatabaseserver=DB2/LINUX8.2.3SQLauthorizationID=DB2INST1Localdatabasealias=SAMPLE6.执行查询操作。执行db2select*fromstaffwheredept=20命令。显示如下信息:IDNAMEDEPTJOBYEARSSALARYCOMM--------------------------------------------------10Sanders20Mgr718357.50-20Pernal20Sales818171.25612.4580James20Clerk-13504.60128.20190Sneider20Clerk814252.75126.504record(s)selected.7.断连sample数据库。执行db2connectreset命令。显示如下信