Linux虚拟环境怎么搭建DB2数据库DPF

Linux虚拟环境怎么搭建DB2数据库DPF,第1张

一、创建用户和组

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 db2admin

2、使用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 start

3、修改节点配置文件

#vim /cbusdb/db2inst1/sqllib/db2nodes.cfg0 cbusdb01 0

1 cbusdb01 1

2 cbusdb02 0

3 cbusdb02 1

4、修改实例参数

su - db2inst1

db2iauto -on db2inst1

db2set DB2_SKIPINSERTED=on

db2set DB2_USE_ALTERNATE_PAGE_CLEANING=ondb2set DB2_EVALUNCOMMITTED=on

db2set DB2_SKIPDELETED=on

db2set DB2COMM=TCPIP

db2set DB2FCMCOMM=TCPIP4

db2set DB2RSHCMD=/bin/rsh

#注意如果配置的ssh则此处需要修改成

db2set DB2RSHCMD=/usr/bin/ssh

db2set DB2CODEPAGE=1386

db2set DB2TERRITORY=86

db2set DB2_PARALLEL_IO=*

5、配置服务端口

DB2c_db2inst1 61000/tcp

DB2_db2inst1 61001/tcp

DB2_db2inst1_1 61002/tcp

DB2_db2inst1_2 61003/tcp

DB2_db2inst1_3 61004/tcp

DB2_db2inst1_4 61005/tcp

DB2_db2inst1_END 61008/tcp

6、调整系统参数,设置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=1073741824

7、修改环境变量

cat 。/sqllib/db2profile 》.profile

vi .bash_profile #添加如下信息:

/cbusdb/db2inst1/sqllib/db2profile

二、配置主机名

分别在两台主机上修改如下文件:

#vi /etc/sysconfig/network

#-------------------------

#NETWORKING=yes

#HOSTNAME=cbusdb01

#-------------------------

#vi /etc/hosts

#-------------------------

#127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 cbusdb01#::1 localhost localhost.localdomain localhost6 localhost6.localdomain6#192.168.1.122 cbusdb01

#192.168.1.123 cbusdb02

#-------------------------

三、配置rsh

rsh是远程运行shell的服务.db2使用rsh服务运行启动和停止数据库服务器的命令,以及大部分管理命令。

1、安装rsh

#yum install rsh*

2、配置rsh的安全文件

#vi /etc/securetty

#add the content

#------------------

#rsh

#rlogin

#rexec

#------------------

3、修改rsh的配置参数/etc/xinetd.d/rsh ##在生产环境建议配置ssh免密登录

#vi /etc/xinetd.d/rsh

service shell

{

socket_type = stream

wait = no

user = root

log_on_success += USERID

log_on_failure += USERID

server = /usr/sbin/in.rshd

disable = no

}

4、修改rsh的配置文件rlogin

#vi /etc/xinetd.d/rlogin

service login

{

disable = no

socket_type = stream

wait = no

user = root

log_on_success += USERID

log_on_failure += USERID

server = /usr/sbin/in.rlogind

}

4、免密登陆,实例用户db2inst1的家目录中创建.rhosts文件

cat $HOME/.rhosts

cbusdb01 db2inst1

cbusdb02 db2inst1

5、CentOS7.0需要单独下载xinetd

yum install xinetd #低于此版本可不下载

6、重启rsh服务

service xinetd restart

7、验证rsh服务

rsh cbusdb01 date

rsh cbusdb02 date

#db2_all echo hi 没有返回

yum install ksh

四、配置时钟服务器

1、安装ntp服务器

#yum install ntp*

# ntpdate -u 202.112.10.36

#ntpdate cn.pool.ntp.org

#service ntpd start

#chkconfig ntpd on

2、修改ntp配置

#允许内网其他机器同步时间

restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

#互联网时间服务器

server 210.72.145.44 perfer # 中国国家受时中心server 202.112.10.36

# 1.cn.pool.ntp.orgserver 59.124.196.83

# 0.asia.pool.ntp.org#允许上层时间服务器主动修改本机时间

restrict 210.72.145.44 nomodify notrap noquery

restrict 202.112.10.36 nomodify notrap noquery

restrict 59.124.196.83 nomodify notrap noquery

#外部时间服务器不可用时,以本地时间作为时间服务

server 127.0.0.1

fudge 127.0.0.1 stratum 10

3、修改时区

cp -f /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

clock -w

4、在节点2上配置时钟服务器

*/5 * * * * /usr/sbin/ntpdate cbusdb01

五、配置nfs服务

1、yum install nfs*

# yum install portmap rpcbind #安装nfs客户端

