Detailed description of the DB2 database installation process in CentOS, centosdb2

Source: Internet
Author: User
Tags db2 connect db2 connect to

Detailed description of the DB2 database installation process in CentOS, centosdb2

This tutorial describes how to install a DB2 database in inux.

Before installation, check the DB2 version and license description to learn more about it. First, check the latest version of Express-C, this version is provided for personal learning.

The management Client no longer has a control center after v9.7, but uses the Data Studio Client.

Linux version:

In Linux, DB2 databases use the official free version and CentOS6.2 for the operating system.

Installation Process:

1. Download: db2_v101_linuxia32_expc.tar.gz

2. decompress the package. After the package is decompressed, A./expc folder is located in the current directory.

Copy codeThe Code is as follows:
[Root @ localhost opt] # tar-zxvf db2_v101_linuxia32_expc.tar.gz

3. Enter this directory

Copy codeThe Code is as follows:
[Root @ localhost opt] # cd expc/

4. Install

Copy codeThe Code is as follows:
[Root @ localhost expc] #./db2_install

5. Add groups and users:

Group (user name)
Db2iadm1 (db2inst1)
Db2fadm1 (db2fenc1)
Copy codeThe Code is as follows:
[Root @ localhost expc] # groupadd-g 2000 db2iadm1
[Root @ localhost expc] # groupadd-g 2001 db2fadm1
[Root @ localhost expc] # useradd-m-g db2iadm1-d/home/db2inst1 db2inst1
[Root @ localhost expc] # useradd-m-g db2fadm1-d/home/db2fenc1 db2fenc1
[Root @ localhost expc] # passwd db2inst1
[Root @ localhost expc] # passwd db2fenc1

6. Install license (Product license) PS: if the version is ExpressC, you do not need to do so.

Copy codeThe Code is as follows:
[Root @ localhost adm] # pwd
[Root @ localhost adm] # chmod-R 775 *
[Db2inst1 @ localhost adm] $./db2licm-a/tmp/seagull/db2v10/license/db2ese_c.lic

7. Create instances and sample Databases

Copy codeThe Code is as follows:
[Root @ localhost instance] # pwd
[Root @ localhost instance] # chmod-R 775 *
[Root @ localhost instance] #./db2icrt-p 50000-u db2fenc1 db2inst1
[Root @ localhost instance] # su-db2inst1
[Db2inst1 @ localhost ~] $ Db2sampl
Creating database "SAMPLE "...
Connecting to database "SAMPLE "...
Creating tables and data in schema "DB2INST1 "...
Creating tables with XML columns and XML data in schema "DB2INST1 "...
'Db2sampl' processing complete.
[Db2inst1 @ localhost ~] $ Db2start
SQL1026N The database manager is already active.
[Db2inst1 @ localhost ~] $ Db2 connect to sample
Database Connection Information
Database server = DB2/LINUX 10.1.2
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
[Db2inst1 @ localhost ~] $ Db2 "select * from staff"

8. Create a das Management Server

To allow remote clients to use the control center to control the database server, you need to install the das on the database server. Of course, if it is just a remote connection rather than remote management, you do not need to install it. Here I have installed it.
Copy codeThe Code is as follows:
[Root @ localhost expc] # groupadd-g 2002 db2asgrp
[Root @ localhost expc] # useradd-m-g db2asgrp-d/home/db2as db2as
[Root @ localhost expc] # passwd db2as
[Db2as @ localhost ~] $ Su-db2as # test new user here
[Db2as @ localhost ~] $ Su # enter the root permission here
[Root @ localhost ~] # Cd/opt/ibm/db2/V10.1/instance/
[Root @ localhost instance] #./dascrt-u db2as
DBI1070I Program dascrt completed successfully.
[Root @ localhost instance] # su-db2as
[Db2as @ localhost ~] $ Db2admin start
Sql00009w The DB2 Administration Server is already active.

9. Set the port number

Copy codeThe Code is as follows:

Add a line # PS: VIM shortcut key at the end, and enter "G" in command mode to jump to the last line.
Copy codeThe Code is as follows:
Db2inst1 50000/tcp

10. For db2 configuration, switch to user db2inst1

Copy codeThe Code is as follows:
Db2set DB2_HASH_JOIN = Y
Db2set DB2COMM = tcpip
Db2set DB2_PARALLEL_IO = *
Db2set DB2CODEPAGE = 819 # PS: this is important.
# Db2 update database manager configuration using svcename db2inst1

11. Have you set SVCENAME to the port number or service name in/etc/services?

Copy codeThe Code is as follows:
[Db2inst1 @ localhost ~] $ Db2 get dbm cfg | grep SVCENAME
TCP/IP Service name (SVCENAME) =
SSL service name (SSL_SVCENAME) =

Find the SVCENAME. If the current value is not the server port number or service name, update the settings.
Copy codeThe Code is as follows:
[Db2inst1 @ localhost ~] $ Db2 update dbm cfg using SVCENAME db2inst1
# Db2 update dbm cfg using INDEXREC ACCESS
[Db2inst1 @ localhost ~] $ Db2 get dbm cfg | grep SVCENAME
TCP/IP Service name (SVCENAME) = 50000
SSL service name (SSL_SVCENAME) =

# PS: svcename required for client connection

12. Disable the firewall before starting DB2.Otherwise, the connection will not be connected at all (the negligence in this place has been entangled For A Long Time), and the following command will be executed under the root user: service iptables stop

13. Start DB2Run: db2start. If the status is enabled, stop and run: db2stop.

View settings:

PS: after the machine is restarted, a problem occurs, that is, no response is triggered when the firewall is disabled. If the firewall is enabled and the database is disabled, the remote connection to the database is disabled. The solution is to restart the server, the firewall is closed in sequence, and the DB2 database is restarted.

Restart the db2 database in linux

The CentOS system I use. The kernel is Linux. After entering the graphic interface, right-click "create terminal" on the desktop"

1. Switch to the db2inst1 account using the following statement on the command line interface:

Note: The command must be in lower case, and the minus sign in the middle is half-width. The db2inst1 account (also an instance or process) is a default account created during the installation of DB2, which is equivalent to the DB2 instance in Windows. To execute various db2 commands, operation under this account;

2. Under this account, you can open the control center or go to the command line processor. The method for entering the command line processor is very simple. Use the db2 command directly and press Enter;

3. It is a little troublesome to open the control center. You need to open another command line window on the desktop and enter:
Xhost local: db2

Then, in the window where the db2inst1 account is located, enter the following command:
Db2cc &
You can open the control center.
4. Now you can view the current instance
To create a table, open the Database Management Service and enter the following command:
Db2start // start a db2 instance
Db2stop // stop a db2 instance
Db2set-all // view all the db2 registry Variables

There is a db2 administrator in the Variable list: DB2ADMINSERVER = XXXXX
The su-XXXXX table can be created only when you switch to the management user.
Then, enter the command: db2admin start to start the management instance.

In Linux, a user corresponds to an instance, and the database to be created must be created under the instance. Therefore, you can switch to the user to switch to the instance. The command is as follows:

Db2 get instance

How to clear the logs of the db2 database in linux

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: 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.