Linux安装DB2说明
Linux下DB2数据库安装教程

Linux下DB2数据库安装教程最近因为⼯作需要在学习DB2数据库,本教程讲解DB2数据库在inux下的安装步骤。
安装前请查看说明来增加了解,先弄明⽩改安装什么版本,这⾥我⽤的是最新的Express-C版本,这个版本是提供给个⼈学习⽤的版本。
管理客户端从v9.7版本之后就不再带有控制中⼼了,⽽是使⽤ Data Studio Client。
Linux版本:Linux版本下的DB2数据库采⽤的官⽅免费版本,操作系统⽤的CentOS6.2。
安装过程:1、下载:db2_v101_linuxia32_expc.tar.gz2、解压,解压完成后会在当前⽬录下有⼀个 ./expc ⽂件夹[root@localhost opt]# tar -zxvf db2_v101_linuxia32_expc.tar.gz3、进⼊这个⽬录[root@localhost opt]# cd expc/4、执⾏安装[root@localhost expc]# ./db2_install5、添加组和⽤户:组(⽤户名)db2iadm1(db2inst1)db2fadm1( db2fenc1)[root@localhost expc]# groupadd -g 2000 db2iadm1[root@localhost expc]# groupadd -g 2001 db2fadm1[root@localhost expc]# useradd -m -g db2iadm1 -d /home/db2inst1 db2inst1[root@localhost expc]# useradd -m -g db2fadm1 -d /home/db2fenc1 db2fenc1[root@localhost expc]# passwd db2inst1[root@localhost expc]# passwd db2fenc16、安装 license(产品许可证)PS:如果是ExpressC版本就不⽤做[root@localhost adm]# pwd/opt/ibm/db2/V10.1/adm[root@localhost adm]# chmod -R 775 *[db2inst1@localhost adm]$ ./db2licm -a /tmp/seagull/db2v10/license/db2ese_c.lic7、创建实例和样本数据库[root@localhost instance]# pwd/opt/ibm/db2/V10.1/instance[root@localhost instance]# chmod -R 775 *[root@localhost instance]# ./db2icrt -p 50000 -u db2fenc1 db2inst1[root@localhost instance]# su - db2inst1[db2inst1@localhost ~]$ db2samplCreating database "SAMPLE"...Connecting to database "SAMPLE"...Creating tables and data in schema "DB2INST1"...Creating tables with XML columns and XML data in schema "DB2INST1"...'db2sampl' processing complete.[db2inst1@localhost ~]$ db2startSQL1026N The database manager is already active.[db2inst1@localhost ~]$ db2 connect to sampleDatabase Connection InformationDatabase server = DB2/LINUX 10.1.2SQL authorization ID = DB2INST1Local database alias = SAMPLE[db2inst1@localhost ~]$ db2 "select * from staff"8、创建 das 管理服务器为了远程客户端能够⽤控制中⼼来控制数据库服务器,需要在数据库服务器上安装 das,当然,如果只是远程连接⽽不是远程管理,可以不⽤装,这⾥我安装了⼀下。
Linux使用命令行安装DB2【详解】

DB2 ESE V9.7文本方式安装主要流程:(1)解压安装包,检查安装先决条件(2)执行安装程序(3)注册license(Express-C版无需注册)(4)创建3个用户组和3个用户,分别是实例用户、受限用户、管理用户(5)创建一个管理服务器(6)创建一个实例(7)配置DB2访问协议(8)配置DB2实例默认端口号一、安装前准备工作1、将下载的安装文件上传到待安装的LINUX 机器,解压缩v9.7_linuxx64_server.tar.gz 文件到某个目录[root@redflag11012601 app]# ll v*gz-rw-r--r-- 1 root root 810576392 05-03 19:44 v9.7_linuxx64_server.tar.gz[root@redflag11012601 app]# tar xzf v9.7_linuxx64_server.tar.gz2、解压产生两个目录server和db2[root@redflag11012601 app]# cd server[root@redflag11012601 server]# ll总计 64drwxr-xr-x 6 bin bin 4096 2009-11-16 db2-r-xr-xr-x 1 bin bin 5340 2009-11-16 db2ckupgrade-r-xr-xr-x 1 bin bin 5293 2009-11-16 db2_deinstall-r-xr-xr-x 1 bin bin 5163 2009-11-16 db2_install-r-xr-xr-x 1 bin bin 5127 2009-11-16 db2ls-r-xr-xr-x 1 bin bin 5145 2009-11-16 db2prereqcheck-r-xr-xr-x 1 bin bin 5145 2009-11-16 db2setupdrwxr-xr-x 15 bin bin 4096 2009-11-16 doc-r-xr-xr-x 1 bin bin 5181 2009-11-16 installFixPackserver 的子目录有多个可执行的脚本,其中db2prereqcheck是先决条件检查,db2setup 是图形界面安装程序,db2_install是命令行方式安装。
如何在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 。
linux下命令行的方式DB2数据库安装和卸载

