更改DB2实例的fence用户的两种办法ITeye - 众发娱乐

更改DB2实例的fence用户的两种办法ITeye

2019年02月21日07时20分39秒 | 作者: 鸿畴 | 标签: 实例,用户,办法 | 浏览: 467

碰到有个DB2的实例竟然实例用户和fence用户是相同的
做了个测验,测验更改fence用户
留意!不管运用哪个办法,都应该全面的备份数据库以及其参数设置。篇幅原因,这些以下没有列出。

鉴于第一个办法在db2idrop的时分会删去sqllib下面的某些文件,具有必定危险
所以引荐第二种办法,危险较小

#办法一:
思路:
1.运用db2cfexp导出实例装备
2.中止实例
3.删去实例
4.运用新的fence用户树立实例
5.运用db2cfimp导入原有实例装备
6.发动新的实例

参阅:
[url]https://www-304.ibm.com/support/docview.wss?uid=swg21267506 [/url]

树立instance,instance用户和fence用户相同
[root@localhost home]# /opt/ibm/db2/V9.7/instance/db2icrt -u db2inst4 db2inst4
DBI1070I Program db2icrt completed successfully.
[root@localhost home]# su - db2inst4
[db2inst4@localhost ~]$ db2ilist
db2inst4
db2inst3
查看fence用户
[db2inst4@localhost sqllib]$ db2pd -fmp |grep -i fen |grep -i user
Fenced User: db2inst4
开端更改
1.运用db2cfexp导出实例装备
[db2inst4@localhost ~]$ db2cfexp cfexp.txt backup
树立测验数据
[db2inst4@localhost ~]$ db2 "insert into t1 values (1)"
DB20000I The SQL command completed successfully.
[db2inst4@localhost ~]$ db2 "insert into t1 values (2)"
DB20000I The SQL command completed successfully.
[db2inst4@localhost ~]$ db2 "insert into t1 values (3)"
DB20000I The SQL command completed successfully.
[db2inst4@localhost ~]$ db2 commit
DB20000I The SQL command completed successfully.
[db2inst4@localhost ~]$ db2 "select * from t1"
-
 3 record(s) selected.
2.中止实例
[db2inst4@localhost ~]$ db2stop
SQL1025N The database manager was not stopped because databases are still active.
3.删去实例
[root@localhost ~]# /opt/ibm/db2/V9.7/instance/db2idrop db2inst4
DBI1070I Program db2idrop completed successfully.
[root@localhost ~]# /opt/ibm/db2/V9.7/instance/db2ilist
db2inst3
实例现已没有了
4.运用新的fence用户树立实例
[root@localhost home]# /opt/ibm/db2/V9.7/instance/db2icrt -u db2fenc1 db2inst4
DBI1070I Program db2icrt completed successfully.
[root@localhost home]# su - db2inst4
[db2inst4@localhost ~]$ db2ilist
db2inst4
db2inst3
5.运用db2cfimp导入原有实例装备
[db2inst4@localhost ~]$ db2cfimp cfexp.txt
6.发动新的实例
[db2inst4@localhost ~]$ db2start
SQL1063N DB2START processing was successful.
测验一下原有数据
[db2inst4@localhost ~]$ db2 "select * from t1"
-
 3 record(s) selected.
查看新的fence用户
[db2inst4@localhost ~]$ db2pd -fmp |grep -i fen
Trusted Path: /home/db2inst4/sqllib/function/unfenced
Fenced User: db2fenc1
[db2inst4@localhost ~]$ more ~/sqllib/ctrl/.fencedID 
db2fenc1


#办法二:
1.中止数据库
2.运用db2iupdt更新
3.db2updv9 ——如有需求
4.发动实例

接着之前的实例,持续做。测验把fence用户从头设置成db2inst3
[db2inst4@localhost ~]$ db2pd -fmp |grep -i fen
Trusted Path: /home/db2inst4/sqllib/function/unfenced
Fenced User: db2fenc1
[db2inst4@localhost ~]$ more ~db2inst1/sqllib/ctrl/.fencedID
/home/db2inst1/sqllib/ctrl/.fencedID: No such file or directory
[db2inst4@localhost ~]$ more ~/sqllib/ctrl/.fencedID 
db2fenc1
1.中止数据库
[db2inst4@localhost ~]$ db2stop
SQL1064N DB2STOP processing was successful.
2.运用db2iupdt更新
[root@localhost db2inst4]# /opt/ibm/db2/V9.7/instance/db2iupdt -u db2inst3 db2inst4
/opt/ibm/db2/V9.7/instance/db2iutil: line 6163: chgowngrp: command not found
DBI1070I Program db2iupdt completed successfully.
4.发动实例
[db2inst4@localhost ~]$ db2start
SQL1063N DB2START processing was successful.
查看一下新的fence用户
[db2inst4@localhost ~]$ db2pd -fmp | grep -i fen
Trusted Path: /home/db2inst4/sqllib/function/unfenced
Fenced User: db2inst3
[db2inst4@localhost ~]$ cat sqllib/ctrl/.fencedID 
db2inst3
成为新的fence用户了
查看测验数据
[db2inst4@localhost ~]$ db2 "select * from t1"
-
 3 record(s) selected.


版权声明
本文来源于网络,版权归原作者所有,其内容与观点不代表众发娱乐立场。转载文章仅为传播更有价值的信息,如采编人员采编有误或者版权原因,请与我们联系,我们核实后立即修改或删除。

猜您喜欢的文章