2、配置需要共享的资源

#vi /etc/exports

/cbusdb *(rw,sync,no_root_squash)

/cbusdblog *(rw,sync)

3、启动nfs server

service rpcbind start

service nfs start

service nfslock restart

4、导出资源

exportfs -rv

5、显示NFS Server上所有的共享卷

showmount -e

6、在客户端挂载共享目录

#mount 192.168.1.122:/cbusdb /cbusdb

#vi /etc/fstab

cbusdb01:/cbusdb /cbusdb nfs rw,timeo=300,retrans=5,hard,intr,bg,nolock,suid

六、关闭selinux

vim /etc/sysconfig/selinux

#SELINUX=disabled

七、测试、创建数据库

1、启动数据库

#db2start

2、创建数据库

#db2 “create db cbusdb on /cbusdblog using codeset gbk territory cn”

你用来执行建库命令的用户是否具有你提到的/boot目录的相应权限?缺省的db2inst1用户只具有它用户home目录下面的权限。如果不加on参数,库都是建在这个目录下的,所以权限不会出问题。但如果你制定了on参数,那目标路径必须开权限。grant一下吧。

DB2数据库命令简介 1.启动数据库 DB2start 2.停止数据库 DB2stop DB2数据库在linux相关指令之3.连接数据库 DB2 connect to o_yd user DB2 using pwd 4.读数据库管理程序配置 DB2 get dbm cfg 5.写数据库管理程序配置 DB2 update dbm cfg using 参数名 参数值 6.读数据库的配置 DB2 connect to o_yd user DB2 using pwd DB2 get db cfg for o_yd 7.写数据库的配置 DB2 connect to o_yd user DB2 using pwd DB2 update db cfg for o_yd using 参数名 参数值 8.关闭所有应用连接 DB2 force application all DB2 force application ID1,ID2,,,Idn MODE ASYNC (DB2 list application for db o_yd show detail) 9.备份数据库 DB2 force application all DB2 backup db o_yd to d: (DB2 initialize tape on \.tape0) (DB2 rewind tape on \.tape0) DB2 backup db o_yd to \.tape0 10.恢复数据库 DB2 restore db o_yd from d: to d: DB2 restore db o_yd from \.tape0 to d: DB2数据库在linux相关指令之11.绑定存储过程 DB2 connect to o_yd user DB2 using pwd DB2 bind c:dfplus.bnd 拷贝存储过程到服务器上的C:sqllibfunction目录中 12.整理表 DB2 connect to o_yd user DB2 using pwd DB2 reorg table ydd DB2 runstats on table ydd with distribution and indexes all 13.导出表数据 DB2 export to c:dftz.txt of del select * from dftz DB2 export to c:dftz.ixf of ixf select * from dftz 14.导入表数据 import from c:123.txt of del insert into ylbx.czyxx DB2 import to c:dftz.txt of del commitcount 5000 messages c:dftz.msg insert into dftz DB2 import to c:dftz.ixf of ixf commitcount 5000 messages c:dftz.msg insert into dftz DB2 import to c:dftz.ixf of ixf commitcount 5000 insert into dftz DB2 import to c:dftz.ixf of ixf commitcount 5000 insert_update into dftz DB2 import to c:dftz.ixf of ixf commitcount 5000 replace into dftz DB2 import to c:dftz.ixf of ixf commitcount 5000 create into dftz (仅IXF) DB2 import to c:dftz.ixf of ixf commitcount 5000 replace_create into dftz (仅IXF) 15.执行一个批处理文件 DB2 -tf 批处理文件名 (文件中每一条命令用 ;结束) 16.自动生成批处理文件 建文本文件:temp.sql select 'runstats on table DB2.' || tabname || ' with distribution and detailed indexes all' from syscat.tables where tabschema='DB2' and type='T'DB2 -tf temp.sql>runstats.sql 17.自动生成建表(视图)语句 在服务器上:C:sqllibmisc目录中 DB2 connect to o_yd user DB2 using pwd DB2look -d o_yd -u DB2 -e -p -c c:o_yd.txt DB2数据库在linux相关指令之18.其他命令 grant dbadm on database to user bb 19select * from czyxx fetch first 1 rows only 20DB2look -d ylbx -u DB2admin -w -asd -a -e -o a.txt21. 显示当前用户所有表 list tables 22.列出所有的系统表 list tables for system 23.查看表结构 DB2 describe select * from user.tables (实习编辑:HJ)


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/sjk/10714008.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2023-05-10
下一篇2023-05-10

发表评论

登录后才能评论

评论列表(0条)

    保存