IBM Db2 笔记

1. IBM Db2 笔记

1.1. 常用命令

db2 list db directory
db2 connect to SAMPLE
db2 "select substr(bpname,1,12) as bpname from syscat.bufferpools"

1.2. 登录命令行模式 (Using the Db2 command line processor)

# 输入进入命令
db2

# 进入后
db2 => connect to testdb

更多见: Tutorial: Using the Db2 command line processor

1.3. issue

1.3.1. db2: command not found/SQL10007N Message "-1390" could not be retreived. Reason code: "3".

  • Setting Up A Command Line to Run Db2 Commands: Linux or UNIX – Sourcing the Db2 Profile

If you have access to the instance owning id, login and issue:

echo $INSTHOME

On the server, try this:

cat /etc/passwd |grep db2inst1

Look at the instance owner’s .profile, .bash_profile, and .bashrc to find the lines automatically added by Db2 on installation

Once you have the correct location, you can substitute it in to the lines above in the .profile, .bash_profile, and/or the .bashrc of every user who wants to execute Db2 commands:

if [ -f /db2home/db2inst1/sqllib/db2profile ]; then
    . /db2home/db2inst1/sqllib/db2profile
fi

直接用命令: source /db2home/db2inst1/sqllib/db2profile

  • Setting Up A Command Line to Run Db2 Commands: Windows

使用下列程序: db2cmd.exe db2cmdadmin.exe

Powershell: set-item -path env:DB2CLP -value "**$$**"

1.3.2. db2 修改 dbm cfg 的时候报 SQL5001N 错误分析以解决方法

本人今天使用 update 更新 dbm cfg 时候出现了 SQL5001N 错误, 那么就简单的分析一下并给出解决方法:

操作命令: db2 update dbm cfg using DFT_MON_STMT on

报错信息: SQL5001N "KEVIN" does not have the authority to change the database manager configuration file.

kevin 是我的 db2 数据库用户名字, 明显是 kevin 用户没有被授权修改 dbm 配置

首先介绍一下最基础的东西:

实例级权限:

  • SYSADM 最高管理权限, 通常供 DBA 使用
  • SYSCTRL 最高系统控制权限, 有 SYSMAINT 和 SYSMON 的全部权限
  • SYSMAINT 次级系统 控制权限
  • SYSMON 最小的实例级管理权限

Unix/Linux 下的查看命令:

db2 get dbm cfg|grep "SYSADM"
db2 get dbm cfg|grep "SYSCTRL"
db2 get dbm cfg|grep "SYSMAINT"

db2 get dbm cfg|grep "SYSMON"

知道了上面的知识, 那么就知道修改 dbm cfg 需要有最高权限 sysadm,

那么在我的终端是用 db2 get dbm cfg | grep SYSADM

SYSADM group name                        (SYSADM_GROUP) = DB2IADM1

知道只有在组 DB2IADM1 下才有权限去执行, 那么我的示例用户是 db2inst1,

那么终端使用命令 id db2inst1

uid=801(db2inst1) gid=901(db2iadm1)=901(db2iadm1),903(db2dadm1)

很明显使用 db2inst1 用户就可以执行 dbm cfg 更新了

然后使用 su 命令切换到 db2inst1 用户下: su - db2inst1

最后再次使用命令: db2 update dbm cfg using DFT_MON_STMT on

DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed  successfully.

1.4. DB2 ODBC/CLI driver

IBM site

1.5. docker

https://hub.docker.com/r/ibmcom/db2

  • 默认用户名: db2inst1
  • 默认数据库: testdb

1.6. monitor/observability

IBM Db2

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

云满笔记

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值