第一次在Linux上安装DB2,参考了很多的网上资源,但是主要的是ldquo;Linux下安装DB2 version 8.1 的详细步骤rdquo;。同时把自己
第一次在Linux上安装DB2,参考了很多的网上资源,但是主要的是“Linux下安装DB2 version 8.1 的详细步骤”。
同时把自己遇到的问题住了一个记录,以做学习之用。
VMWARE使用的是VMware server 1.0.6,Linux的内核版本是:Linux node1 2.6.18-53.el5PAE
Root 权限操作:
第一步:检查程序包及其版本
compat-libstdc++-7.3-2.96.118.i386.rpm
在linux的安装盘上,找到后使用rpm -i compat-libstdc++-7.3-2.96.118.i386.rpm 安装即可
第二步:配置 Linux 内核参数
/etc/sysctl.conf文件,添加内核参数
kernel.msgmni =1024
kernel.sem = 250 256000 32 1024
使更改激活:sysctl –p
第三步:安装
sh db2_install
按照提示做
第四步:创建用户
/usr/sbin/groupadd db2iadm1
/usr/sbin/groupadd db2fadm1
/usr/sbin/useradd –m -g db2iadm1 –d /home/db2inst1 db2inst1
/usr/sbin/useradd –m -g db2fadm1 –d /home/db2fenc1 db2fenc1
第五步:创建实例
/opt/IBM/db2/V8.1/instance/db2icrt –a server –u db2fenc1 db2inst1
** please can go into /opt/IBM/db2/V8.1/instance, find file db2iutil
and replace all 'tail +2' with 'tail -n +2' if you meet error.
第六步:产品许可证
/opt/IBM/db2/V8.1/adm/db2licm -a /mnt/cdrom/db2/license/db2pe.lic
第七步:允许SMS的多页分配
/opt/IBM/db2/V8.1/cfg/db2ln
#第八步:添加DB2端口
# SU - root
# vi /etc/services 加入下面一行
# db2inst1 50000/tcp
这一步是不需要的,系统自定添加,但是有可能需要更改一下,我的是这样的:
DB2_db2inst1 50000/tcp
DB2_db2inst1_1 50001/tcp
DB2_db2inst1_2 50002/tcp
DB2_db2inst1_END 50003/tcp
以下是DB2 用户操作
第九步:DB2 配置
su – db2inst1
db2set DB2_EXTENDED_OPTIMIZATION=ON
db2set DB2_DISABLE_FLUSH_LOG=ON
db2set AUTOSTART=YES
db2set DB2_STRIPED_CONTAINERS=ON
db2set DB2_HASH_JOIN=Y
db2set DB2COMM=tcpip
db2set DB2_PARALLEL_IO=*
db2set DB2CODEPAGE=819
#Update dbm cfg
db2 update dbm cfg using SVCENAME db2inst1
db2 update dbm cfg using INDEXREC ACCESS
第十步:运行DB2
db2start
If raised error message:
Please check $DB2_home/sqllib/db2nodes.cfg, /etc/hosts uname -n,, confirm that all the node name is same.
第十一步:创建库
db2 "CREATE DATABASE test1 on /opt/IBM/tony/ USING CODESET ISO8859-1 TERRITORY CN"
以后就可以创建表和对表操作了,如 db2 "select * from sysibm.sysdummy1"
客户端操作:
1. catalog DB
db2 catalog tcpip node DS_NODE remote 192.168.102.128 server 50000
db2 catalog db test1 as ds_test1 at node ds_node
2. DB2 的一个常见连接错误出现:
db2 connect to ds_test1 user db2inst1 using 123456
SQL30081N A communication error has been detected. Communication protocol
being used: "TCP/IP". Communication API being used: "SOCKETS". Location
where the error was detected: "192.168.102.128". Communication function
detecting the error: "connect". Protocol specific error code(s): "10061", "*",
"*". SQLSTATE=08001
把dbm的VCENAME 的值和/etc/services中的端口号对应
db2 update dbm cfg using SVCENAME 50000
3. restart DB
db2stop force
db2start
db2 activate db test1
4. 参数确认
[db2inst1@node1 C]$ db2set -all
[i] DB2COMM=TCPIP
[g] DB2_EEE_LICENSE_POLICY=4295032864
[db2inst1@node1 C]$ netstat -an | grep 50000
确认DB2COMM 参数已经设置,同时50000端口已经启动
5.出现pagecode错误
db2 connect to ds_test1 user db2inst1 using 123456
SQL0332N Character conversion from the source code page "1114" to the target
code page "UNKNOWN" is not supported. SQLSTATE=57017
**原因:连接的数据库使用的代码页设置(819)与本地客户端设置的代码页(1386)不同 之间无法进行双向转换,
即无法将GBK 编码的字符转换为ISO-8859-1字符,解决方法:
db2set DB2CODEPAGE=819
db2 terminate
DB20000I The TERMINATE command completed successfully.
db2 connect to ds_test1 user db2inst1 using 123456
Database Connection Information
Database server = DB2/LINUX 8.1.0
SQL authorization ID = DB2INST1
Local database alias = DS_TEST1

