第一次在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

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL is an open source relational database management system suitable for data storage, management, query and security. 1. It supports a variety of operating systems and is widely used in Web applications and other fields. 2. Through the client-server architecture and different storage engines, MySQL processes data efficiently. 3. Basic usage includes creating databases and tables, inserting, querying and updating data. 4. Advanced usage involves complex queries and stored procedures. 5. Common errors can be debugged through the EXPLAIN statement. 6. Performance optimization includes the rational use of indexes and optimized query statements.

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

InnoDB's lock mechanisms include shared locks, exclusive locks, intention locks, record locks, gap locks and next key locks. 1. Shared lock allows transactions to read data without preventing other transactions from reading. 2. Exclusive lock prevents other transactions from reading and modifying data. 3. Intention lock optimizes lock efficiency. 4. Record lock lock index record. 5. Gap lock locks index recording gap. 6. The next key lock is a combination of record lock and gap lock to ensure data consistency.

The main reasons for poor MySQL query performance include not using indexes, wrong execution plan selection by the query optimizer, unreasonable table design, excessive data volume and lock competition. 1. No index causes slow querying, and adding indexes can significantly improve performance. 2. Use the EXPLAIN command to analyze the query plan and find out the optimizer error. 3. Reconstructing the table structure and optimizing JOIN conditions can improve table design problems. 4. When the data volume is large, partitioning and table division strategies are adopted. 5. In a high concurrency environment, optimizing transactions and locking strategies can reduce lock competition.

In database optimization, indexing strategies should be selected according to query requirements: 1. When the query involves multiple columns and the order of conditions is fixed, use composite indexes; 2. When the query involves multiple columns but the order of conditions is not fixed, use multiple single-column indexes. Composite indexes are suitable for optimizing multi-column queries, while single-column indexes are suitable for single-column queries.

To optimize MySQL slow query, slowquerylog and performance_schema need to be used: 1. Enable slowquerylog and set thresholds to record slow query; 2. Use performance_schema to analyze query execution details, find out performance bottlenecks and optimize.

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function