您好,登錄后才能下訂單哦!
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/.文件格式是:
<logic port> <hostname> <logic port> //主機名要與/etc/hosts 的主機名一致 或hostname命令查看
(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
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。