<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    隨筆-25  評(píng)論-6  文章-0  trackbacks-0
      2006年10月31日

    Question:
    The restore command works fine, but while attempting the rolforward of the sql logs, it complains about database falling short on bufferpool,and then terminates the rollforward process. One close look at the db2diag.log file, I noticed that db2 tried to start the database with the hidden bufferpool. But, apparently, that hidden bufferpool was pretty small to rollforward the logs and bring it online.

    I cannot reduce the bufferpool size as the database cannot be connected to.I cannot connect to the database as it is in rollforward pending state. I cannot rollforward the database, as it's not happy with the size of the *hidden* bufferpool and terminates.

    Answer:

    db2set DB2_OVERRIDE_BPF=50000

    This will bring up all configured bufferpools using 50000 pages each. You
    can choose a smaller/larger value that is suitable for your number of
    bufferpools and available system memory. You can also configure each
    bufferpool individually if you want

    値: 正數(shù)のページ數(shù)
    ???? OR
    ?<entry>[;<entry>...] (<entry>=<バッファー?プール ID>,<ページ數(shù)> )

    There is sitiuation that above solution does not work.

    				When you try to create a bufferpool or alter a bufferpool to a
    very large size and there is not enough memory in the system
    , DB2 may occupies all pagespace and overrall performance of
    the system become slow and may get hang at last because no
    pagespace is available. Then after you connect the database
    next time, DB2 will do crash recovery and still try to
    allocate memory for this big bufferpool and occupy all
    pagespace again. when you specify DB2_OVERRIDE_BPF parameter
    to override bufferpool size, it doesn't take effect in this
    situation. This is becasue DB2_OVERRIDE_BPF only applies for
    bufferpools that already exist at startup, and not to
    bufferpools that are created during crash recovery or roll
    forward. We will fix this problem and check DB2_OVERRIDE_BPF
    registry when creating bufferpools during crash recovery or
    roll forward. This problem only occurs in a 64 bit instance.
    
    		

    Local fix

    				You can use db2iupdt -w 32 <INSTNAME> to update the instance to
    a 32 bit instance, then you can connect to the database
    succefully. After that, use db2iupdt -w 64 <INSTNAME> to update
    the instance to 64 bit again. Please take a backup at this
    point, so we don't have to roll forward through bufferpool
    creation that fails if we need restore and roll forward
    database.
    
    		

    Problem summary

    				Users Affected:
    All users using 64 bit instance
    Problem Description:
    When you try to create a bufferpool or alter a bufferpool to a
    very large size and there is not enough memory in the system
    , DB2 may occupies all pagespace and overrall performance
    of the system become slow and may get hang at last
    because no pagespace is available. Then after you connect the
    database at next time, DB2 will do crash recovery and still try
    to allocate
    memory for this big bufferpool and occupy all pagespace again.
    In this situation, when you specify DB2_OVERRIDE_BPF parameter
    to override bufferpool size, it doesn't take effect in this
    situation. This
    is becasue DB2_OVERRIDE_BPF only applies for bufferpools that
    already exist at startup, and not to bufferpools that are
    created during crash recovery or roll forward. We will fix
    this problem and check
    DB2_OVERRIDE_BPF registry when creating bufferpools during crash
    recovery or roll forward. This problem only occurs in 64 bit
    instance.
    Problem Summary:
    This problem is caused by a misoperation, when you create or alt
    er a bufferpool, the size is too large to allocated from OS and
    cause overrall performance of the system is very slow and seems
    hang. Another problem is that DB2_OVERRIDE_BPF registry only app
    lies to bufferpools that already exists, and not bufferpools wil
    l be created in crash recovery or roll forward. So DB2 will try
    to create this big bufferpool again when doing crash recovery or
     roll forward. We will fix this problem and check DB2_OVERRIDE_B
    PF registry in our crash recovery and roll forward code.
    
    		

    Problem conclusion

    				
    				
    		

    Temporary fix

    				You can use db2iupdt -w 32 <INSTNAME> to update the instance to
    a 32 bit instance, then you can connect to the database
    succefully. After that, use db2iupdt -w 64 <INSTNAME> to update
    the instance to 64 bit again. Please take a backup at this
    point, so we don't have to roll forward through bufferpool
    creation that fails if we need restore and roll
    forward database.Please also notice that be careful when creati
    ng bufferpool, don't specify a too large value.
    
    		


    posted @ 2007-03-15 15:21 MyJavaWorld 閱讀(741) | 評(píng)論 (0)編輯 收藏

    Change db2 password in db2 level

    DB2 depends on operation system level authorization to control DB2 system access.

    In some case, our db2 account only allows to connect to instance or database, but not log on the system. In other words, we are not able to use the account to get a shell on unix or logon locally on windows.

    As usual, when we need to change db2 password, we take action on the system level because it's more frank. But in the case above that we can't get logon, we have to do it on db2 level. There are 2 ways.

    • Use the GUI tool DB2 Configuration Assistance
    • Use the command line tools DB2 CLP or CE

    Using DB2 Configuration Assistance

    Right click on a database name, then choose "Change password".

    CA tool interface

    Note: When more than one databases live in same system, we might share the same account in multi-database. Changing password for one of them will affect all databases in this system. In other words, we don't need to do the change on each database, we could choose any we have privileges on the system.

    Limitation: We are not able to change our password in the case of that we are only allowed to attach to the node but not connect to any database, or we don't get the catalog information for any database in the node.

    For this limitation, it works out with the 2nd way.?

    Using DB2 CLP and CE

    We could use CLP and CE to change password for databases and nodes that we connected or attached to.

    • Change by connecting to database
    C:\> db2 connect to SAMPLE user TEST using OLDPWD new NEWPWD confirm NEWPWD
    C:\> db2 connect to SAMPLE user TEST using OLDPWD change password
    • Change by attaching to node, this way works out for the limitation in Configuration Assistance
    C:\> db2 attach to NODE user TEST using OLDPWD new NEWPWD confirm NEWPWD
    C:\> db2 attach to NODE user TEST using OLDPWD change password


    alter table xxx VOLATILE

    valatile

    • a. 反復(fù)無(wú)常的,揮發(fā)性的

    VOLATILE CARDINALITY or NOT VOLATILE CARDINALITY
    Indicates to the optimizer whether or not the cardinality of table table-name can
    vary significantly at run time. Volatility applies to the number of rows in the
    table, not to the table itself. CARDINALITY is an optional keyword. The default
    is NOT VOLATILE.

    VOLATILE
    Specifies that the cardinality of table table-name can vary significantly at
    run time, from empty to large. To access the table, the optimizer will use
    an index scan (rather than a table scan, regardless of the statistics) if that
    index is index-only (all referenced columns are in the index), or that index
    is able to apply a predicate in the index scan. The list prefetch access method
    will not be used to access the table. If the table is a typed table, this option
    is only supported on the root table of the typed table hierarchy (SQLSTATE 428DR).

    NOT VOLATILE
    Specifies that the cardinality of table-name is not volatile.
    Access plans to this table will continue to be based on existing statistics and
    on the current optimization level.

    NOTE: The keyword could be specified within ALTER TABLE, but not CREATE TABLE.

    ?

    Difference between Local and System Database Directory

    DB2 automatically catalogs databases when they are created. It catalogs an entry
    for the database in the local database directory and another entry in the system
    database directory. If the database is created from a remote client (or a client which
    is executing from a different instance on the same machine), an entry is also made
    in the system database directory at the client instance.

    Databases on the same node as the database manager instance are cataloged as
    indirect entries. Databases on other nodes are cataloged as remote entries.

    List DBs in Local Database Directory

    $ db2 list db directory on /path_to_where_db_created?

    List DBs in System Database Directory

    $ db2 list db directory

    ?

    Illustration of standard tables

    Standard Tables Overview

    Query the status for one specified tablespace?

    As we know, we could issue following command to query status for all of tablespaces in current connected DB.

    $ db2 list tablespaces show detail > /tmp/ts.list

    Then find the status for the tablespaces we concerned.

    Is there's a way to query the status for one specified tablespace?

    My answer is No.?

    1. First, I don't find the related column defination in the table or view:
      • sysibm.systablespaces
      • syscat.tablespaces
    2. Second, I don't think DB2 stores the status flag within syscata tables. The reason is that once a tablespace comes into a special status, it will not be allowed changing any longer(this may also happen on a system catalog tablespace.) that will lead to a conflict on changing the tablespace status flag if stores it within system catalog tables.

    Illustration of the DMS table-space address map

    address map for DMS TS

    DB2 directories and files

    • http://publib.boulder.ibm.com/infocenter/db2luw/v8//topic/com.ibm.db2.udb.doc/admin/c0005420.htm

    Illustration of DB2 architechure and process

    overview for tuning

    Reference

    • http://publib.boulder.ibm.com/infocenter/db2luw/v8//topic/com.ibm.db2.udb.doc/admin/c0005418.htm?

    Tablespaces are put into backup pending after a load

    DB2 sets tablespace as Backup Pending state after loading data into a table in linear logging database(that is, logretain or userexit is on), whatever the load is successful or failed. the reason is that the load process will not write log file. from the begin time of loading to the end time of loading, there will be a blank segment in log file, and the rollforward recovery can Not jump over the blank segment to apply the later log file.

    so database needs a backup after loading to make sure db2 have recovery capicibility.

    it's able to use [COPY YES|NO]? or [NONRECOVERABLE] to prevent tablespace go into Backup Pending state. COPY YES will do the backup automatically after loading, and COPY NO and NONRECOVERABLE will give up this backup that means db2 will be not able to recover the database once an serious error occured.


    繼續(xù)閱讀 "Tablespaces are put into backup pending after a load" 的剩余內(nèi)容

    Come pending when droping Procedures

    Problem Description?

    There's no any response for creating or droping any procedures in DB2. Seems it's pending there, without any error returned. This time UPDATE statement on tables could be issued successfully.

    Check Process

    Check OS disk available

    $ df -kl?

    Check database configure

    db2 => get db cfg |more?

    Check system catalog tablespace?

    db2 => list tablespaces show detail |more
    syscatspace 0x0000?

    Cause?

    It caused by issuing CREATE or DROP statement without COMMIT or ROLLBACK statement in CLP which is in non-Autocommit mode.

    Solution?

    After you issue a COMMIT or a ROLLBACK in the CLP or close it, the pending is gone.

    We must be very careful when we use client in non-Autocommit mode just like CLPs in this case.

    To check the Autocommit mode in CLP issues. Refer to:

    set COMMIT mode in db2 clp

    db2 => list command options

    -c 自動(dòng)落實(shí) OFF

    More?

    From this point, we could get more. Most of strange things like this(pending there and no error return) are caused by locking.

    In this case, it was only the opertation on procedures being pended, so track on this thread to suppose the syscat tables related with procedures are locked then find the what probably causes it.
    ?

    db2 can not create index on local view

    There's an object called index view since MS SQL Server 2000, it's an index which is created on an view which is based on a local table. it is attent to imporve the select performence on the view when this view is based on multi-table and has complex logic.

    I try to find a simular thing in DB2, but there's no the simular solution in DB2 v8.2 for now. Instead, I found another thing instested.

    DB2 allows creating index on the tables or views in remote data source, such as a database on another host or an XML data source. To be exactly, that's Not true Index, it's Index Specification. It requests that the tables in remote data source have created index in its own system. And it only repeat the index description in local system.

    										Local DB2 Env??? ??? ??? ??? ??? ??? ??? ??? ??? ??? ??? Remote DB2 Env
    										

    Index Specification??? ->??? Nickname?? - - ->?? True Index??? ->??? Table

    See following example in DB2 info center.

    • CREATE INDEX statement
      http://publib.boulder.ibm.com/infocenter/db2luw/v8//topic/com.ibm.db2.udb.doc/admin/r0000919.htm?resultof=%22%63%72%65%61%74%65%22%20%22%63%72%65%61%74%22%20%22%69%6e%64%65%78%22%20%22%73%74%61%74%65%6d%65%6e%74%22%20

    Example 3:? The nickname EMPLOYEE references a data source table called CURRENT_EMP. After this nickname was created, an index was defined on CURRENT_EMP. The columns chosen for the index key were WORKDEBT and JOB. Create an index specificationindex. Through this specification, the optimizer will know that the index exists and what its key is. With this information, the optimizer can improve its strategy to access the table. that describes this

       CREATE UNIQUE INDEX JOB_BY_DEPT
    ON EMPLOYEE (WORKDEPT, JOB)
    SPECIFICATION ONLY

    Note: the Nickname is only allowed to be created on tables in local database and on much kind of objects at remote data source. It's not allowed to be created on views in local database.

    set COMMIT mode in db2 clp

    As default, DB2 CLP will do commit after you issue each DB2 statements or SQL automatically.

    If you want to change it instead of issuing COMMIT or ROLLBACK manually, do following.

    SQLLIB\BIN> db2
    db2 => list command options
    ??? -c?? ON
    db2 => update command options using c off
    db2 => list command options
    ??? -c?? OFF

    This change will only exists during this session. The setting will lose when you close this CLP and open CLP next time.

    following cmd will get the same result with above.

    SQLLIB\BIN> db2 list command options
    ??? -c??? ON
    SQLLIB\BIN> db2 +c
    db2 =>
    db2 => list command options
    ??? -c??? OFF
    db2 => quit
    SQLLIB\BIN> db2 list command options
    ??? -c??? ON

    There's also the way to keep the settings forever, do following.

    SQLLIB\BIN\> db2 list command options
    ??? -c?? ON
    SQLLIB\BIN\> db2set db2options=+c
    SQLLIB\BIN\> db2 list command options
    ??? -c?? OFF

    This change will take effection immediately even for others having been opened CLP windows. And will keep along.

    Use following cmd set it back to ON.?

    SQLLIB\BIN> db2set db2opptions=-c

    Reference

    表與索引的重命名 RENAME

    在DB2 中重命名表或者索引

    db2=> RENAME TABLE EMP TO EMPLOYEE
    db2=> RENAME TABLE ABC.EMP TO EMPLOYEE
    db2=> RENAME INDEX NEW-IND TO IND
    db2=> RENAME INDEX ABC.NEW-IND TO IND
    posted @ 2007-03-15 15:00 MyJavaWorld 閱讀(529) | 評(píng)論 (0)編輯 收藏
    三個(gè)UNIX文件時(shí)間ctime、mtime、atime
    ?????? 我曾經(jīng)根據(jù)文件的狀態(tài)在指定時(shí)間內(nèi)是否改變寫(xiě)過(guò)一個(gè)WatchDog來(lái)對(duì)服務(wù)進(jìn)行監(jiān)控,其間曾被這三個(gè)時(shí)間搞混淆,所以覺(jué)得很有必要和大家分享我對(duì)這三個(gè)術(shù)語(yǔ)的理解。
    ????? ctime(change time)改變時(shí)間:是指文件狀態(tài)最后一次被改變的時(shí)間;
    ????? mtime(modification time)修改時(shí)間:是指文件內(nèi)容最后一次被改變的時(shí)間;
    ????? atime(access time)訪問(wèn)時(shí)間:是指文件最后一次被讀取的時(shí)間。
    ????? 前兩者的區(qū)別就在于文件狀態(tài)的改變既包括文件索引節(jié)點(diǎn)的改變,也包括文件內(nèi)容的改變。也就是說(shuō)如果你改變了文件內(nèi)容,則同時(shí)更新了ctime和mtime,但是如果你只改變了文件索引節(jié)點(diǎn)則只是改變了ctime。atime只有在文件被讀取的時(shí)侯才會(huì)改變。它的改變與文件狀態(tài)以及文件內(nèi)容的改變沒(méi)有直接的聯(lián)系。
    ???? 例如:echo “Hello World” >> myfile 則同時(shí)改變了ctime和mtime,atime不變;
    ???? chmod u+x myfile 則只改變了ctime,mtime和atime不變。
    ???? cat myfile,則只改變了atime,ctime和mtime不變
    ???? ps:以上操作均在redhat linux下驗(yàn)證通過(guò)
    posted @ 2007-03-13 17:51 MyJavaWorld 閱讀(1175) | 評(píng)論 (0)編輯 收藏
    ?
    ?
    查看文章
    ?
    DB2/SQL命令大全
    2006-12-25 13:21

    連接數(shù)據(jù)庫(kù):

    ??connect?to?[數(shù)據(jù)庫(kù)名]?user?[操作用戶(hù)名]?using?[密碼]?

    創(chuàng)建緩沖池(8K):

    ??create?bufferpool?ibmdefault8k?IMMEDIATE??SIZE?5000?PAGESIZE?8?K?;
    創(chuàng)建緩沖池(16K)(OA_DIVERTASKRECORD):
    ??create?bufferpool?ibmdefault16k?IMMEDIATE??SIZE?5000?PAGESIZE?16?K?;
    創(chuàng)建緩沖池(32K)(OA_TASK):
    ??create?bufferpool?ibmdefault32k?IMMEDIATE??SIZE?5000?PAGESIZE?32?K?;

    創(chuàng)建表空間:

    ??CREATE?TABLESPACE?exoatbs?IN?DATABASE?PARTITION?GROUP?IBMDEFAULTGROUP?PAGESIZE?8K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoacontainer')?EXTENTSIZE?32?PREFETCHSIZE?16??BUFFERPOOL?IBMDEFAULT8K??OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TABLESPACE?exoatbs16k??IN?DATABASE?PARTITION?GROUP?IBMDEFAULTGROUP?PAGESIZE?16K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoacontainer16k'???)?EXTENTSIZE?32??PREFETCHSIZE?16??BUFFERPOOL?IBMDEFAULT16K??OVERHEAD?24.1?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TABLESPACE?exoatbs32k??IN?DATABASE?PARTITION?GROUP?IBMDEFAULTGROUP?PAGESIZE?32K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoacontainer32k'???)?EXTENTSIZE?32??PREFETCHSIZE?16??BUFFERPOOL?IBMDEFAULT32K??OVERHEAD?24.1?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    GRANT?USE?OF?TABLESPACE?exoatbs?TO?PUBLIC;
    GRANT?USE?OF?TABLESPACE?exoatbs16k?TO?PUBLIC;
    GRANT?USE?OF?TABLESPACE?exoatbs32k?TO?PUBLIC;

    創(chuàng)建系統(tǒng)表空間:

    ??CREATE?TEMPORARY?TABLESPACE?exoasystmp?IN?DATABASE?PARTITION?GROUP?IBMTEMPGROUP?PAGESIZE?8K??MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoasystmp'???)?EXTENTSIZE?32?PREFETCHSIZE?16?BUFFERPOOL?IBMDEFAULT8K??OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TEMPORARY?TABLESPACE?exoasystmp16k?IN?DATABASE?PARTITION?GROUP?IBMTEMPGROUP?PAGESIZE?16K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoasystmp16k'??)?EXTENTSIZE?32?PREFETCHSIZE?16?BUFFERPOOL?IBMDEFAULT16K?OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    ??CREATE?TEMPORARY?TABLESPACE?exoasystmp32k?IN?DATABASE?PARTITION?GROUP?IBMTEMPGROUP?PAGESIZE?32K?MANAGED?BY?SYSTEM?USING?('/home/exoa2/exoasystmp32k')?EXTENTSIZE?32?PREFETCHSIZE?16?BUFFERPOOL?IBMDEFAULT32K?OVERHEAD?24.10?TRANSFERRATE?0.90??DROPPED?TABLE?RECOVERY?OFF;

    1.?啟動(dòng)實(shí)例(db2inst1):

    db2start

    2.?停止實(shí)例(db2inst1):

    db2stop

    3.?列出所有實(shí)例(db2inst1)

    db2ilist

    5.列出當(dāng)前實(shí)例:

    db2?get?instance

    4.?察看示例配置文件:

    db2?get?dbm?cfg|more

    5.?更新數(shù)據(jù)庫(kù)管理器參數(shù)信息:

    db2?update?dbm?cfg?using?para_name?para_value

    6.?創(chuàng)建數(shù)據(jù)庫(kù):

    db2?create?db?test

    7.?察看數(shù)據(jù)庫(kù)配置參數(shù)信息

    db2?get?db?cfg?for?test|more

    8.?更新數(shù)據(jù)庫(kù)參數(shù)配置信息

    db2?update?db?cfg?for?test?using?para_name?para_value

    10.刪除數(shù)據(jù)庫(kù):

    db2?drop?db?test

    11.連接數(shù)據(jù)庫(kù)

    db2?connect?to?test

    12.列出所有表空間的詳細(xì)信息。

    db2?list?tablespaces?show?detail

    13.查詢(xún)數(shù)據(jù):

    db2?select?*?from?tb1

    14.刪除數(shù)據(jù):

    db2?delete?from?tb1?where?id=1

    15.創(chuàng)建索引:

    db2?create?index?idx1?on?tb1(id);

    16.創(chuàng)建視圖:

    db2?create?view?view1?as?select?id?from?tb1

    17.查詢(xún)視圖:

    db2?select?*?from?view1

    18.節(jié)點(diǎn)編目

    db2?catalog?tcp?node?node_name?remote?server_ip?server?server_port

    19.察看端口號(hào)

    db2?get?dbm?cfg|grep?SVCENAME

    20.測(cè)試節(jié)點(diǎn)的附接

    db2?attach?to?node_name

    21.察看本地節(jié)點(diǎn)

    db2?list?node?direcotry

    22.節(jié)點(diǎn)反編目

    db2?uncatalog?node?node_name

    23.數(shù)據(jù)庫(kù)編目

    db2?catalog?db?db_name?as?db_alias?at?node?node_name

    24.察看數(shù)據(jù)庫(kù)的編目

    db2?list?db?directory

    25.連接數(shù)據(jù)庫(kù)

    db2?connect?to?db_alias?user?user_name?using?user_password

    26.數(shù)據(jù)庫(kù)反編目

    db2?uncatalog?db?db_alias

    27.導(dǎo)出數(shù)據(jù)

    db2?export?to?myfile?of?ixf?messages?msg?select?*?from?tb1

    28.導(dǎo)入數(shù)據(jù)

    db2?import?from?myfile?of?ixf?messages?msg?replace?into?tb1

    29.導(dǎo)出數(shù)據(jù)庫(kù)的所有表數(shù)據(jù)

    db2move?test?export

    30.生成數(shù)據(jù)庫(kù)的定義

    db2look?-d?db_alias?-a?-e?-m?-l?-x?-f?-o?db2look.sql

    31.創(chuàng)建數(shù)據(jù)庫(kù)

    db2?create?db?test1

    32.生成定義

    db2?-tvf?db2look.sql

    33.導(dǎo)入數(shù)據(jù)庫(kù)所有的數(shù)據(jù)

    db2move?db_alias?import

    34.重組檢查

    db2?reorgchk

    35.重組表tb1

    db2?reorg?table?tb1

    36.更新統(tǒng)計(jì)信息

    db2?runstats?on?table?tb1

    37.備份數(shù)據(jù)庫(kù)test

    db2?backup?db?test

    38.恢復(fù)數(shù)據(jù)庫(kù)test

    db2?restore?db?test

    399\.列出容器的信息

    db2?list?tablespace?containers?for?tbs_id?show?detail

    40.創(chuàng)建表:

    db2?ceate?table?tb1(id?integer?not?null,name?char(10))

    41.列出所有表

    db2?list?tables

    42.插入數(shù)據(jù):

    db2?insert?into?tb1?values(1,’sam’);

    db2?insert?into?tb2?values(2,’smitty’);

    .?建立數(shù)據(jù)庫(kù)DB2_GCB?

    CREATE?DATABASE?DB2_GCB?ON?G:?ALIAS?DB2_GCB?

    USING?CODESET?GBK?TERRITORY?CN?COLLATE?USING?SYSTEM?DFT_EXTENT_SZ?32?

    2.?連接數(shù)據(jù)庫(kù)?

    connect?to?sample1?user?db2admin?using?8301206?

    3.?建立別名?

    create?alias?db2admin.tables?for?sysstat.tables;?

    CREATE?ALIAS?DB2ADMIN.VIEWS?FOR?SYSCAT.VIEWS?

    create?alias?db2admin.columns?for?syscat.columns;?

    create?alias?guest.columns?for?syscat.columns;?

    4.?建立表?

    create?table?zjt_tables?as?

    (select?*?from?tables)?definition?only;?

    create?table?zjt_views?as?

    (select?*?from?views)?definition?only;?

    5.?插入記錄?

    insert?into?zjt_tables?select?*?from?tables;?

    insert?into?zjt_views?select?*?from?views;?

    6.?建立視圖?

    create?view?V_zjt_tables?as?select?tabschema,tabname?from?zjt_tables;?

    7.?建立觸發(fā)器?

    CREATE?TRIGGER?zjt_tables_del?

    AFTER?DELETE?ON?zjt_tables?

    REFERENCING?OLD?AS?O?

    FOR?EACH?ROW?MODE?DB2SQL?

    Insert?into?zjt_tables1?values(substr(o.tabschema,1,8),substr(o.tabname,1,10))?

    8.?建立唯一性索引?

    CREATE?UNIQUE?INDEX?I_ztables_tabname?

    [size=3]ON?zjt_tables(tabname);?

    9.?查看表?

    select?tabname?from?tables?

    where?tabname='ZJT_TABLES';?

    10.?查看列?

    select?SUBSTR(COLNAME,1,20)?as?列名,TYPENAME?as?類(lèi)型,LENGTH?as?長(zhǎng)度?

    from?columns?

    where?tabname='ZJT_TABLES';?

    11.?查看表結(jié)構(gòu)?

    db2?describe?table?user1.department?

    db2?describe?select?*?from?user.tables?

    12.?查看表的索引?

    db2?describe?indexes?for?table?user1.department?

    13.?查看視圖?

    select?viewname?from?views?

    where?viewname='V_ZJT_TABLES';?

    14.?查看索引?

    select?indname?from?indexes?

    where?indname='I_ZTABLES_TABNAME';?

    15.?查看存貯過(guò)程?

    SELECT?SUBSTR(PROCSCHEMA,1,15),SUBSTR(PROCNAME,1,15)?

    FROM?SYSCAT.PROCEDURES;?

    16.?類(lèi)型轉(zhuǎn)換(cast)?

    ip?datatype:varchar?

    select?cast(ip?as?integer)+50?from?log_comm_failed?

    17.?重新連接?

    connect?reset?

    18.?中斷數(shù)據(jù)庫(kù)連接?

    disconnect?db2_gcb?

    19.?view?application?

    LIST?APPLICATION;?

    20.?kill?application?

    FORCE?APPLICATION(0);?

    db2?force?applications?all?(強(qiáng)迫所有應(yīng)用程序從數(shù)據(jù)庫(kù)斷開(kāi))?

    21.?lock?table

    lock?table?test?in?exclusive?mode?

    22.?共享?

    lock?table?test?in?share?mode?

    23.?顯示當(dāng)前用戶(hù)所有表?

    list?tables?

    24.?列出所有的系統(tǒng)表?

    list?tables?for?system?

    25.?顯示當(dāng)前活動(dòng)數(shù)據(jù)庫(kù)?

    list?active?databases?

    26.?查看命令選項(xiàng)?

    list?command?options?

    27.?系統(tǒng)數(shù)據(jù)庫(kù)目錄?

    LIST?DATABASE?DIRECTORY?

    28.?表空間?

    list?tablespaces?

    29.?表空間容器?

    LIST?TABLESPACE?CONTAINERS?FOR?

    Example:?LIST?TABLESPACE?CONTAINERS?FOR?1?

    30.?顯示用戶(hù)數(shù)據(jù)庫(kù)的存取權(quán)限?

    GET?AUTHORIZATIONS?

    31.?啟動(dòng)實(shí)例?

    DB2START?

    32.?停止實(shí)例?

    db2stop?

    33.?表或視圖特權(quán)?

    grant?select,delete,insert,update?on?tables?to?user?

    grant?all?on?tables?to?user?WITH?GRANT?OPTION?

    34.?程序包特權(quán)?

    GRANT?EXECUTE?

    ON?PACKAGE?PACKAGE-name?

    TO?PUBLIC?

    35.?模式特權(quán)?

    GRANT?CREATEIN?ON?SCHEMA?SCHEMA-name?TO?USER?

    36.?數(shù)據(jù)庫(kù)特權(quán)?

    grant?connect,createtab,dbadm?on?database?to?user?

    37.?索引特權(quán)?

    grant?control?on?index?index-name?to?user?

    38.?信息幫助?(??XXXnnnnn?)?

    例:??SQL30081?

    39.?SQL?幫助(說(shuō)明?SQL?語(yǔ)句的語(yǔ)法)?

    help?statement?

    例如,help?SELECT?

    40.?SQLSTATE?幫助(說(shuō)明?SQL?的狀態(tài)和類(lèi)別代碼)?

    ??sqlstate?或???class-code?

    41.?更改與"管理服務(wù)器"相關(guān)的口令?

    db2admin?setid?username?password?

    42.?創(chuàng)建?SAMPLE?數(shù)據(jù)庫(kù)?

    db2sampl?

    db2sampl?F:(指定安裝盤(pán))?

    43.?使用操作系統(tǒng)命令?

    !?dir?

    44.?轉(zhuǎn)換數(shù)據(jù)類(lèi)型?(cast)?

    SELECT?EMPNO,?CAST(RESUME?AS?VARCHAR(370))?

    FROM?EMP_RESUME?

    WHERE?RESUME_FORMAT?=?'ascii'?

    45.?UDF

    要運(yùn)行?DB2?Java?存儲(chǔ)過(guò)程或?UDF,還需要更新服務(wù)器上的?DB2?數(shù)據(jù)庫(kù)管理程序配置,以包括在該機(jī)器上安裝?JDK?的路徑?

    db2?update?dbm?cfg?using?JDK11_PATH?d:sqllibjavajdk?

    TERMINATE?

    update?dbm?cfg?using?SPM_NAME?sample?

    46.?檢查?DB2?數(shù)據(jù)庫(kù)管理程序配置?

    db2?get?dbm?cfg?

    47.?檢索具有特權(quán)的所有授權(quán)名?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'DATABASE'?FROM?SYSCAT.DBAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'TABLE?'?FROM?SYSCAT.TABAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'PACKAGE?'?FROM?SYSCAT.PACKAGEAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'INDEX?'?FROM?SYSCAT.INDEXAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'COLUMN?'?FROM?SYSCAT.COLAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'SCHEMA?'?FROM?SYSCAT.SCHEMAAUTH?

    UNION?

    SELECT?DISTINCT?GRANTEE,?GRANTEETYPE,?'SERVER?'?FROM?SYSCAT.PASSTHRUAUTH?

    ORDER?BY?GRANTEE,?GRANTEETYPE,?3?

    create?table?yhdab?

    (id?varchar(10),?

    password?varchar(10),?

    ywlx?varchar(10),?

    kh?varchar(10));?

    create?table?ywlbb?

    (ywlbbh?varchar(8),?

    ywmc?varchar(60))?

    48.?修改表結(jié)構(gòu)?

    alter?table?yhdab?ALTER?kh?SET?DATA?TYPE?varchar(13);?

    alter?table?yhdab?ALTER?ID?SET?DATA?TYPE?varchar(13);?

    alter?table?lst_bsi?alter?bsi_money?set?data?type?int;?

    insert?into?yhdab?values?

    ('20000300001','123456','user01','20000300001'),?

    ('20000300002','123456','user02','20000300002');?

    49.?業(yè)務(wù)類(lèi)型說(shuō)明?

    insert?into?ywlbb?values?

    ('user01','業(yè)務(wù)申請(qǐng)'),?

    ('user02','業(yè)務(wù)撤消'),?

    ('user03','費(fèi)用查詢(xún)'),?

    ('user04','費(fèi)用自繳'),?

    ('user05','費(fèi)用預(yù)存'),?

    ('user06','密碼修改'),?

    ('user07','發(fā)票打印'),?

    ('gl01','改用戶(hù)基本信息'),?

    ('gl02','更改支付信息'),?

    ('gl03','日統(tǒng)計(jì)功能'),?

    ('gl04','沖帳功能'),?

    ('gl05','對(duì)帳功能'),?

    ('gl06','計(jì)費(fèi)功能'),?

    ('gl07','綜合統(tǒng)計(jì)')?

    備份數(shù)據(jù)庫(kù):
    CONNECT?TO?EXOA;
    QUIESCE?DATABASE?IMMEDIATE?FORCE?CONNECTIONS;
    CONNECT?RESET;
    BACKUP?DATABASE?EXOA?TO?"/home/exoa2/db2bak/"?WITH?2?BUFFERS?BUFFER?1024?PARALLELISM?1?WITHOUT?PROMPTING;
    CONNECT?TO?EXOA;
    UNQUIESCE?DATABASE;
    CONNECT?RESET;

    以下是小弟在使用db2move中的一些經(jīng)驗(yàn),希望對(duì)大家有所幫助。?

    ?db2???connect???to??YOURDB???
    連接數(shù)據(jù)庫(kù)?

    ?db2look?-d??YOURDB??-a?-e?-x?-o?creatab.sql?
    導(dǎo)出建庫(kù)表的SQL?

    ?db2move???YOURDB??export?
    用db2move將數(shù)據(jù)備份出來(lái)?

    ?vi???creatab.sql?
    如要導(dǎo)入的數(shù)據(jù)庫(kù)名與原數(shù)據(jù)庫(kù)不同,要修改creatab.sql中CONNECT?項(xiàng)?
    如相同則不用更改?

    ?db2move??NEWDB??load?
    將數(shù)據(jù)導(dǎo)入新庫(kù)中?

    在導(dǎo)入中可能因?yàn)榉N種原因發(fā)生中斷,會(huì)使數(shù)據(jù)庫(kù)暫掛?
    db2????list?tablespaces???show???detail?
    如:?
    ??????詳細(xì)說(shuō)明:?
    ?????裝入暫掛?
    ?總頁(yè)數(shù)??????????????????????????=?1652?
    ?可用頁(yè)數(shù)????????????????????????=?1652?
    ?已用頁(yè)數(shù)?????????????????????????=?1652?
    ?空閑頁(yè)數(shù)?????????????????????????=?不適用?
    ?高水位標(biāo)記(頁(yè))?????????????????=?不適用?
    ?頁(yè)大?。ㄗ止?jié))???????????????????=?4096?
    ?盤(pán)區(qū)大?。?yè))???????????????????=?32?
    ?預(yù)讀取大小(頁(yè))?????????????????=?32?
    ?容器數(shù)???????????????????????????=?1?
    ?狀態(tài)更改表空間標(biāo)識(shí)????????????????????=?2?
    ?狀態(tài)更改對(duì)象標(biāo)識(shí)??????????????????????=?59?

    ?db2?select?tabname,tableid?from?syscat.tables?where?tableid=59?
    查看是哪張表掛起?

    表名知道后到db2move.lst(在db2move??YOURDB??export的目錄中)中找到相應(yīng)的.ixf文件?
    ?db2?load?from?tab11.ixf?of?ixf?terminate?into?db2admin.xxxxxxxxx?
    tab11.ixf對(duì)應(yīng)的是xxxxxxxxx表?

    數(shù)據(jù)庫(kù)會(huì)恢復(fù)正常,可再用db2?list?tablespaces?show?detail查看

    30.不能通過(guò)GRANT授權(quán)的權(quán)限有哪種?

    SYSAM

    SYSCTRL

    SYSMAINT

    要更該述權(quán)限必須修改數(shù)據(jù)庫(kù)管理器配置參數(shù)

    31.表的類(lèi)型有哪些?

    永久表(基表)

    臨時(shí)表(說(shuō)明表)

    臨時(shí)表(派生表)

    32.如何知道一個(gè)用戶(hù)有多少表?

    SELECT*FROMSYSIBM.SYSTABLESWHERECREATOR='USER'

    33.如何知道用戶(hù)下的函數(shù)?

    select*fromIWH.USERFUNCTION

    select*fromsysibm.SYSFUNCTIONS

    34.如何知道用戶(hù)下的VIEW數(shù)?

    select*fromsysibm.sysviewsWHERECREATOR='USER'

    35.如何知道當(dāng)前DB2的版本?

    select*fromsysibm.sysvERSIONS

    36.如何知道用戶(hù)下的TRIGGER數(shù)?

    select*fromsysibm.SYSTRIGGERSWHERESCHEMA='USER'

    37.如何知道TABLESPACE的狀況?

    select*fromsysibm.SYSTABLESPACES

    38.如何知道SEQUENCE的狀況?

    select*fromsysibm.SYSSEQUENCES

    39.如何知道SCHEMA的狀況?

    select*fromsysibm.SYSSCHEMATA

    40.如何知道INDEX的狀況?

    select*fromsysibm.SYSINDEXES

    41.如何知道表的字段的狀況?

    select*fromsysibm.SYSCOLUMNSWHERETBNAME='AAAA'

    42.如何知道DB2的數(shù)據(jù)類(lèi)型?

    select*fromsysibm.SYSDATATYPES

    43.如何知道BUFFERPOOLS狀況?

    select*fromsysibm.SYSBUFFERPOOLS

    44.DB2表的字段的修改限制?

    只能修改VARCHAR2類(lèi)型的并且只能增加不能減少.

    45.如何查看表的結(jié)構(gòu)?

    DESCRIBLETABLETABLE_NAME

    OR

    DESCRIBLESELECT*FROMSCHEMA.TABLE_NAME

    ?
    ?

    ? ? ?
    ?
    posted @ 2006-12-28 16:57 MyJavaWorld 閱讀(2763) | 評(píng)論 (0)編輯 收藏

    DB2 UDB中用戶(hù)出口程序是如何工作的?

    ?

    采用用戶(hù)出口程序與DB2 UDB共同工作背后的基本思想是提供一種歸檔和檢索數(shù)據(jù)庫(kù)日志文件的方法以實(shí)現(xiàn)日志冗余處理并從易失性介質(zhì)上轉(zhuǎn)儲(chǔ)出來(lái)。重要的,值得注意的是,根據(jù)你的特殊需求,在用戶(hù)出口程序當(dāng)中,除了能實(shí)現(xiàn)歸檔和檢索日志之外,你還可以實(shí)現(xiàn)其他的操作。

    ?

    如果一個(gè)數(shù)據(jù)庫(kù)需要采用歸檔日志文件來(lái)進(jìn)行恢復(fù),在DB2 UDB中實(shí)行用戶(hù)出口程序策略將不能恢復(fù)100%的事務(wù)。用戶(hù)出口程序只是一種通過(guò)拷貝已經(jīng)存在的日志文件到一個(gè)安全的地方來(lái)為其提供更多保護(hù)的方法。它是數(shù)據(jù)完整性策略中的一部分,而且是重要的一部分。

    ?

    編譯了用戶(hù)出口程序之后,可執(zhí)行程序db2uext2被放置在數(shù)據(jù)庫(kù)管理器可以找到的目錄當(dāng)中。在UNIX?中,這個(gè)目錄是/sqllib/adm;在Windows?中,是Program FilesIBMSQLLIBBIN。

    ?

    除非數(shù)據(jù)庫(kù)管理器知道用戶(hù)出口程序是可用的,不然它不會(huì)調(diào)用db2uext2。讓數(shù)據(jù)庫(kù)管理器知道db2uext2可以被調(diào)用的唯一方法是將數(shù)據(jù)庫(kù)配置參數(shù)userexit設(shè)置為on。一旦這個(gè)參數(shù)被設(shè)定好而且DB2實(shí)例被重復(fù)利用了,數(shù)據(jù)庫(kù)管理器將每五分鐘調(diào)用一次用戶(hù)出口程序來(lái)檢查那些可以被歸檔到程序相關(guān)的歸檔目錄的日志文件。

    ?

    如果數(shù)據(jù)庫(kù)的恢復(fù)是必要的,在前滾操作期間,數(shù)據(jù)庫(kù)管理器將調(diào)用db2uext2把歸檔日志文件拷貝回活動(dòng)的日志目錄當(dāng)中。然后,日志文件被再次運(yùn)用到重建的數(shù)據(jù)庫(kù)中。

    ?

    讓我們看看被數(shù)據(jù)庫(kù)管理器生成的到用戶(hù)出口程序的調(diào)用的格式。注意,這一信息也可以在用戶(hù)出口示例程序的注釋部分找到。

    db2uext2 -OS -RL

    -RQ -DB -NN

    -LP -LN [-AP]

    ?

    其中:

    os=操作系統(tǒng)

    release=DB2發(fā)行版本

    request= 'ARCHIVE' 或 'RETRIEVE'

    dbname=數(shù)據(jù)庫(kù)名

    nodenumber=節(jié)點(diǎn)號(hào)

    logpath=日志文件目錄

    logname=日志文件名

    logsize=日志文件大?。蛇x)

    startingpage=以4k頁(yè)為單位的起始偏移量(可選)

    adsmpasswd=ADSM密碼(可選)

    ?

    注意:只有當(dāng)logpath為裸設(shè)備時(shí)才使用logsize和startingpage。

    ?

    歸檔或者從磁盤(pán)檢索日志文件遵從以下命名規(guī)則:

    歸檔:歸檔路徑+數(shù)據(jù)庫(kù)名+節(jié)點(diǎn)號(hào)+日志文件名

    檢索:檢索路徑+數(shù)據(jù)庫(kù)名+節(jié)點(diǎn)號(hào)+日志文件名

    ?

    比如:如果歸檔的路徑為”c:mylogs”,

    檢索路徑是“c:mylogs”,

    數(shù)據(jù)庫(kù)名是“SAMPLE”,

    節(jié)點(diǎn)號(hào)是 NODE0000,

    文件名是 S0000001.LOG,

    日志文件將是:

    歸檔到 - c:mylogsSAMPLENODE0000S0000001.LOG

    檢索自 - c:mylogsSAMPLENODE0000S0000001.LOG

    以下描述了用戶(hù)出口程序中的邏輯是如何運(yùn)轉(zhuǎn)的:

    1)? 安裝信號(hào)處理程序。

    2)? 驗(yàn)證傳遞的參數(shù)個(gè)數(shù)。

    3)? 驗(yàn)證操作請(qǐng)求。

    4)? 開(kāi)始審計(jì)跟蹤(如果有此請(qǐng)求)。

    5)? 根據(jù)操作需求的不同獲取以下路徑中的一個(gè):

    a)? 如果操作需求為歸檔一個(gè)文件,將日志文件從日志路徑拷貝到歸檔路徑中。

    i) 如果沒(méi)有找到日志文件,執(zhí)行第6點(diǎn)。

    ?

    b)? 如果操作需求是檢索一個(gè)文件,將日志文件從檢索路徑拷貝到日志路徑中。

    i) 如果沒(méi)有找到日志文件,執(zhí)行第6點(diǎn)。

    6) 將錯(cuò)誤記入日志(如果要求或者有需要的話)。

    7)? 結(jié)束審計(jì)跟蹤(如果有請(qǐng)求)。

    8)? 以適當(dāng)?shù)姆祷卮a退出。

    ?

    手工調(diào)用用戶(hù)出口程序來(lái)歸檔日志文件是可以的,但最好還是使用ARCHIVE LOG命令以便在定義以上參數(shù)時(shí)不會(huì)因?yàn)槟愕脑驅(qū)е洛e(cuò)誤。在這篇文章的末尾,可以找到關(guān)于ARCHIVE LOG命令的鏈接。

    ?

    日志文件術(shù)語(yǔ)

    ?

    DB2 中用戶(hù)出口程序的基本功能是將日志文件拷貝到活動(dòng)日志目錄或反之。這里,值得指出一些術(shù)語(yǔ)來(lái)闡明活動(dòng)的日志目錄被置于何處以及數(shù)據(jù)庫(kù)日志文件的狀態(tài)如何。

    ?

    活動(dòng)日志目錄:

    ?

    該目錄被置于你的數(shù)據(jù)庫(kù)目錄中。在Windows中,如果在C:中創(chuàng)建了一個(gè)叫做SAMPLE的單一數(shù)據(jù)庫(kù)且實(shí)例名為db2inst1,則將會(huì)出現(xiàn)以下的目錄結(jié)構(gòu):

    ?

    C:DB2INST1NODE0000SQL000001SQLOGDIR

    ?

    SQL00001是SAMPLE數(shù)據(jù)庫(kù)的數(shù)據(jù)庫(kù)目錄,SQLOGDIR 是活動(dòng)日志目錄。

    ?

    以下的圖1顯示了Windows操作系統(tǒng)上的活動(dòng)日志目錄:

    PATH o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" />SHAPE id=_x0000_i1025 style="WIDTH: 299.25pt; HEIGHT: 180.75pt" type="#_x0000_t75" />/P>

    ?

    圖 1活動(dòng)日志目錄

    日志文件狀態(tài)

    ?

    在活動(dòng)日志目錄中,日志文件可以是活動(dòng)日志,也可以是聯(lián)機(jī)歸檔日志。活動(dòng)日志是那些被 DB2 用于當(dāng)前事務(wù)處理和崩潰恢復(fù)的日志。聯(lián)機(jī)歸檔日志是那些 DB2 UDB 進(jìn)行常規(guī)處理時(shí)不再需要,而進(jìn)行數(shù)據(jù)庫(kù)恢復(fù)時(shí)可能還會(huì)需要的日志。當(dāng)實(shí)現(xiàn)用戶(hù)出口程序時(shí),這些聯(lián)機(jī)歸檔日志將最終以歸檔日志目錄中的副本形式出現(xiàn)。

    ?

    既然 DB2 UDB 中用戶(hù)出口程序的目的是將數(shù)據(jù)庫(kù)日志拷貝到歸檔目錄中,你將最終在活動(dòng)日志目錄(缺省為 SQLOGDIR)中得到重復(fù)的日志文件。你可能考慮刪除這些重復(fù)的聯(lián)機(jī)歸檔日志以釋放文件系統(tǒng)空間。在從數(shù)據(jù)庫(kù)目錄中除去這些日志之前,要十分小心地確認(rèn)它們是否已經(jīng)將成功地被復(fù)制到歸檔目錄中。還必須確保數(shù)據(jù)庫(kù)管理器進(jìn)行崩潰恢復(fù)時(shí)不再需要它們。要確定你的活動(dòng)日志目錄中哪些日志文件不為正常處理所需要,可用通過(guò)以下命令檢查數(shù)據(jù)庫(kù)配置:

    ????????

    ???? db2 "get db cfg for sample"

    ?

    這條命令的數(shù)據(jù)庫(kù)配置輸出結(jié)果將包含第一個(gè)活動(dòng)日志文件,如:

    First active log file = S000009.LOG

    ?

    在如上所示的輸出當(dāng)中,日志文件S000009.LOG是數(shù)據(jù)庫(kù)當(dāng)前的活動(dòng)日志。任何編號(hào)比該日志文件小的日志文件都被看作聯(lián)機(jī)歸檔日志。

    ?

    這里有一個(gè)例子:

    ?

    在這個(gè)場(chǎng)景中,活動(dòng)日志目錄中有日志文件 S000000.LOG - S000009.LOG,歸檔日志目錄中有 S000000.LOG - S000008.LOG。因?yàn)?S000009.LOG 是第一個(gè)活動(dòng)日志文件,所以,可以從活動(dòng)日志目錄中移走 S000001.LOG - S000008.LOG 以釋放磁盤(pán)空間。S000009.LOG 文件必須保留在活動(dòng)日志目錄中,因?yàn)樗匀槐划?dāng)前事務(wù)使用。

    ?

    同樣可以通過(guò)檢查數(shù)據(jù)庫(kù)歷史文件來(lái)查看活動(dòng)日志目錄中哪些日志文件不再有用。以下命令將列出數(shù)據(jù)庫(kù)備份信息:

    ?

    ???? db2 "list history backup all for database sample"

    ?

    以下是該命令的輸出結(jié)果的一個(gè)例子:

    ?

    List History File for sample

    Number of matching file entries = 4

    Op Obj Timestamp+Sequence Type Dev Earliest Log Current? Log

    -- --- ------------------ ---- --- ------------------------

    B D 20030416162026001 F D S0000010.LOGS0000014.LOG

    ------------------------------------------------------------

    Contains 2 tablespace(s):

    00001 SYSCATSPACE

    00002 USERSPACE1

    ------------------------------------------------------------

    ?

    在上面的輸出中,最早的日志將表示,需要 S0000010.LOG 及其之后的任何日志。 S00000010.LOG 之前的任何日志可以被安全的刪除。再次提醒,在從活動(dòng)日志目錄中刪除日志文件之前,驗(yàn)證在活動(dòng)日志目錄中存在這些日志文件的拷貝是十分重要的。

    ?

    雖然可以手動(dòng)的從活動(dòng)日志目錄中刪除日志文件,刪除聯(lián)機(jī)歸檔日志文件的安全方法是通過(guò)prune logfile命令。該命令可以用來(lái)刪除活動(dòng)歸檔目錄中的日志文件。在下面的示例中,以下命令將刪除日志文件 S000000.LOG - S000008.LOG:

    ???? db2 "prune logfile prior to S000009.LOG"

    ?

    注意:根據(jù)您的恢復(fù)策略,可能會(huì)出現(xiàn)之前的前滾操作在數(shù)據(jù)庫(kù)上執(zhí)行的場(chǎng)景。歸檔目錄中的老日志文件可能被同名的新日志文件所覆蓋,從而阻止你使用舊日志文件對(duì)數(shù)據(jù)庫(kù)進(jìn)行時(shí)間點(diǎn)恢復(fù)。對(duì)用戶(hù)出口程序的設(shè)計(jì)程序員來(lái)說(shuō),考慮類(lèi)似這樣的情況是很重要的。

    ?

    設(shè)置用戶(hù)出口

    ?

    在本文中,我們將采用DB2提供的db2uext2.cdisk樣例c程序,它位于你的c目錄當(dāng)中。在UNIX中,c目錄位于/sqllib/samples。Windows中,這目錄位于Program Files/IBM//samples。

    ?

    在Windows中設(shè)置用戶(hù)出口

    ?

    修改和編譯用戶(hù)出口程序

    1.? 創(chuàng)建名為C:mylogs的目錄

    2.? 將C:Program filesIBMSQLLIBsamplescdb2uext2.cdisk拷貝到一個(gè)工作目錄當(dāng)中

    3.? 對(duì)于本示例,用戶(hù)出口程序的以下部分應(yīng)該得以驗(yàn)證以反映路徑 c:\mylogs\

    ?

    #define ARCHIVE_PATH "c:\mylogs\"

    #define RETRIEVE_PATH "c:\mylogs\"

    #define AUDIT_ACTIVE 1 /* enable audit trail logging */

    #define ERROR_ACTIVE 1 /* enable error trail logging */

    #define AUDIT_ERROR_PATH "c:\mylogs\"

    ???????????????? /* path must end with a slash */

    #define AUDIT_ERROR_ATTR "a" /* append to text file */

    #define BUFFER_SIZE 32

    ??? /* # of 4K pages for output buffer */

    ?

    4.? 確定在你的系統(tǒng)中安裝了被支持的C編譯器(比如,Microsoft Visual Studio)而且環(huán)境中有該編譯器的路徑。

    5.? 通過(guò)命令行,將db2uext2.cdisk更名為db2uext2.c并構(gòu)建:

    cl db2uext2.c

    一旦程序被編譯,將創(chuàng)建db2uext2.exe和db2uext2.obj文件。

    6.? 將可執(zhí)行文件db2uext2.exe放到/SQLLIB/BIN目錄當(dāng)中從而使數(shù)據(jù)庫(kù)管理器能夠定位并執(zhí)行它用以歸檔和檢索日志。

    ?

    為用戶(hù)出口創(chuàng)建并準(zhǔn)備數(shù)據(jù)庫(kù)

    7.? 在 DB2 命令窗口中用 db2sampl 命令創(chuàng)建 SAMPLE 數(shù)據(jù)庫(kù)。這將使你對(duì)下面的示例使用樣本表。

    db2sampl

    8.? 更新數(shù)據(jù)庫(kù)配置文件以便為數(shù)據(jù)庫(kù)打開(kāi)用戶(hù)出口。請(qǐng)注意:只能為一個(gè)數(shù)據(jù)庫(kù)分配用戶(hù)出口程序,因?yàn)?bin 目錄被所有 DB2 實(shí)例共享。

    db2 "update db cfg for sample using userexit on"

    db2stop force

    <span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: black; FONT-FAMILY: 宋體; mso-hansi-font-family: 'Times New Roman'; mso-bidi-font-family: 宋體; mso-

    /P>
    posted @ 2006-12-08 18:12 MyJavaWorld 閱讀(418) | 評(píng)論 (0)編輯 收藏
    其實(shí)主要的就是要?jiǎng)?chuàng)建一個(gè)密鑰倉(cāng)庫(kù)以管理您的公鑰 / 私鑰對(duì)來(lái)自您所信任實(shí)體的證書(shū)。
    ?
    第一步:生成密鑰對(duì)
    您首先要做的是創(chuàng)建一個(gè)密鑰倉(cāng)庫(kù)和生成密鑰對(duì)。您可以使用以下命令: ?
    keytool -genkey -keyalg RSA -keysize 512 -dname "cn=hyq,o=eagle,c=cn" -alias weblogic -keypass 123456 -keystore C:/mykeystore/weblogic.jks -storepass 123456 -validity 365

    (請(qǐng)注意:鍵入該命令時(shí)必須使其成為一行。此處用多行來(lái)顯示,主要是為了可讀性。)如下圖:
    Snap2.gif

    該命令將在 ?C? 盤(pán)的 “mykeystore” 目錄中創(chuàng)建名為 “weblogic.jks” 的密鑰倉(cāng)庫(kù),并賦予它口令 123456 。它將為實(shí)體生成公鑰 / 私鑰對(duì),該實(shí)體的 特征名 為:常用名 “hyq” 、組織 “eagle” 和兩個(gè)字母的國(guó)家代碼 “cn” ?!?/span> -keyalg ”指定它使用的是那種密鑰生成算法來(lái)創(chuàng)建密鑰,缺省的是 “DSA” 密鑰生成算法(會(huì)使用缺省的 ?DSA? ?SHA1” 簽名算法),兩個(gè)密鑰(公鑰與私鑰)的長(zhǎng)度是 512 位,由 -keysize 來(lái)指定,默認(rèn)的是 1024? 位。 ? 該證書(shū)包括公鑰和特征名信息。該證書(shū)的有效期為 365 天,由 -validity 來(lái)指定,且與別名 “business” 所代表的密鑰倉(cāng)庫(kù)項(xiàng)關(guān)聯(lián)。私鑰被賦予口令 123456

    ?

    命令行里 DName 信息注解

    ?

    DN 信息域

    含義

    CN

    域名或 IP

    OU

    部門(mén),沒(méi)有部門(mén)的可不要此項(xiàng)

    O

    單位名稱(chēng)

    L

    單位地址

    S

    省份的拼音(第一個(gè)字母大寫(xiě))

    C

    國(guó)家的簡(jiǎn)寫(xiě) ( CN 代表中國(guó))


    如果采用選項(xiàng)的缺省值,可以大大縮短該命令。實(shí)際上,這些選項(xiàng)并不是必需的;對(duì)于有缺省值的選項(xiàng),未指定時(shí)將使用缺省值,對(duì)于任何被要求的值,您將會(huì)得到要求輸入它的提示。例如:輸入命令 keytool -genkey -keystore "C:/tone.jks" -storepass 123456 -keyalg RSA ,就會(huì)有如下提示:
    Snap3.gif


    注意:這里的
    密鑰倉(cāng)庫(kù)路徑一定要存在,如果不存在的話,它就會(huì)拋如下的異常

    Snap4.gif
    第二步
    : 產(chǎn)生證書(shū)請(qǐng)求certreq.pem 文件

    使用如下命令:

    keytool -certreq -alias weblogic -sigalg "MD5withRSA" -file C:/mykeystore/certreq.pem -keypass 123456 -keystore C:/mykeystore/weblogic.jks -storepass 123456

    Snap5.gif
    這樣在
    C:/mykeystore/ 目錄下 就會(huì)產(chǎn)生一個(gè) certreq.pem 文件,內(nèi)容如下:

    -----BEGIN NEW CERTIFICATE REQUEST-----

    MIHlMIGQAgEAMCsxCzAJBgNVBAYTAmNuMQ4wDAYDVQQKEwVlYWdsZTEMMAoGA1UEAxMDaHlxMFww

    DQYJKoZIhvcNAQEBBQADSwAwSAJBAMhaIG2Ki7+RwZUP4gPBdTbnY38bisW16u1XUyysPxdNwSie

    aSd6E3Hm277E7NjHoz56ZoaYdPPDmdiTkMrS9rcCAwEAAaAAMA0GCSqGSIb3DQEBBAUAA0EAYRNl

    l5dyGgV9hhu++ypcJNQTrDIwjx1QT4fgVubrtIaHU0fzHamD5QG6PYddw9TL51XQHvu6tOS0NUc/

    ItNKJw==

    -----END NEW CERTIFICATE REQUEST-----

    第三步:這就相對(duì)來(lái)說(shuō)簡(jiǎn)單多了,就是CA提交證書(shū)請(qǐng)求。
    ??? 你可以隨便從網(wǎng)上找一家免費(fèi)的CA認(rèn)證適用機(jī)構(gòu)(很多的),然后按照上面的提示進(jìn)行操作就可以了,這一步就要用到前面生成的certreq.pem 文件了。(注意:一定要下載根證書(shū))
    ??? 將生成的證書(shū)和下載的根證書(shū)放至你比較容易找到的位置,我一般將它們和生成的jks文件放到一起。

    第四步:導(dǎo)入證書(shū)
    ??? 通過(guò)命令:keytool -import -alias RootCA -trustcacerts -file C:/mykeystore/RootCADemo.cer -keystore C:/mykeystore/weblogic.jks -storepass 123456將根證書(shū)導(dǎo)入第一步生成的weblogic.jks中,接著將所有其它的證書(shū)按照此命令全部導(dǎo)入。(注意證書(shū)的別名不能重復(fù),同時(shí)一定注意要用上 -trustcacerts,否則,你在以后使用時(shí),它將會(huì)認(rèn)為你導(dǎo)入的這些證書(shū)是不可信任的 ,就會(huì)導(dǎo)致你在配置SSL時(shí)不能正常的工作。)
    ??? 這就全部完成了密鑰倉(cāng)庫(kù)的創(chuàng)建。然后就可以在支持這些證書(shū)格式的服務(wù)器上使用了。下一篇將會(huì)寫(xiě)一下在weblogic上如何配置雙向SSL

    posted @ 2006-10-31 17:18 MyJavaWorld 閱讀(455) | 評(píng)論 (0)編輯 收藏
    主站蜘蛛池模板: 好吊妞788免费视频播放| 久久久久久久尹人综合网亚洲 | 成人婷婷网色偷偷亚洲男人的天堂 | 亚洲AⅤ视频一区二区三区| 伊人久久五月丁香综合中文亚洲| 久99久精品免费视频热77| 中文字幕亚洲不卡在线亚瑟| 国产精品亚洲а∨无码播放不卡 | 最近最好最新2019中文字幕免费| 亚洲午夜国产精品无码老牛影视 | 亚洲精品人成在线观看| 99精品视频在线观看免费| 亚洲国产精品无码久久青草| 久久亚洲AV成人无码国产最大| 永久免费AV无码国产网站 | 狼人大香伊蕉国产WWW亚洲 | 国外亚洲成AV人片在线观看| 曰批免费视频播放免费| 国产在线观看免费完整版中文版| 亚洲色欲色欲www在线播放| 麻豆最新国产剧情AV原创免费| 亚洲精品动漫在线| 在线观看www日本免费网站| 色婷婷亚洲十月十月色天| 性无码免费一区二区三区在线| 亚洲AV无码一区东京热久久| 99精品全国免费观看视频..| 亚洲精品国产精品乱码视色| 成人妇女免费播放久久久| 永久亚洲成a人片777777| fc2成年免费共享视频18| 亚洲毛片av日韩av无码| 一级做a爰性色毛片免费| 国产亚洲精品a在线观看| AAAAA级少妇高潮大片免费看| 亚洲精品无码成人片久久| 精品国产一区二区三区免费| 亚洲精品私拍国产福利在线| 久久久久久成人毛片免费看 | 亚洲日韩国产精品无码av| 99视频精品全部免费观看|