安装1.系统依赖检测执行./db2prereqcheck[root@localhost server]# ./db2prereqcheck提示信息:下载对应版本的so文件放在/usr/lib下,再执行,DB2系统依赖检测,正常2.安装1)命令行安装执行db2_install,出现以下界面选择ESE,是服务器版本,安装成功创建数据库,指定编码格式为GBK[db2inst1@localhost ~]$ db2 create db DBTE using codeset GBK territory CNConnect to db DBTE,报错,如下执行下列语句[db2inst1@localhost V9.7]$ db2 update db cfg for DBTE using UTIL_HEAP_SZ 5000 DATABASE_MEMORY 50000原因:应该是我的util_heap_sz参数不够大,之前设置为automatic 的话,应该是默认分配了512再连接成功,如下图常用操作命令db2 =>connect to sample ---连接到sample数据库db2 =>list tables ---查看库下面的所有表db2 => select * from staff wheredept=10 ---查询某张表dept等于10的所有记录db2 => quit ---退出db2DB20000I The QUIT command completed successfully.$ db2ilist; ---查看实例列表db2inst1$ db2 get instance ---查看当前所运行的实例Thecurrent database manager instance is: db2inst1卸载1.Remove DB[首先删除数据库](1)su - db2inst1(2)db2 list db directory(3)db2 drop db <db name>2.Remove Instance【删除实例】(1)su - root(2)cd <db2 dir>/instance(3)./db2ilist(4)./db2idrop -f <instance name>3.Remove das【删除das】(1)su - root(2)cd <db2 dir>/instance(3)./daslist(4)./dasdrop <das user>4.Uninstall【卸载】(1)su - root(2)cd <db2 dir>/install(3)./db2_deinstall -a5.Remove user ( db2inst1,db2fenc1,dasusr1)【删除用户】userdel -r <username>please lookinto the file /etc/passwd before and after you deleted users。
linux下安装DB2的详细步骤

