十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
1、设置主机名和修改/etc/hosts一致
hostnamectl --static set-hostname db2v11
公司主营业务:网站设计制作、做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。成都创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。成都创新互联公司推出平泉免费做网站回馈大家。
2、安装操作系统依赖包
yum install libstdc++.so.6
3、解压包并安装
./db2_deinstall
安装目录,选择推荐目录即可(可以修改目录,如果不修改/预留大小为6G)
Enter "help" to redisplay product names. --------------- 选择安装产品类型,这里选择SERVER
Do you want to install the DB2 pureScale Feature? [yes/no] ---------------- 选择是否安装pureScale功能,这里选择不安装
4、安装完后初始化
groupadd db2iadm1
groupadd db2fadm1
useradd db2inst1 -G db2iadm1
useradd db2fenc1 -G db2fadm1
cd /opt/ibm/db2/V11.1/instance/
./db2icrt -a server -p 50000 -u db2fenc1 db2inst1
5、激活license
以下操作全部以db2inst1用户执行查看license信息
db2licm -l
license激活
db2licm -a /usr/local/src/db2ese_c.lic
6、修改实例
a、修改db2nodes.cfg(可选)位置在instance用户的$HOME/sqllib/.文件格式是:
(2) 检查services文件(多节点配置自动生成多个服务端口)
vi /etc/services
DB2c_db2inst1 50000/tcp // 要与dbm SVCENAME一致
(3) 启动实例:
配置环境变量 --root用户和db2inst1用户
# vi ~/.bash_profile
$ vi ~/.bash_profile
./home/db2inst1/sqllib/db2profile # 增加该行代码
# source ~/.bash_profile
$ source ~/.bash_profile
设置服务名称
$ db2 update dbm cfg using SVCENAME db2inst1
设置注册变量
$ db2set DB2COMM=tcpip
启动实例
$ db2start
7、创建数据库
[root@localhost ~]# su - db2inst1
[db2inst1@localhost ~]$ cd /opt/ibm/db2/V9.7/bin
[db2inst1@localhost bin]$ ./db2sampl
8、调整数据库参数
db2set DB2_PARALLEL_IO=*
db2set DB2_SKIPINSERTED=YES
db2set DB2_USE_ALTERNATE_PAGE_CLEANING=YES
db2set DB2_EVALUNCOMMITTED=YES
db2set DB2_ANTIJOIN=EXTEND
db2set DB2_SKIPDELETED=YES
db2set DB2CODEPAGE=1208
db2 update dbm cfg using DFT_MON_BUFPOOL on
db2 update dbm cfg using DFT_MON_LOCK on
db2 update dbm cfg using DFT_MON_SORT on
db2 update dbm cfg using DFT_MON_STMT on
db2 update dbm cfg using DFT_MON_TABLE on
db2 update dbm cfg using DFT_MON_TIMESTAMP on
db2 update dbm cfg using DFT_MON_UOW on
[db2inst1@db2v11 ~]$ db2 get dbm cfg |grep -i mon
Transaction processor monitor name (TP_MON_NAME) =
Default database monitor switches
Buffer pool (DFT_MON_BUFPOOL) = OFF
Lock (DFT_MON_LOCK) = OFF
Sort (DFT_MON_SORT) = OFF
Statement (DFT_MON_STMT) = OFF
Table (DFT_MON_TABLE) = OFF
Timestamp (DFT_MON_TIMESTAMP) = ON
Unit of work (DFT_MON_UOW) = OFF
Monitor health of instance and databases (HEALTH_MON) = OFF
SYSMON group name (SYSMON_GROUP) =
Database monitor heap size (4KB) (MON_HEAP_SZ) = AUTOMATIC(90)
授权
db2 get dbm cfg |grep -i sysmon
groupadd db2user
db2 update dbm cfg using SYSMON_GROUP db2user
db2 attach to db2inst1
db2 force applications all
db2stop force
db2 get dbm cfg |grep -i sysmon
useradd -g db2user -d /home/dpmmon -s /bin/bash -m dpmmon
su - db2inst1
db2 connet to 数据库
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_SERVICE_SUBCLASS TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_TABLESPACE TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_CONTAINER TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_PKG_CACHE_STMT TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_BUFFERPOOL TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.ENV_GET_SYSTEM_RESOURCES TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.ENV_GET_DB2_SYSTEM_RESOURCES TO USER dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.ENV_GET_NETWORK_RESOURCES TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_CONNECTION TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_TABLE TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_LOCKS TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_ACTIVITY TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.MON_BP_UTILIZATION TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.MON_BP_UTILIZATION TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.MON_LOCKWAITS TO user dpmmon"
db2 "grant sqladm on database to user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_FORMAT_LOCK_NAME TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_SERVICE_SUBCLASS TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.SNAPDB TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.SNAPDB_MEMORY_POOL TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.MON_LOCKWAITS TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.SNAPDBM TO user dpmmon"
db2 "GRANT SELECT ON TABLE SYSIBMADM.ENV_INST_INFO TO user dpmmon"
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.SNAP_GET_HADR TO user dpmmon"---需要在配置hadr上配置
db2 "GRANT EXECUTE ON FUNCTION SYSPROC.MON_GET_SYSTEM_RESOURCES TO user dpmmon"-----报错,可忽略
su - dpmmon
if [ -f /home/db2inst1/sqllib/db2profile ]; then
. /home/db2inst1/sqllib/db2profile
fi
db2 connect to sample
/home/db2inst1/sqllib/misc
db2 -tvf EXPLAIN.DDL
[dpmmon@db2v11 misc]$ db2 list tables
Table/View Schema Type Creation time
------------------------------- --------------- ----- --------------------------
ADVISE_INDEX DPMMON T 2018-12-30-18.01.12.076928
ADVISE_INSTANCE DPMMON T 2018-12-30-18.01.11.780594
ADVISE_MQT DPMMON T 2018-12-30-18.01.12.737807
ADVISE_PARTITION DPMMON T 2018-12-30-18.01.13.200973
ADVISE_TABLE DPMMON T 2018-12-30-18.01.13.707483
ADVISE_WORKLOAD DPMMON T 2018-12-30-18.01.12.454300
EXPLAIN_ACTUALS DPMMON T 2018-12-30-18.01.16.561204
EXPLAIN_ARGUMENT DPMMON T 2018-12-30-18.01.08.940831
EXPLAIN_DIAGNOSTIC DPMMON T 2018-12-30-18.01.10.379307
EXPLAIN_DIAGNOSTIC_DATA DPMMON T 2018-12-30-18.01.10.858547
EXPLAIN_INSTANCE DPMMON T 2018-12-30-18.01.07.627235
EXPLAIN_OBJECT DPMMON T 2018-12-30-18.01.09.203827
EXPLAIN_OPERATOR DPMMON T 2018-12-30-18.01.09.322018
EXPLAIN_PREDICATE DPMMON T 2018-12-30-18.01.09.593889
EXPLAIN_STATEMENT DPMMON T 2018-12-30-18.01.08.443878
EXPLAIN_STREAM DPMMON T 2018-12-30-18.01.09.938834
OBJECT_METRICS DPMMON T 2018-12-30-18.01.11.477921