设为首页 收藏本站
查看: 1205|回复: 0

[经验分享] db2 catalog 解释

[复制链接]

尚未签到

发表于 2016-11-18 06:47:14 | 显示全部楼层 |阅读模式
  在DB2数据库中,编目(catalog)这个单词很难理解,我自己当初在学习DB2的时候也常常被这个编目搞的很不明白,直到现在我个人也感觉到DB2中编目(catalog)这个术语用的不是很好,具体来说编目有编目节点,编目数据库等。如果要理解编目,我先简单讲一下DB2数据库的体系结构,在DB2数据库中最大的概念是系统(节点)也就是主机,下面是实例,实例下面是数据库,然后是表空间,然后是数据库对象。现在假设你有一个数据库服务器在p570的机器上,你有一个客户端在windows,linux或任何平台上,你现在想建立一个客户端到服务器端的连接,具体步骤是什么呢?
第一步:
你必须要在客户端的机器上能够把远程的服务器能够识别出来,这个具体如何来做呢?在DB2使用的编目(catalog)方式,具体来说就是通过编目把远程的服务器写在本地客户端的一个文件中:
db2 catalog tcpip node p570 remote 172.10.10.10 server 50000

在上面的这条命令中p570是一个节点名(在一个机器上必须是唯一的),remote后面是服务器的IP地址,server是远程服务器上实例对应的端口号。DB2通过这种方式在本地的SQLNODIR文件中把远程服务器的信息记录下来,所以编目节点其实就是把远程服务器映射到本地,通过SQLNODIR中的记录能够找到远程服务器和实例,类似指向远程服务器和实例的地址指针。

第二步:
当把远程的服务器IP地址,实例编目下来后,第二步应该把该实例下的数据库编目到本地
db2 catalog db REMOTEDB at node p570

在这条命令中,REMOTEDB是远程实例下的数据库,p570是我们在第一步中编目的节点名
这条命令执行后会在本地SQLDBDIR文件中记录远程数据库的信息,这这里编目数据库可以理解为把远程服务器实例下的数据库映射到本地为一个别名
=========================================
上面是客户端和服务器不在同一台机器上,是通过编目节点,编目数据库来实现客户端连接到服务器上数据库的目的,如果是连接在同一台机器上,那么这时候不要显示的编目节点,但是在服务器上当我们创建一个实例的时候,有一个隐含的把实例在本地编目的过程,假设在p570上创建一个实例名为db2inst1,其实有一个隐含的
db2 catalog local node db2inst1 instance db2inst1 system p570 ostype aix的步骤,
同样当你在db2inst1下创建一个数据库MYDB的时候,有一个隐含的编目(catalog)数据库的步骤:
db2 catalog db mydb at node db2inst1的步骤
  至此你可以这样理解编目(catalog),编目就是在本地或远程建立客户端到服务器的数据库连接的目的。
  

  ===============================================
  

db2 catalog 命令

  catalog一个普通的数据库
  db2 catalog tcpip node<Node Name> remote <IP> server <Port>
db2 catalog db <Database Name> at node <Node Name>
db2 connect to <Database Name> user<DB2 UserName> using<DB2 Password>
db2 connect reset
  uncatalog
db2 uncatalog node <Node Name>


catalog db2 on z/OS
db2 catalog tcpip node <Node Name> remote  <IP> server<Port>
db2 catalog db <SubSystem Name> at node <Node Name>
db2 connect to <SubSystem Name>user <DB2 UserName> using <DB2 Password>
db2 connect reset
  uncatalog
db2 uncatalog node <Node Name>
  

  ================================================
DB2:Database Connection Services Directory
The Database Connection Services (DCS) directory contains connectivity information for host databasesresiding on System z (z/OS or OS/390) or System i (OS/400) server. You need to have DB2 Connect software installed.


To list the contents of the DCS directory, issue the following command:

db2 list dcs directory

To enter information into the DCS directory, use

db2 catalog dcs dbdbnameas location_name

For example

db2 catalog dcs db mydb as db1g


Three table spaces—SYSCATSPACE(holding the Catalog tables), TEMPSPACE1 (system temporary

space), and USERSPACE1 (the default user table space)—areautomatically created

when you create a database. SYSCATSPACE and TEMPSPACE1 can be considered system

structures, as they are needed for the normal operation of your database. SYSCATSPACE contains

the catalog tables containingmetadata(dataabout your database objects) and must exist at

all times. Some other RDBMSs call this structure a“datadictionary.”


If the database you want to access is MYDB2, which was in themyinstinstance,you would first

need to create this instance, switch to the instance, and then issue thecatalogcommandas

shown below.

db2icrt myinst

set DB2INSTANCE=myinst

catalog db mydb2 on h:

It is a good practice to back up the contents of all your configuration files as shown below.

db2 get dbm cfg > dbmcfg.bk

db2 get db cfg fordatabase_name> dbcfg.bk

db2set -all > db2set.bk

db2 list db directory > systemdbdir.bk

db2 list node directory > nodedir.bk

db2 list dcs directory > dcsdir.bk


Database federated support in DB2 allows tables from multiple databases to be presented as

local tables to a DB2 server. The databases may be local or remote; they can also belong to different

RDBMSs.


First of all, make sure that your server allows federated support: The database manager parameter

FEDERATED must be set to YES.

  

运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-301798-1-1.html 上篇帖子: DB2导入导出命令(工作中使用) 下篇帖子: DB2错误码解释对照
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表