linux下安装DB2的详细步骤安装前准备:DB2 10.1的版本需要在Linux5以上版本,核心要求2.6.16以上。
可以通过lsb_release –a和uname –a命令查看系统版本和核心版本。
/etc/redhat-release文件中描述了系统的版本信息。
第一步在IBM网站下载,下载db2数据包,目前我下载的是db2_v1012_linuxia32_expc_lite.tar.gz第二步把下载下来的包(名称有可能是:db2_v1012_linuxia32_expc_lite.tar.gz)通过FTP放进opt目录第三步用命令解压db2_v1012_linuxia32_expc_lite.tar.gz如下:#cd /opt#gunzip db2_v1012_linuxia32_expc_lite.tar.gz# tar -xvf db2_v1012_linuxia32_expc_lite.tar第四步解压以后会有目录名如:tar -xvf DB2_V81_PE_LNX_32_NLV,点击进去以后,可以看到有三个文件,其它一个是用指令(db2_install)安装,另一个是图片介面(db2setup)切换到/opt/devinst/db2_v101fp2/linuxia32/s121127/expc_lite/,用指令如下:#cd /opt/devinst/db2_v101fp2/linuxia32/s121127/expc_lite/#sh db2_install稍后会出现如果提示:DB2.ADMCL DB2 Administration Client for LINUX26DB2.ESE DB2 Enterprise Server Edition for LINUX26DB2.ADCL DB2 Application Development Client for LINUX26 然后进行选择,选择时一定要用大写如果选择:DB2.ESE这时它自己会执行所有文件,执行完以后在:/opt目录里面会出现:IBM表示安装已经完毕接下来,我们要创建实例和创建数据库第五步(注册license)要注册license不然到时没法创建数据库,license在哪里你要自己去找一下,一般情况会出现在这里:/home/db/db2/V10.1/adm/db2licm/opt/devinst/db2_v101fp2/linuxia32/s121127/expc_lite/db2/license/ db2expc_uw.lic然后在root用户下执行#/home/db/db2/V10.1/adm/db2licm –a/opt/devinst/db2_v101fp2/linuxia32/s121127/expc_lite/db2/license/db 2expc_uw.lic第六步创建用户组和用户# groupadd -g 901 db2grp# groupadd -g 902 db2fgrp# groupadd -g 903 db2agrp# useradd -g db2grp -u 801 -d /home/db2inst1 -m -s /bin/sh db2inst1# useradd -g db2fgrp -u 802 -d /home/db2fenc -m -s /bin/sh db2fenc# useradd -g db2agrp -u 803 -d /home/db2das -m -s /bin/sh db2das第七步修改密码# passwd db2inst1Changing password for db2inst1.New password:[db2inst1]Re-enter new password:[db2inst1]创建完成后,执行如下命令,检查用户组和用户是否创建成功。
Linux 下 DB2 的安装