mySqlStringTypesimpactStorageAndPerformanCeaseAsfollows:1)長度,始終使用theSamestoragespace,whatcanbefasterbutlessspace-felfficity.2)varCharisvariable varcharisvariable length,morespace-morespace-morespace-effficitybuteftife buteftife butfority butfority textifforlyslower.3)

mysqlStringTypesIncludeVarChar,文本,char,Enum和set.1)varCharisVersAtileForvariable-lengthStringStringSuptoPuptOuptoPepePecifiedLimit.2)textisidealforlargetStortStorStoverStoverStorageWithoutAutAdefinedLength.3)charlisfixed-lenftenge,for forConsistentDatalikeCodes.4)

MySQLoffersvariousstringdatatypes:1)CHARforfixed-lengthstrings,2)VARCHARforvariable-lengthtext,3)BINARYandVARBINARYforbinarydata,4)BLOBandTEXTforlargedata,and5)ENUMandSETforcontrolledinput.Eachtypehasspecificusesandperformancecharacteristics,sochoose

TograntpermissionstonewMySQLusers,followthesesteps:1)AccessMySQLasauserwithsufficientprivileges,2)CreateanewuserwiththeCREATEUSERcommand,3)UsetheGRANTcommandtospecifypermissionslikeSELECT,INSERT,UPDATE,orALLPRIVILEGESonspecificdatabasesortables,and4)

toadduserInmysqleffect和securly,跟隨台詞:1)USEtheCreateUserStattoDaneWuser,指定thehostandastrongpassword.2)GrantNecterAryAryaryPrivilegesSustherthing privilegesgeStatement,usifementStatement,adheringtotheprinciplelastprefilegege.3)

toaddanewuserwithcomplexpermissionsinmysql,loldtheSesteps:1)創建eTheEserWithCreateuser'newuser'newuser'@''localhost'Indedify'pa ssword';。 2)GrantreadAccesstoalltablesin'mydatabase'withGrantSelectOnMyDatabase.to'newuser'@'localhost';。 3)GrantWriteAccessto'

MySQL中的字符串數據類型包括CHAR、VARCHAR、BINARY、VARBINARY、BLOB、TEXT,排序規則(Collations)決定了字符串的比較和排序方式。 1.CHAR適合固定長度字符串,VARCHAR適合可變長度字符串。 2.BINARY和VARBINARY用於二進制數據,BLOB和TEXT用於大對像數據。 3.排序規則如utf8mb4_unicode_ci忽略大小寫,適合用戶名;utf8mb4_bin區分大小寫,適合需要精確比較的字段。

最佳的MySQLVARCHAR列長度選擇應基於數據分析、考慮未來增長、評估性能影響及字符集需求。 1)分析數據以確定典型長度;2)預留未來擴展空間;3)注意大長度對性能的影響;4)考慮字符集對存儲的影響。通過這些步驟,可以優化數據庫的效率和擴展性。


熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

Video Face Swap
使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱門文章

熱工具

Safe Exam Browser
Safe Exam Browser是一個安全的瀏覽器環境,安全地進行線上考試。該軟體將任何電腦變成一個安全的工作站。它控制對任何實用工具的訪問,並防止學生使用未經授權的資源。

SAP NetWeaver Server Adapter for Eclipse
將Eclipse與SAP NetWeaver應用伺服器整合。

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器

Atom編輯器mac版下載
最受歡迎的的開源編輯器

SublimeText3 Mac版
神級程式碼編輯軟體(SublimeText3)