Install DB2 in linux

Source: Internet
Author: User

How can I install DB2 in linux? The following describes how to install DB2 in linux.

Step 1
Download db2 data packets,

Step 2
Put the downloaded package (the name may be DB2_V81_PE_LNX_32_NLV.tar) into the opt directory.

Step 3
Run the following command to decompress db2_v81_pe_lnx_32_nlv.tar:

 
 
  1. linux:~#cd /opt  
  2. linux:/opt # tar -xvf DB2_V81_PE_LNX_32_NLV.tar 

Step 4
After decompression, there will be a directory name such as tar-xvf DB2_V81_PE_LNX_32_NLV. After you click in, you can see three files. The other one is installed with the command (db2_install) and the other is the image interface (db2setup)
Switch to/opt/DB2_V81_PE_LNX_32_NLV and run the following command:

 
 
  1. Linux :~ # Cd/opt/DB2_V81_PE_LNX_32_NLVlinux:/opt/DB2_V81_PE_LNX_32_NLV # sh db2_install:
  2. DB2.ADMCL DB2 Administration Client for LINUX26
  3. DB2.ESE DB2 Enterprise Server Edition for LINUX26
  4. DB2.ADCL DB2 Application Development Client for LINUX26

Then, make the selection in uppercase. If you select DB2.ESE, it will execute all the files by itself. After the execution, the IBM
Indicates that the installation is complete.
Next, we will create an instance and a database.

Step 5 (register license)
If you want to register a license, you will not be able to create a database at that time. If you want to find the license, it will usually appear here:

 
 
  1. /opt/IBM/db2/V8.1/adm/db2licm -a /opt/DB2_V81_PE_LNX_32_NLV/db2/license/db2ese.lic 

Run/opt/IBM/db2/V8.1/adm/db2licm-a/opt/334_ESE_LNX26_32_NLV/db2/license/db2ese. lic under the root user.

The command is as follows:

 
 
  1. :linux:~ # /opt/IBM/db2/V8.1/adm/db2licm -a /opt/DB2_V81_PE_LNX_32_NLV /db2/license/db2ese.lic   
  2. DBI1402I License added successfully.  
  3. DBI1426I This product is now licensed for use as specified in   
  4.           the License Acceptance and License Information   
  5.           documents pertaining to the licensed copy of this   
  6.           product. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF   
  7.           THE TERMS OF THE IBM LICENSE ACCEPTANCE AND LICENSE   
  8.           INFORMATION DOCUMENTS, LOCATED IN THE FOLLOWING   
  9.           DIRECTORY: /opt/IBM/db2/V8.1/license/zh_CN.utf8 

If the above prompt appears after execution, the registration is successful.

Step 6: create user groups and users

 
 
  1. # groupadd -g 901 db2grp  
  2. # groupadd -g 902 db2fgrp  
  3. # groupadd -g 903 db2agrp# useradd -g db2grp -u 801 -d /home/db2inst1 -m -s /bin/sh db2inst1  
  4. # useradd -g db2fgrp -u 802 -d /home/db2fenc -m -s /bin/sh db2fenc  
  5. # useradd -g db2agrp -u 803 -d /home/db2das -m -s /bin/sh db2das 

Step 7 change the password

 
 
  1. # Passwd db2inst1
  2. Changing password for db2inst1.
  3. New password: [enter a New password]
  4. Re-enter new password: [enter the new password again]
  5. Password changed

After the user is created, run the following command to check whether the user group and user are created successfully.

 
 
  1. # more /etc/group |grep db2  
  2. # more /etc/passwd |grep db2 

If the displayed results are consistent with the plan, the user group and the user are successfully created.

 
 
  1. # more /etc/group |grep db2  
  2. dialout:x:16:db2inst1,db2fenc,db2das  
  3. video:x:33:db2inst1,db2fenc,db2das  
  4. db2grp:!:901:  
  5. db2fgrp:!:902:  
  6. db2agrp:!:903:  
  7. # more /etc/passwd |grep db2  
  8. db2inst1:x:801:901::/home/db2inst1:/bin/sh  
  9. db2fenc:x:802:902::/home/db2fenc:/bin/sh  
  10. db2das:x:803:903::/home/db2das:/bin/sh 

Step 8 check DB2 users
Run the following command to check whether the DB2 user group is created.

 
 
  1. # more /etc/group |grep db2 


Run the following command to check whether DB2 users have been created.

 
 
  1. # more /etc/passwd |grep db2 

Step 9: Create an instance.
1. Go to the/opt/ibm/db2/V8.1/instance directory.

 
 
  1. # cd /opt/ibm/db2/V8.1/instance 

2. Run the following command:

 
 
  1. # ./dascrt -u db2das  
  2. # ./db2icrt -u db2fenc db2inst1 

Step 10 configure DB2
Step 1 configure DB2 auto-start.
Run the following command as the root user:

 
 
  1. # cd /opt/ibm/db2/V9.1/instance  
  2. # ./db2iauto -on db2inst1 

Step 2: run the following command to switch to db2inst1.

 
 
  1. # su - db2inst1 

Step 3 modify the service port of DB2 to 50110.

 
 
  1. db2inst1@masa:~> db2 update dbm cfg using SVCENAME 50110 

DB20000I The update database manager configuration command completed
Successfully.
Step 4 modify the DB2 connection mode to TCPIP.

 
 
  1. db2inst1@masa:~> db2set DB2COMM=TCPIP 

---- End

Step 2 start and close a database instance
Start a database instance
In db2inst1, run db2start to start the database instance. The system output is as follows.

 
 
  1. db2inst1@linux:~> db2start 

SQL1063N DB2START processing was successful.
Shut down database instances
Step 1 execute the following command under db2inst1 to force close all connections.

 
 
  1. db2inst1@linux:~> db2 force applications all 

Step 2. Run the following command to shut down the database instance.

 
 
  1. db2inst1@linux:~> db2stop 

The system outputs the following information.
SQL1064N DB2STOP processing was successful.
---- End

 
 
  1. linux:~> su - db2ins1   
  2. linux:~> cd   
  3. db2inst1@linux:~> db2 create database mydatab   
  4. DB20000I The CREATE DATABASE command completed successfully.  

The database is created successfully.

Top 10 considerations for DB2 Performance Optimization

How to view DB2 dynamic SQL statements

Learn about the DB2 Index Structure

Provides you with an in-depth understanding of the DB2 materialized query table.

Two Methods for restoring DB2 partitioned Database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.