Linux 下DB2 的安装DB2(7.1)在AIX上的安装DB2 7.1EE的安装步骤一,安装前的准备工作1,内存要求:db2要求的内存取决于服务器进程和客户端并发连接数,最小256MB。
2,硬盘空间free要大于300M(/usr),db2是安装在/usr/lpp/db2_07_01下;3,基本上不需要打什么补丁,但注意尽量打全,因为有可能会用到除tcpip之外的协议,如IPX / SPX,NetBIOS…;4,建db2的用户(3个,分别为Instance user(db2inst1),UDF user(db2fenc1),admin user(db2admin)),3个用户分别属于db2iadm1.db2fadm1.db2asgrp这3个组。
这步可以跳过,在db2安装过程中系统会自动建;二,安装DB21, 以root用户登录;2,插入光盘;3,建mount点,mkdir /cdrom;4,mount光盘,mount –rv cdrfs /dev/cd0 /cdrom注:弟4步可以用下面步骤代替smitty manfs选cdrom File System选Add a cdrom File Systems.Device Name处(用F4选cd0)Mount point处(键入/cdrom)这样建立了一个文件系统,以后mount光盘只要用mount /cdrom就可以了。
5,./db2setup开始安装db2可以用./db2setup –d这样会产生一个安装的log文件,/tmp/db2setup.trc6,选DB2 UDB Enterprise Edition7,选Create a DB2 Instance建instance会建用户,组,注意密码默认是ibmdb28,Create the Administration Server建db2管理员用户,组,密码同上9,安装结束三,确认安装1,以db2inst1登录;2,db2sampl,建sample数据库;3,db2start,启动数据库;4,db2 connect to sample,连接成功5,删掉sample数据库,db2 drop databaseDB2 UDB 7.1 Enterprise Extended Edition Install on Red Hat Linux 7.1The purpose of this document is to provide a step-by-step installation of DB2 UniversalDatabase 7.1 Enterprise Extended Edition (DB2 EEE) on Red Hat Linux 7.1. It does not coverall the possible installation methods or running environments. All steps should be performed asroot unless otherwise noted.Overview of Installation Steps:1. Install Red Hat 7.1 on servers2. Configure networking hardware3. Setup NFS filesystem4. Create users and groups5. Enable rsh6. Install and setup DB27. Configure multiple nodes8. Configure the Administration Server9. Configure the Kernel10. Create a database(Step 1) Install Red Hat 7.1Typical installs of Red Hat 7.1 do not include all the necessary packages to install and run DB2EEE. When installing Red Hat 7.1 choose the option not to install a firewall. The followingservices also need to be installed:✍ X - if you wish to run the DB2 Java Control Center✍ Xinetd - required for DB2 Communication✍ rsh - required for DB2 EEE only (ssh will not work)✍ pdksh - required for install✍ Nfs-utils - required for NFS mount(Step 2) Configure networking hardwareDB2 EEE systems require communication between partitions. The demands forinter-nodecommunication vary based upon implementation. It is recommended that inter-node communication be isolated to a network dedicated for this purpose. The following example setupsplits network activity between a public network and a private network for DB2 EEE by utilizingtwo network cards in each machine.Machine: DB2lab9Hostname: DB2lab9NIC 1 - IP address (public): 9.19.156.33- Subnet : 255.255.252.0NIC 2 - IP address (private): 10.10.10.9- Subnet: 255.255.255.0Machine: DB2lab10Hostname: DB2lab10NIC 1 - IP address (public): 9.19.156.34- Subnet: 255.255.252.0NIC 2 - IP address (private): 10.10.10.10- Subnet: 255.255.255.0(Step 3) Setup NFS file systemThe scalability of DB2 EEE is a result of maximizing the parallelism of hardware resources.There are a small number of configuration control files that all partitions in a DB2 system share.These files are made available by a NFS mounted file system. The steps for creating and testingthe NFS mount are:1. Create a directory /db2home on all the machines that will be in the cluster2. On the first machine in the cluster (the instance owner) prepare and mount the exported filesystemA. Create the /etc/exports file on DB2lab9B. Add the following entry /db2home db2lab*.local.domain(rw)C. On DB2lab9 restart the NFS service./etc/init.d/nfs restartD. Verify the export is working correctlyshowmount --exports3. On all other machines in the cluster mount the file systemA. Add the following entry to /etc/fstab ‘DB2lab9:/db2home /db2home nfs rw 0 0’B. Mount the exported file system on all the machines in the clustermount /db2homeC. Verify the mount by issuing the mount command with no options(Step 4) Create users and groupsThe DB2 setup program can create the necessary users and groups. The following are steps tocreate the required groups and users manually to ensure consistency across all machines.1. Create the necessary groups on all machinesgroupadd -g 550 db2iadmgroupadd -g 551 db2fadmgroupadd -g 552 db2as2. Create the necessary users on all machinesuseradd -u 550 -g 550 -d /db2home/db2inst1 db2inst1useradd -u 551 -g 551 -d /db2home/db2fenc1 db2fenc1useradd -u 552 -g 552 -d /db2home/db2as db2as3. Set passwords for users on all machinespasswd db2inst1passwd db2fenc1passwd db2asThe user db2inst1 will be the instance owner and administrator for DB2 EEE. Stored procedureswill run under the db2fenc1 ID.(Step 5) Setup rshDB2 EEE uses rsh to perform remote execution on machines in the cluster. There are twomethods for enabling rsh. The first method is to provide a security file .rhosts file in the instanceowner’s home directory. The second method is to provide a security file/etc/hosts.equiv for everymachine in the cluster. In either case the file/s list the users allowed to issue remote commandsand the machines where the remote commands may originate. User root is disabled from usingrsh in Red Hat Linux 7.1.Method One:1. Create the /db2home/db2inst1/.rhosts.equiv file2. Add the following entries to the .rhosts.equiv file:DB2lab9 db2inst1DB2lab10 db2inst13. Restart xinetd service on all machines/etc/init.d/xinetd restart4. Verify the rsh service is workingA. Login as user db2inst1B. Issue a remote command on each machine for example:rsh DB2lab10 ls /usrMethod Two:1. On every machine in the cluster create the /etc/hosts.equiv file2. Add the following entries to the hosts.equiv files:DB2lab9 db2inst1DB2lab10 db2inst13. Restart xinetd service on all machines/etc/init.d/xinetd restart4. Verify the rsh service is workingA. Login as user db2inst1B. Issue a remote command on each machine for example:rsh DB2lab10 ls /usr(Step 6) Install and Setup DB2 EEEThe install steps may depend on how you obtained DB2. If you downloaded the code you willneed to extract the files from the tar file before proceeding. If you obtained DB2 EEE on CD thiswill not be necessary. There are two scripts important to the setup and installation of DB2,db2_install and db2setup. The first, db2_install, will only install the DB2 libraries and can not beused to setup DB2 EEE or create db2 instances. The db2setup utility can be used for bothprocesses. This example will use both utilities to complete the installation. Complete thefollowing steps on each machine.1. Extract the DB2 RPMs (only required for downloaded TAR files)tar -xf db2eee linuxeee.english.tar2. Extract any fix pack appropriate for your version leveltar -xf FP3_U475391.tar3. Install the code on each serverdb2_install/FP3_U475391/installpatchDB2 will be installed into the following path /usr/IBMdb2/V7.1/. The db2setup script requires libncurses.so.4 to be viewed properly. This library is not installed during the default install of Red Hat 7.1. The alternative to installing these libraries is to create a symbolic link to libncurses.so.5 with the following command. However, you will need topay close attention when running db2setup. The screen may display characters that do notexist.ln -sf /usr/lib/libncurses.so.5 /usr/lib/libncurses.so.44. Begin the setup of DB2 on the first machine (db2lab9)/usr/IBMdb2/V7.1/install/db2setup5. Choose the option to create a DB2 instance (this will only be completed on one node)6. Provide the proper user and group information as created in step 4 and continue the setupdb2inst1 will be used for the DB2 Instancedb2fenc1 will be used for the Fenced User7. Verify the setup by stopping and starting the db2 instance (db2inst1)As user db2inst1 issue the db2start and db2stop(Step 7) Configure multiple nodesAfter you have configured and setup DB2 EEE you will need to create new partitions. The/db2home/db2inst1/sqllib/db2nodes.cfg specifies what partitions exist in the DB2 EEE system.To add partitions:1. Add an entry into the db2nodes.cfg for the new partition1 db2lab10 02. Update the services file for listening ports both for external communication and for FCMcommunication between nodes. You can copy the entries from the end of the/etc/servicesfile or simply copy the file from the instance owning machine.3. To use a specific network for FCM communication edit the/db2home/db2inst1/sqllib/db2nodes.cfg and specify what network FCM should flow over.0 db2lab9 0 10.10.10.91 db2lab10 0 10.10.10.104. Verify communication by stopping and starting the instance, db2start and db2stop (Step 8) Configure the Administration ServerThe Administration Server is used for administration of instances.1. Begin the setup of the Administration Server by executing the db2setup command /usr/IBMdb2/V7.1/install/db2setup2. Choose the option to create an instance3. Select the option to create the Administration Server4. Provide the proper user and group information as created in step 4 and continue the setupdb2as will be used for the Administration Server(Step 9) Configure the KernelTo increase performance and the number of simultaneous connections to DB2 EEE change ipckernel parameters.1. Configure the msgmni parametersysctl - w kernel.msgmni=1282. Configure the parameter to be applied at boot timeAppend the following line to /etc/sysctl.conf:kernel.msgmni=128(Step 10) Create a DatabaseBy default the create database command will create the initial database objects in the instanceowner’s home directory. This is not the desired location as the instance owner’s home directoryresides on the NFS mounted file system. To change this specify a location when using the createdatabase command. The initial database objects known as the system catalogs will only reside onthe first partition. Rows in user created tables will be striped across the partitions. The pathspecified on the create database command must exist on all the machines and the instance owner’sID must have read write access to the path. The best option is to give ownership of the path tothe instance owner’s ID.1. As root create a directory for database objects on db2lab9 and db2lab10mkdir /testdbdir2. Change ownership of this directory to the instance owner on db2lab9 and db2lab10 chown /testdbdir db2inst13. As db2inst1 create the test databasedb2 “create database test on /testdbdir”For setup instructions of the DB2 Control Center refer to the After Installing DB2 on Red Hatsection of the following HOWTO:/HOWTO/DB2-HOWTO/Additional thanks to:✍ Nancy Miller for reviewing this document and providing constructive insights. ✍ Dan Scott for his web resources unavailable anywhere else.Monty WrightDB2 SpecialistAdvanced Technical Supportmontywri@。
Linux系统环境下DB2服务器的安装

