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:
- linux:~#cd /opt
- 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:
- Linux :~ # Cd/opt/DB2_V81_PE_LNX_32_NLVlinux:/opt/DB2_V81_PE_LNX_32_NLV # sh db2_install:
- DB2.ADMCL DB2 Administration Client for LINUX26
- DB2.ESE DB2 Enterprise Server Edition for LINUX26
- 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:
- /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:
- :linux:~ # /opt/IBM/db2/V8.1/adm/db2licm -a /opt/DB2_V81_PE_LNX_32_NLV /db2/license/db2ese.lic
- DBI1402I License added successfully.
- DBI1426I This product is now licensed for use as specified in
- the License Acceptance and License Information
- documents pertaining to the licensed copy of this
- product. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF
- THE TERMS OF THE IBM LICENSE ACCEPTANCE AND LICENSE
- INFORMATION DOCUMENTS, LOCATED IN THE FOLLOWING
- 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
- # groupadd -g 901 db2grp
- # groupadd -g 902 db2fgrp
- # groupadd -g 903 db2agrp# useradd -g db2grp -u 801 -d /home/db2inst1 -m -s /bin/sh db2inst1
- # useradd -g db2fgrp -u 802 -d /home/db2fenc -m -s /bin/sh db2fenc
- # useradd -g db2agrp -u 803 -d /home/db2das -m -s /bin/sh db2das
Step 7 change the password
- # Passwd db2inst1
- Changing password for db2inst1.
- New password: [enter a New password]
- Re-enter new password: [enter the new password again]
- Password changed
After the user is created, run the following command to check whether the user group and user are created successfully.
- # more /etc/group |grep db2
- # more /etc/passwd |grep db2
If the displayed results are consistent with the plan, the user group and the user are successfully created.
- # more /etc/group |grep db2
- dialout:x:16:db2inst1,db2fenc,db2das
- video:x:33:db2inst1,db2fenc,db2das
- db2grp:!:901:
- db2fgrp:!:902:
- db2agrp:!:903:
- # more /etc/passwd |grep db2
- db2inst1:x:801:901::/home/db2inst1:/bin/sh
- db2fenc:x:802:902::/home/db2fenc:/bin/sh
- 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.
- # more /etc/group |grep db2
Run the following command to check whether DB2 users have been created.
- # more /etc/passwd |grep db2
Step 9: Create an instance.
1. Go to the/opt/ibm/db2/V8.1/instance directory.
- # cd /opt/ibm/db2/V8.1/instance
2. Run the following command:
- # ./dascrt -u db2das
- # ./db2icrt -u db2fenc db2inst1
Step 10 configure DB2
Step 1 configure DB2 auto-start.
Run the following command as the root user:
- # cd /opt/ibm/db2/V9.1/instance
- # ./db2iauto -on db2inst1
Step 2: run the following command to switch to db2inst1.
- # su - db2inst1
Step 3 modify the service port of DB2 to 50110.
- 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.
- 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.
- 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.
- db2inst1@linux:~> db2 force applications all
Step 2. Run the following command to shut down the database instance.
- db2inst1@linux:~> db2stop
The system outputs the following information.
SQL1064N DB2STOP processing was successful.
---- End
- linux:~> su - db2ins1
- linux:~> cd
- db2inst1@linux:~> db2 create database mydatab
- 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