Create an AIX instance

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

Note: Why do instance users and instance names need to be the same?

There is no instance user option in the instance creation command, but the system finds this user through the Instance name,

The instance folder and file (sqllib) are created in the/home directory ).

-Bash-3.2 # The CD instance is under the instance directory.

-Bash-3.2 #./db2icrt-U test
Dbi1070i program db2icrt completed successfully.

-Bash-3.2 # cd/home
-Bash-3.2 # ls
Askeylinux dasusr1 esaadmin lost + found Test
Tt_db db2fenc1 guest Poka wqs
Chong db2inst1 hegl poka01 Yang
-Bash-3.2 # cd Test
-Bash-3.2 # ls
. Profile. sh_history sqllib

3. Create a database
Su-test

$ Db2start
07 /09/2014 11:04:01 0 0 sql1063n db2start processing was successful.
Sql1063n db2start processing was successful.
$ DB2 create dB tcashman
Db20000i the create database Command completed successfully.

$ DB2 connect to cashmant

Database connection information

Database Server = DB2/aix64 9.7.0
SQL authorization id = test
Local Database alias = cashmant

$ DB2 list tables for all show all tables of the database


$ DB2 drop dB tcashman delete database
Db20000i the drop database Command completed successfully.
$ Db2stop

 

Delete An Instance

-Bash-3.2 # cd/opt/IBM/DB2/v9.7/instance

 

-Run the $ db2home/instance/db2idrop-F Instance name as the root user. Be sure to add-F. Otherwise, the sqllib file under the instance will not be deleted. If you forget to execute db2icrt, an error will be reported in the sqllib file, even if you delete the file first. If you execute db2icrt, a part of sqllib will be generated, leading to a dead end, this is caused by the use of instance user login. Maybe there is a db2profile file which is strange during login. What should I do? Look at me! Log on with a non-instance user, su it to root, delete sqllib, and try db2icrt again. The problem is solved :)

 

Bash-3.2 #./db2idrop-F test be sure to add-F, otherwise the sqllib file under the instance will not be deleted
Dbi1324w support of the-F command is deprecated.
More information, see the DB2 Information Center.

Dbi1070i program db2idrop completed successfully.

 

-Bash-3.2 # cd test: The sqllib file of the test user has been deleted.
-Bash-3.2 # ls
. Profile. sh_history
-Bash-3.2 #

 

-Bash-3.2 $ DB2 get dBm CFG view instance parameter configuration

TCP/IP service name (svcename) = (NO content by default)

You need to set the parameter information through

$ CAT/etc/services

Db2c_db2inst1 50000/tcp // This is the connection port for instance DB2
Db2_db2inst1 60000/tcp // these ports reserved for DB2 fast communications manager
Db2_db2inst1_1 60001/tcp
Db2_db2inst1_2 60002/tcp
Db2_db2instanceend 60003/tcp
Db2_test 60004/tcp
Db2_test_1 60005/tcp
Db2_test_2 60006/tcp
Db2_test_end 60007/tcp

In addition, in the following content obtained by the DB2 get dBm CFG command on the server side, the port number corresponding to db2c_db2 in the services file is the port number of the server listener. TCP/IP service name (svcename) = db2cdb2. To modify the DBM parameter, run the following command: DB2 update dBm CFG using svcename db2cdb2_another. Db2cdb2_another is the port variable defined in advance.

Note that svcename is an instance-level variable. In the DB2 catalog TCPIP node West Remote 9.181.139.155 server 50000 statement, the node of catalog is determined by the IP address and port number. Port 50000 corresponds to the instance-level parameter svcename, therefore, the actual significance of node is instance. node indicates the catalog of the instance on the network.

Make sure that DB2 on the server is started: db2start
Make sure that the client db2comm is set to TCPIP
First, check the db2comm settings: db2set-all.
If this registry is not set, run db2set db2comm = TCPIP
Have you set svcename to the port number or service name in/etc/services?
Run DB2 get dBm CFG to check and find the svcename. If the current value is not the server port number or service name, update the settings.
Run: DB2 update dBm CFG svcename db2inst1
Note: db2inst1 is the service name, which is db2inst1 50000/TCP in the/etc/services file.
Consistent

 

Create Database

-Bash-3.2 $ DB2 create database tcashman using codeset UTF-8 territory CN
Db20000i the create database Command completed successfully.

-Bash-3.2 $ DB2 connect to tcashman

Database connection information

Database Server = DB2/aix64 9.7.0
SQL authorization id = db2inst1
Local Database alias = tcashman

Mkdir: 0653-357 cannot access directory/home.
/Home: the file access permissions do not allow the specified action. The problem is that you do not have permission to access the file.

-Bash-3.2 $ chmod 755 db2inst1

-Bash-3.2 $ CD/home/db2inst1
-Bash-3.2 $ ls
Data db2inst1 export_ SQL fsms_8k_1 sqllib tempo
-Bash-3.2 $ CD Data
-Bash-3.2 $ ls
-Bash-3.2 $ db2look-D Cashman-e-a-X-I db2inst1-w'1qaz! QAZ '-O db_714. SQL
-- Generate statistics for all creators
-- Creating DDL for table (s)
-- Output is sent to file: db_714. SQL
-Bash-3.2 $ ls
Db_714. SQL

Import table structure

DB2 connect to tcashman

DB2-tvf/home/db2inst1/data/db_714. SQL

 

 

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.