Linux系统环境下DB2服务器的安装与配置一、系统环境:Centos Linux 5.4 Enterprise Edition(默认已安装)二、服务器前期基本配置1.更改主机名为DB2servervi /etc/sysconfig/network#修改成如下配置NETWORKING=yesNETWORKING_IPV6=noHOSTNAME=DB2serverGATEWAY=192.168.1.1vi /etc/hosts添加如下一行:192.168.1.49 DB2server(注:这里服务器的ip为当前机器的ip地址)2.修改系统时间date -s 07/13/2013date -s 15:41:003.关闭selinuxvi /etc/selinux/config#修改如下行SELINUX=disabled4.设置eth0的IP地址为192.168.1.49/24vi /etc/sysconfig/network-scripts/ifcfg-eth0# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]DEVICE=eth0BOOTPROTO=staticBROADCAST=192.168.1.255HWADDR=00:0C:29:8B:14:B2IPADDR=192.168.1.49NETMASK=255.255.255.0NETWORK=192.168.1.0ONBOOT=yes5.设置DNS地址为192.168.1.1vi /etc/resolv.conf#添加如下一行nameserver 192.168.1.16.关闭不需要的服务注:在日常的服务器维护过程中,原则上只保留syslog,network,sshd,Crond 服务chkconfig list|grep 3:onchkconfig network onchkconfig syslog onchkconfig sshd onchkconfig crond on对于其他的服务,采用service XXX stopchkconfig XXX off即可。
在linux上部署安装db2

