1.1 安装DB2服务器 1.1.1 检查系统环境 文件系统/usr和/home DB2 V7.1产品总是被安装在/usr/lpp/db2_07_01目录下(/usr文件系统),而每个DB2实例和sample数据库都在管理用户的根目录下(/home文件系统)创建,所以,必须保证这两个文件系统上有足够的空闲存储空间。建议/usr文件系统至少有500M剩余空间;/home文件系统至少有100M剩余空间。使用命令df 查看文件系统/usr和/home的信息。 扩充文件系统/usr和/home # smitty chfs Change / Show Characteristics of a Journaled File System 选择要扩大的文件系统,如/home,回车后进入以下画面:
在“SIZE of file system (in 512-byte blocks)”处输入希望扩大到的空间容量,其它不变,回车即可。如/home文件系统需要扩大到200M,则通过计算得出: 200*1024*1024/512=409600 在“SIZE of file system (in 512-byte blocks)”处,输入“409600”即可。 页空间(paging space)应为内存的1.5~2倍。
1.1.2 安装CD-ROM文件系统将DB2 UDB V6.1 FOR AIX光盘放入光驱,如果CD-ROM文件系统已经存在,使用命令mount /dev/cd0安装CD-ROM文件系统;否则,应首先创建CDROM文件系统: (1) 创建一个目录来安装该CD-ROM # mkdir -p /cdrom cdrom表示CD-ROM安装目录 (2) 分配CD-ROM文件系统 # smitty crcdrfs 在“DEVICE name”处按F4选择“cd0”;“MOUNT POINT”处输入“/cdrom”;选择“Mount AUTOMATICALLY at system restart?”为“no”。创建成功后,执行# mount /dev/cd0 安装CD-ROM文件系统。
1.1.3 安装DB2软件的License Key DB2软件的License Key保存在光盘上db2/license/db2entr.lic文件中,一般为最后两行,将这两行追加到/usr/lib/netls/conf/nodelock文件中即可。使用命令: tail –4 /cdrom/db2/license/db2entr.lic >;>; /usr/lib/netls/conf/nodelock
1.1.4 安装DB2产品 # cd /cdrom # ./db2setup 进入DB2安装画面: +------------------------------- Install DB2 V7--------------------------------+ | | | Select the products you are licensed to install. Your Proof of | | Entitlement and License Information booklet identify the products for | | which you are licensed. | | | | To see the preselected components or customize the selection, select | | Customize for the product. | | [ ] DB2 Administration Client [ Customize... ] | | [*] DB2 UDB Enterprise Edition [ Customize... ] | | [ ] DB2 UDB Connect [ Customize... ] | | [*] DB2 Application Development Client [ Customize... ] | | To choose a language for the following components, select Customize for | | the product. | | DB2 Product Messages [ Customize... ] | | DB2 Product Library [ Customize... ] | | | | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ (图一)注:只需安装“DB2 UDB Enterprise Edition(DB2通用数据库企业版)”。和“DB2 Application Development Client”两项其他两项不需安装: DB2 Administration Client(DB2客户端管理) DB2 Software Developer's Kit(DB2软件开发工具包)
移到光标到”DB2 UDB Enterprise Edition”,按空格健选择,选中后前面应有一“*”号;移动光标到”Customize”,回车后进入以下画面:
+------------------ DB2 Universal Database Enterprise Edition -----------------+ | | | Required: DB2 Client | | DB2 Run-time Environment | | DB2 Engine | | DB2 Communication Support : | | TCP/IP IPX/SPX | | SNA DRDA AS | | DB2 Sample Database Source | | Administration Server | | DB2 Connect Support | | License Support | | Optional: [*] Java Support | | [*] Replication | | [ ] Control Center | | [ ] DB2 Control Server | | Code Page Conversion Support: | | [ ] Japanese [*] Simplified Chinese | | [ ] Korean [ ] Traditional Chinese | | | | [ Select All ] [ Deselect All ] [ Default ] | | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ (图二) 在Code Page Conversion Support:处选择Simplified Chinese(简体中文),然后选择OK,返回“图一”,选择“OK”,进入以下画面: +---------------------------- Create DB2 Services -----------------------------+ | | | Select the items you want to create, and select OK when finished. | | | | A DB2 Instance is an environment where you store data and run | | applications. An instance can contain multiple databases. | | | | [ ] Create a DB2 Instance. : Customize... : | | [*] Do not create a DB2 Instance. | | | | An Administration Server provides services to support client tools that | | automate the configuration of connections to DB2 databases. | | | | [ ] Create the Administration Server. : Customize... : | | [*] Do not create the Administration Server. | | | | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ (图三) 选择“Do not create a DB2 Instance”和“Do not create the Administration Server”,即不创建实例和管理服务器。选择“OK”进入以下画面: +-------------------------- Warning ----------------------------+ | | | DBI1755W The Administration Server is not created. | | | | Cause: You have not created a Administration Server. | | Without the Administration Server, you cannot provide | | services to support client tools that automate the | | configuration of connections to DB2 databases, and cannot | | administer DB2 from your server system or a remote client | | using the Control Center. | | | | Action: | | | | o Press OK to continue, or | | | | o Press Cancel to abort. | | | | [ OK ] [ Cancel ] | +---------------------------------------------------------------+ (图四) 选择“OK”后,进入以下画面:
+------------------------------- DB2 Installer --------------------------------+ | +-------------------------- Summary Report ----------------------------+ | | | [ More... ] | | | | Installation | | | | ------------ | | | | Product components to be installed: | | | | | | | | DB2 Client | | | | Open Database Connectivity (ODBC) | | | | DB2 Run-time Environment | | | | DB2 Engine | | | | DB2 Communication Support - TCP/IP | | | | Administration Server | | | | DB2 Connect Support | | | | DB2 Communication Support - SNA | | | | DB2 Communication Support - DRDA Application Server | | | | DB2 Communication Support - IPX/SPX | | | | [ More... ] | | | +----------------------------------------------------------------------+ | | [ Continue ] | +------------------------------------------------------------------------------+ (图五) 选择“Continue”后,进入以下画面: +--- Warning -------------------------------------+ | | | (X) This is your last chance to stop. | | | | Select OK to start, or Cancel to abort. | | | | [ OK ] [ Cancel ] | +-------------------------------------------------+ (图六) 选择“OK”后,开始安装DB2,安装完闭后,进入以下画面: +------------------------------- DB2 Installer --------------------------------+ | | | +--------------------------- Status Report ----------------------------+ | | | [ More... ] | | | | DB2 Communication Support - SNA SUCCESS | | | | DB2 Communication Support - DRDA Application Server SUCCESS | | | | DB2 Communication Support - IPX/SPX SUCCESS | | | | DB2 Sample Database Source SUCCESS | | | | Code Page Conversion Support - Simplified Chinese SUCCESS | | | | License Support for DB2 UDB Enterprise Edition SUCCESS | | | | | | | | DB2 Services Creation | | | | --------------------- | | | | | | | | DB2 Instance | | | | | | | | Group Name Cancel | | | | User Name Cancel | | | | Password Cancel | | | | [ More... ] | | | +----------------------------------------------------------------------+ | | [ View Log ] [ OK ] | +------------------------------------------------------------------------------+ (图七) 选择“OK”后,进入以下画面: +------------------------------- DB2 Installer --------------------------------+ | | | Select Install to select products and their components to install, or | | select Create to create the DB2 services. | | | | To select products and their components, select [ Install... ] | | Install. | | | | To create a DB2 Instance, or the Administration [ Create... ] | | Server, select Create. | | | | [ Close ] [ Help ] | +------------------------------------------------------------------------------+ (图八)选择“Close”,DB2安装完成。因db2 V7.1是最新版本,因此不需安装补丁盘 1.2 创建实例 # cd /usr/lpp/db2_07_01/install # ./db2setup 进入创建DB2实例画面: +------------------------------- DB2 Installer --------------------------------+ | | | Select Install to select products and their components to install, or | | select Create to create the DB2 services. | | | | To select products and their components, select [ Install... ] | | Install. | | | | To create a DB2 Instance, or the Administration [ Create... ] | | Server, select Create. | | | | [ Close ] [ Help ] | +------------------------------------------------------------------------------+ 移动光标到“Create”,回车后进入以下画面: +---------------------------- Create DB2 Services -----------------------------+ | | | Select the items you want to create, and select OK when finished. | | | | A DB2 Instance is an environment where you store data and run | | applications. An instance can contain multiple databases. | | | | [*] Create a DB2 Instance. : Customize... : | | [ ] Do not create a DB2 Instance. | | | | An Administration Server provides services to support client tools that | | automate the configuration of connections to DB2 databases. | | | | [ ] Create the Administration Server. : Customize... : | | [*] Do not create the Administration Server. | | | | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ 选择“Create a DB2 Instance”,并将光标移到“Customize”处,回车后进入以下画面: +---------------------------- Create DB2 Services -----------------------------+ | Select the items you want to create, and select OK when finished. | |+--- DB2 Instance -----------------------------------------------------------+| || || || Authentication: || || Enter User ID, Group ID, Home Directory and Password that will be || || used for the DB2 Instance. || || User Name [db2inst1] || || User ID [600 ] [ ] Use default UID || || Group Name [db2iadm1] || || Group ID [601 ] [ ] Use default GID || || Home Directory [/home/db2inst1 ] || || Password [****** ] || || Verify Password [****** ] || || || || Select Properties to view or change more options. [ Properties... ] || || Select Default to restore all default settings. [ Default ] || || || || [ OK ] [ Cancel ] [ Help ] || |+----------------------------------------------------------------------------+| | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ 在“User Name”、“Group Name”、“Home Directory”取默认值,不必修改;在“User ID”、“Group ID”处不要选择“Use default UID”,应输入规划的ID号。选择“OK”回车后进入以下画面: +---------------------------- Create DB2 Services -----------------------------+ | | | Select the items you want to create, and select OK when finished. | | +--- DB2 Instance Properties ----------------------------------------------+ | |+| |+| ||| Authentication Type: ||| ||| Select one of the following types of authentication for ||| ||| the DB2 Instance. ||| ||| (*) Server ||| ||| ( ) Client ||| ||| ( ) DCS ||| ||| ( ) DCE ||| ||| ( ) Server Encrypt ||| ||| ( ) DCS Encrypt ||| ||| ( ) DCE Server Encrypt ||| ||| ||| ||| Communication Protocols: ||| ||| Select protocols and then select Properties to modify ||| ||| the protocol values. ||| ||| [*] TCP/IP Detected [ Properties... ] ||| ||| : : IPX/SPX : Properties... : ||| ||| ||| ||| [ ] Auto start DB2 Instance at system boot. ||| ||| [*] Create a sample database for DB2 Instance. ||| |+| |+| | | [ OK ] [ Cancel ] [ Help ] | | | +--------------------------------------------------------------------------+ | | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ 选择TCP/IP会显示以下画面: +---------------------------- Create DB2 Services -----------------------------+ | | | Select the items you want to create, and select OK when finished. | | +--- DB2 Instance Properties ----------------------------------------------+ | |+| |+| ||| Authentication Type: ||| ||| Select one of the following types of authentication for ||| ||| the DB2 Instance. ||| ||| +--- TCP/IP ---------------------------------------------------------+ ||| ||| | | ||| ||| | Enter the Service Name and Port Number that will | ||| ||| | be used for TCP/IP connection. | ||| ||| | | ||| ||| | Service Name [db2cdb2inst1 ] | ||| ||| | Port Number [50000] | ||| ||| | Port Number (FCM) : : | ||| ||| | | ||| ||| | Select Default to restore all default settings. [ Default ] | ||| ||| | | ||| ||| | [ OK ] [ Cancel ] [ Help ] | ||| ||| +--------------------------------------------------------------------+ ||| ||| [ ] Auto start DB2 Instance at system boot. ||| ||| [*] Create a sample database for DB2 Instance. ||| |+| |+| | | [ OK ] [ Cancel ] [ Help ] | | | +--------------------------------------------------------------------------+ | | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ 取默认值即可,不需修改。 选择“Create a sample database for DB2 Instance”,建立样本数据库;不要选择“Auto start DB2 Instance at system boot”,即系统启动时,不自动启DB2实例,DB2实例的启动是由双机软件HACMP控制的。选择“OK”后进入以下画面: +---------------------------- Create DB2 Services -----------------------------+ | Select the items you want to create, and select OK when finished. | | | |+--- Fenced User ------------------------------------------------------------+| || || || Fenced user defined functions (UDFs) and stored procedures will || || execute under this user and group. || || || || Authentication: || || Enter User ID, Group ID, Home Directory and Password that will be || || used for the Fenced User. || || User Name [db2fenc1] || || User ID [600 ] [ ] Use default UID || || Group Name [db2fadm1] || || Group ID [601 ] [ ] Use default GID || || Home Directory [/home/db2fenc1 ] || || Password [****** ] || || Verify Password [****** ] || || || || Select Default to restore all default settings. [ Default ] || || || || [ OK ] [ Cancel ] [ Help ] || |+----------------------------------------------------------------------------+| | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ 在“User Name”、“Group Name”、“Home Directory”取默认值,不必修改;在“User ID”、“Group ID”处不要选择“Use default UID”,应输入规划的ID号。选择“OK”回车后进入以下画面: +---------------------------- Create DB2 Services -----------------------------+ | Select the items you want to create, and select OK when finished. | | | | A DB2 Instance is an environment where you store data and run | | applications. An instance can contain multiple databases. | | +--- Warning ------------------------------------------------------------+ | | | DBI1755W The Administration Server is not created. | | | | | | | | Explanation: You have not created a Administration Server. | | | | Without the Administration Server, you cannot provide services to | | | | support client tools that automate the configuration of | | | | connections to DB2 databases, and cannot administer DB2 from your | | | | server system or a remote client using the Control Center. | | | | | | | | User Response: | | | | o Press OK to continue, or | | | | o Press Cancel to go back. | | | | [ OK ] [ Cancel ] | | | +------------------------------------------------------------------------+ | | [ OK ] [ Cancel ] [ Help ] | +------------------------------------------------------------------------------+ 选择“OK”后,进入以下画面: +------------------------------- DB2 Installer --------------------------------+ | +-- Summary Report ----------------------------------------------------+ | | | DB2 Services Creation | | | | --------------------- | | | | Fenced User | | | | Create new group name: | | | | Group Name db2fadm1 | | | | Group ID 301 | | | | Create new user name: | | | | User Name db2fenc1 | | | | User ID 302 | | | | Home Directory /home/db2fenc1 | | | | | | | | DB2 Instance | | | | Create new group name: | | | | Group Name db2iadm1 | | | | Group ID 302 | | | | Create new user name: | | | | User Name db2inst1 | | | | [ More... ] | | | +----------------------------------------------------------------------+ | | [ Continue ] | +------------------------------------------------------------------------------+
选择“Continue” 进入以下画面: +------------------------------- DB2 Installer --------------------------------+ | +-- Summary Report ----------------------------------------------------+ | | | DB2 Services Creation | | | | --------------------- | | | | Fenced User | | | | Create new group name: | | | | Gro+--- Warning -------------------------------------+db2fadm1 | | | | Gro| | 301 | | | | Creat| (X) This is your last chance to stop. | | | | | Use| |db2fenc1 | | | | Use| Select OK to start, or Cancel to abort. | 302 | | | | Hom| |db2fenc1 | | | | | [ OK ] [ Cancel ] | | | | | DB2 Ins+-------------------------------------------------+ | | | | Create new group name: | | | | Group Name db2iadm1 | | | | Group ID 302 | | | | Create new user name: | | | | User Name db2inst1 | | | | [ More... ] | | | +----------------------------------------------------------------------+ | | [ Continue ] | +------------------------------------------------------------------------------+
选择“OK”后,开始安装,安装成功后提示以下画面: +------------------------------- DB2 Installer --------------------------------+ | +-- Summary Report ----------------------------------------------------+ | | | DB2 Services Creation | | | | --------------------- | | | | | | | | Fenced User | | | | Create new group name: | | | | Group Name db2fadm1 | | | | Group ID +--- Notice -----------------+ 301 | | | | Create new user | | | | | | User Name | Completed successfully. | db2fenc1 | | | | User ID | | 302 | | | | Home Directory| [ OK ] | /home/db2fenc1 | | | | +----------------------------+ | | | | DB2 Instance | | | | Create new group name: | | | | Group Name db2iadm1 | | | | Group ID 302 | | | | Create new user name: | | | | User Name db2inst1 | | | | [ More... ] | | | +----------------------------------------------------------------------+ | | [ Continue ] | +------------------------------------------------------------------------------+
选择“OK”后,进入以下画面: +------------------------------- DB2 Installer --------------------------------+ | +-- Status Report -----------------------------------------------------+ | | | The log file can be found in /tmp/db2setup.log. | | | | | | | | DB2 Services Creation | | | | --------------------- | | | | Fenced User | | | | Create new group name SUCCESS | | | | Create new user name SUCCESS | | | | Set password for new user SUCCESS | | | | | | | | DB2 Instance | | | | Create new group name SUCCESS | | | | Create new user name SUCCESS | | | | Set password for new user SUCCESS | | | | DB2 Instance Creation SUCCESS | | | | Create new entry in /etc/services SUCCESS | | | | Update DBM configuration file for TCP/IP SUCCESS | | | | [ More... ] | | | +----------------------------------------------------------------------+ | | [ View Log ] [ OK ] | +------------------------------------------------------------------------------+
选择“OK”后,进入以下画面: +------------------------------- DB2 Installer --------------------------------+ | Select Install to select products and their components to install, or | | select Create to create the DB2 services. | | | | +--- Warning ------------------------------------------------------------+ | | | | | | | DBI1755W The Administration Server is not created. | | | | | | | | Explanation: You have not created a Administration Server. | | | | Without the Administration Server, you cannot provide services to | | | | support client tools that automate the configuration of | | | | connections to DB2 databases, and cannot administer DB2 from your | | | | server system or a remote client using the Control Center. | | | | | | | | User Response: | | | | o Press OK to continue, or | | | | o Press Cancel to go back. | | | | | | | | [ OK ] [ Cancel ] | | | +------------------------------------------------------------------------+ | | [ Close ] [ Help ] | +------------------------------------------------------------------------------+
选择“OK”后,进入以下画面: +------------------------------- DB2 Installer --------------------------------+ | | | Select Install to select products and their components to install, or | | select Create to create the DB2 services. | | | | To select products and their components, select [ Install... ] | | Install. | | | | To create a DB2 Instance, or the Administration [ Create... ] | | Server, selec+--- Notice ---------------------------------+ | | | | | | | (?) Do you want to exit DB2 Installer? | | | | Select OK to proceed. | | | | | | | | [ OK ] [ Cancel ] | | | +--------------------------------------------+ | | [ Close ] [ Help ] | +------------------------------------------------------------------------------+
选择“OK”退出安装菜单。
1.3 编辑实例所有者主目录下.dtprofile文件将/home/db2inst1/.dtprofile文件中DTSOURCEPROFILE=TRUE一行中前面的注释号“#”去掉,使其生效即可。 1.4 验证安装 检查有关DB2实例的用户是否安装正确 DB2实例安装完成后,会在/home目录下建立两个用户db2inst1和db2fenc1(若安装了“管理服务器”,还应有用户db2as),样本数据库sample也建在/home/db2inst1下。应检查用户及用户组是否与规划的一致。 检查/etc/services文件,在文件尾应有以下两条记录: db2cdb2inst1 50000/tcp # Connection port for DB2 instance db2inst1 db2idb2inst1 50001/tcp # Interrupt port for DB2 instance db2inst1 启动DB2实例 # su – db2inst1 注册进入db2inst1用户 $ db2start 启动DB2实例,应该提示启动成功。 测试样本数据库 $ db2 connect to sample 连接sample数据库 $ db2 connect reset 断开数据库连接 删除样本数据库在验证安装后,可删除sample数据库以释放磁盘空间。 $ db2 drop db sample 停止DB2实例 $ db2stop 应提示关闭成功。