一、在linux(虚机)上部署DB2(8.2版本)(一)用命令行安装及配置db2数据库1.利用远程终端工具上传DB2_V82_ESE_LNX_32_NLV.tar到linux系统上。
如放置在/tmp/gxs目录中。
2.进入“/tmp/gxs”目录,执行tar命令解压db2的安装包3.解压后在gxs目录中的内容如下拷到license中,否则db2安装完后不能使用。
4.执行db2_install命令,进行db2数据库安装。
5.如下所示,输入DB2.ESE后,回车确定。
6.安装完毕后的页面如下所示。
DB2默认安装在/opt/IBM目录下。
7.创建用户id,如下所示。
可。
如下所示。
8.创建实例,首先我们使用以下命令创建管理服务器实例,切换到root用户,进入/opt/IBM/db2/V8.1/instance目录中。
执行:./dascrt -u dasusr1命令9.接着使用以下命令创建数据库实例db2inst1这个命令有一些可选的参数。
特别地,-a选项允许我们指定一个不同于缺省的“server”的认证机制。
10.创建共享库链接,进入/opt/ibm/db2/v8.1/cfg/目录中,如下所示11.设置db2实例环境变量。
用su命令切换到db2实例所用者用户终端12.执行db2start命令,验证db2是否成功安装。
13.设置服务端口,输入db2命令,进入db2命令行模式(c) Copyright IBM Corporation 1993,2002Command Line Processor for DB2 SDK 8.2.0Y ou can issue database manager commands and SQL statements from the command prompt. For example:db2 => connect to sampledb2 => bind sample.bndFor general help, type: ?.For command help, type: ? command, where command can bethe first few keywords of a database manager command. For example:? CA TALOG DA TABASE for help on the CA TALOG DA TABASE command? CA TALOG for help on all of the CA TALOG commands.To exit db2 interactive mode, type QUIT at the command prompt. Outside interactive mode, all commands must be prefixed with 'db2'.To list the current command option settings, type LIST COMMAND OPTIONS.For more detailed help, refer to the Online Reference Manual.db2 =>14.执行:update database manager configuration using svcename server1|50000其中:server1|50000两者选其一,server1|为服务名,50000为端口号15.执行get database manager configuration16.创建数据库:create database dbname如果此处失败,在命令行执行db2start,或者重新启动系统(reboot)。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Linux(RedHat Enterprise Linux 5.4)下的DB2安装__使用图形界面可以使用图形界面,也可以使用手工安装的方式。
我们先介绍最简单的安装方法。
1.从IBM网站下载DB2 9.7 express C版本:文件名db2exc_971_LNX_x86.tar.gz,。
2.在LINUX下解压缩及解包#gzip -d db2exc_971_LNX_x86.tar.gz#tar -xvf db2exc_971_LNX_x86.tar3.进入相关目录,运行安装文件#xhost +#cd expc#./db2setup先允许所有用户使用xwindows界面。
在当前目录中要找到db2setup文件,然后执行它。
如果权限不够,先运行chmod +x db2setup4.根据图形界面安装可以选择安装位置或内容等。
过程中需要对其中的三个DB2用户的名字和密码进行设置,并记录下来。
注意DB2没有自己独立的用户管理系统,因此这几个用户实际就是LINUX的用户。
最后完成安装。
5.验证安装成功。
[root@bogon expc]# su - db2inst1[db2inst1@bogon ~]$ db2 create database testDB20000I The CREATE DATABASE command completed successfully.[db2inst1@bogon ~]$其中db2inst1为安装过程中创建的三个用户之一,为实例的管理者用户。
创建数据库成功表明安装成功。
更多的初始配置见DB2手工安装。
########################################################DB2 for linux手动安装步骤第一步下载db2数据包当前最新版本为9.7,从IBM网站下载免费的Express C版本。
db2exc_971_LNX_x86.tar.gz及语言包db2exc_nlpack_971_LNX_x86.tar.gz(后者可选)。
第二步上传安装文件把下载下来的包ftp上传到待安装的LINUX机器上第三步解包db2exc_971_LNX_x86.tar.gz# gzip -d db2exc_971_LNX_x86.tar.gz# tar -xvf db2exc_971_LNX_x86.tar第四步安装解包以后会有目录名为expc,进入找到db2_install和db2setup文件,前者为手动安装,后者为图形界面安装。
#cd expc#./db2_install设定安装目录等以后,耐心等待安装任务完成。
默认安装路径是/opt/ibm/db2/V9.7,可检查之。
第五步注册license本安装无须这一步。
对于企业版等版本,需要注册license才能使用。
对于V8.1 ESE版,注册license的文件一般是:/opt/DB2_V81_PE_LNX_32_NLV/db2/license/db2ese.lic,否则需要自己找一下db2ese.lic,根据实际情况执行#/opt/IBM/db2/V8.1/adm/db2licm -a /opt/334_ESE_LNX26_32_NLV/db2/license/db2ese.lic若提示:DBI1402I License added successfully.DBI1426I This product is now licensed for use as specified inthe License Acceptance and License Informationdocuments pertaining to the licensed copy of thisproduct. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OFTHE TERMS OF THE IBM LICENSE ACCEPTANCE AND LICENSEINFORMATION DOCUMENTS, LOCATED IN THE FOLLOWINGDIRECTORY: /opt/IBM/db2/V8.1/license/zh_CN.utf8表明注册成功第六步创建DB2运行所需要的用户组和用户注意DB2并没有独立的用户管理系统,必须借用OS用户来提供安全性认证,所以这里需要创建LINUX用户和组。
# groupadd -g 901 db2grp# groupadd -g 902 db2fgrp# groupadd -g 903 db2agrp# useradd -g db2grp -u 801 -d /home/db2inst1 -m -s /bin/sh db2inst1# useradd -g db2fgrp -u 802 -d /home/db2fenc -m -s /bin/sh db2fenc# useradd -g db2agrp -u 803 -d /home/db2das -m -s /bin/sh db2das这里的默认用户名是:DAS用户 dasusr1 组名: dasadm1管理实例的用户 db2inst1 组名:db2iadm1受防护用户 db2fenc1 组名: db2fadm1但是DB2用户可以任意起名。
第七步添加密码# passwd db2inst1Changing password for db2inst1.New password:[输入新密码]Re-enter new password:[再次输入新密码]Password changed创建完成后,执行如下命令,检查用户组和用户是否创建成功。
# more /etc/group |grep db2# more /etc/passwd |grep db2如果结果中包含那三个用户和组,则创建成功。
正确的结果应该是:# more /etc/group |grep db2dialout:x:16:db2inst1,db2fenc,db2dasvideo:x:33:db2inst1,db2fenc,db2dasdb2grp:!:901:db2fgrp:!:902:db2agrp:!:903:# more /etc/passwd |grep db2db2inst1:x:801:901::/home/db2inst1:/bin/shdb2fenc:x:802:902::/home/db2fenc:/bin/shdb2das:x:803:903::/home/db2das:/bin/sh第八步创建实例。
b1. 进入/opt/ibm/db2/V9.7/instance目录# cd /opt/ibm/db2/V9.7/instance2. 执行以下命令# ./dascrt -u db2das# ./db2icrt -u db2inst1 db2inst1这里dascrt创建的是DB2 adminstration server,每台服务器只有一个这种server,为进行DB2管理(比如运行控制中心)所必须,同时指定其管理用户是db2das。
db2icrt创建的是实例,其名字一般和管理用户名一样,这里均为db2inst1。
3 启动DB2切换到db2das用户,执行db2admin启动DB2管理服务器。
$ db2admin start切换到db2inst1用户,执行db2start启动数据库实例。
$ db2start第九步配置DB21 设置DB2自启动。
使用root用户执行以下命令:# cd /opt/ibm/db2/V9.7/instance# ./db2iauto -on db2inst1设置对db2inst1在LINUX启动时自动启动。
2 配置网络切换到db2inst1用户。
# su - db2inst1修改DB2的服务端口为50000,这里默认端口就是50000。
$ db2 update dbm cfg using SVCENAME 50000DB20000I The UPDATE DATABASE MANAGER CONFIGURATION command completedsuccessfully.修改DB2连接方式为TCPIP,然后可通过JDBC、ODBC等访问本DB2服务器上的数据库,安装了DB2客户端的其它机器也可访问数据库。
$ db2set DB2COMM=TCPIP至此,安装过程结束。
第十步创建和访问数据库,安装验证1 启动与关闭数据库实例做任何事情之前,首先要启动数据库实例切换到db2inst1用户,执行db2start启动数据库实例。
$ db2startSQL1063N DB2START processing was successful.若需要,可运行下面的命令来关闭数据库实例首先在db2inst1用户下强制关闭实例上的所有应用程序。
$ db2 force applications all关闭数据库实例。
$ db2stopSQL1064N DB2STOP processing was successful.2 创建数据库$ su - db2ins1$ db2 create database test1DB20000I The CREATE DATABASE command completed successfully.数据库创建成功了。
3 远程访问数据库笔者是在VMWARE虚拟机上安装RHEL5.4和DB2的,在主机上也安装了DB2 ESE for windows V9.7,经实验这样配置后主机可以访问到虚拟机上的DB2数据库。
方法是在主机上运行db2cmd,然后运行:C:\Documents and Settings\Administrator>db2 catalog tcpip node bogon remote 192.168.211.132 server 50000DB20000I CATALOG TCPIP NODE 命令成功完成。
DB21056W 直到刷新目录高速缓存之后,目录更改才生效。
C:\Documents and Settings\Administrator>db2 catalog database test1 as test_1 atnode bogonDB20000I CATALOG DATABASE 命令成功完成。
DB21056W 直到刷新目录高速缓存之后,目录更改才生效。
C:\Documents and Settings\Administrator>db2? Copyright IBM Corporation 1993,2007DB2 客户机 9.7.0 的命令行处理器可从命令提示符处发出数据库管理器命令和 SQL 语句。