<<OCM实验选讲>> 第三课 网络配置 实验

来源:互联网 发布:网络ip地址怎么修改 编辑:程序博客网 时间:2024/05/16 08:56

1.配置监听的非默认端口1621。

配置非默认端口的监听, 需要设置local_listener参数, 该参数需要在tnsnames.ora文件进行配置. 由于监听使用了非默认端口, 可用alter system register实时向PMON动态注册.

若listener.ora文件配置的监听名字不是默认的LISTENER, 则启动或停止监听需要显示指定监听名字(lsnrctl start/stop LIS16).

详细配置如下:

[oracle@localhost admin]$ echo $ORACLE_HOME
/home/oracle/oracle/product/10.2.0/db_1
[oracle@localhost admin]$ pwd
/home/oracle/oracle/product/10.2.0/db_1/network/admin
[oracle@localhost admin]$ cat listener.ora
LIS16=
 (DESCRIPTION=
  (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1621))
)
[oracle@localhost admin]$ cat tnsnames.ora
TNS16=
 (DESCRIPTION=
  (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1621))
)


PROD16=
 (DESCRIPTION=
  (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1621))
  ( CONNECT_DATA=(SID=PROD))
)
[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 5 19:53:30 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> show parameter local_listener

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
local_listener                 string     TNS16
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@localhost admin]$ lsnrctl status LIS16

LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JAN-2014 19:53:53

Copyright (c) 1991, 2005, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1621)))
STATUS of the LISTENER
------------------------
Alias                     LIS16
Version                   TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date                05-JAN-2014 19:48:17
Uptime                    0 days 0 hr. 5 min. 35 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /home/oracle/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File         /home/oracle/oracle/product/10.2.0/db_1/network/log/lis16.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1621)))
Services Summary...
Service "PROD" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
Service "PROD_XPT" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@localhost admin]$ tnsping PROD16

TNS Ping Utility for Linux: Version 10.2.0.1.0 - Production on 05-JAN-2014 19:54:01

Copyright (c) 1997, 2005, Oracle.  All rights reserved.

Used parameter files:


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1621)) ( CONNECT_DATA=(SID=PROD)))
OK (0 msec)
[oracle@localhost admin]$ sqlplus scott/tiger@PROD16

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 5 19:54:08 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Error accessing PRODUCT_USER_PROFILE
Warning:  Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@localhost admin]$ sqlplus scott/tiger@TNS16

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 5 20:00:43 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

ERROR:
ORA-12504: TNS:listener was not given the SID in CONNECT_DATA


Enter user-name:
[oracle@localhost admin]$


参考:

配置非默认端口的动态服务注册

http://blog.csdn.net/leshami/article/details/5925526


--EOF--


2.配置客户端连接数据库的tnsnames.ora文件,并测试连接成功。

请参看第一题.


--EOF--


3.创建新的UNDO表空间,并使用它。

[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 5 20:04:23 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> show parameter undo

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
undo_management              string     AUTO
undo_retention                 integer     900
undo_tablespace              string     undotbs
SQL> set linesize 200
SQL> col file_name for a80
SQL> select file_name from dba_data_files where tablespace_name='UNDOTBS';

FILE_NAME
--------------------------------------------------------------------------------
/home/oracle/oracle/oradata/PROD/undotbs01.dbf

SQL> CREATE UNDO TABLESPACE undotbs_02  DATAFILE '/home/oracle/oracle/oradata/PROD/undo0201.dbf' SIZE 2M REUSE AUTOEXTEND ON;

Tablespace created.

SQL> ALTER SYSTEM SET UNDO_TABLESPACE = undotbs_02 scope=both;

System altered.

SQL> show parameter undo

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
undo_management              string     AUTO
undo_retention                 integer     900
undo_tablespace              string     UNDOTBS_02
SQL>


参考:

Oracle® Database Administrator's Guide 10g Release 2 (10.2) => 10 Managing the Undo Tablespace


--EOF    --


4.创建一个大文件表空间。

SQL> select file_name from dba_data_files where rownum=1;

FILE_NAME
--------------------------------------------------------------------------------
/home/oracle/oracle/oradata/PROD/system01.dbf

SQL> CREATE BIGFILE TABLESPACE bigtbs DATAFILE '/home/oracle/oracle/oradata/PROD/bigtbs01.dbf' SIZE 50M;

Tablespace created.

SQL> select tablespace_name,status,bigfile from dba_tablespaces where tablespace_name='BIGTBS';

TABLESPACE_NAME            STATUS     BIG
------------------------------ --------- ---
BIGTBS                   ONLINE     YES

SQL>

--EOF--


5.添加REDO成员组的成员。

SQL> col member for a80
SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                        IS_
---------- ------- ------- -------------------------------------------------------------------------------- ---
     1 STALE   ONLINE  /home/oracle/oracle/oradata/PROD/log1.log                        NO
     2 STALE   ONLINE  /home/oracle/oracle/oradata/PROD/log2.log                        NO
     3       ONLINE  /home/oracle/oracle/oradata/PROD/log3.log                        NO

SQL> ALTER DATABASE ADD LOGFILE MEMBER '/home/oracle/oracle/oradata/PROD/log1b.rdo' TO GROUP 1;

Database altered.

SQL> ALTER DATABASE ADD LOGFILE MEMBER '/home/oracle/oracle/oradata/PROD/log2b.rdo' TO GROUP 2;

Database altered.

SQL> ALTER DATABASE ADD LOGFILE MEMBER '/home/oracle/oracle/oradata/PROD/log3b.rdo' TO GROUP 3;

Database altered.

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER                                        IS_
---------- ------- ------- -------------------------------------------------------------------------------- ---
     1 STALE   ONLINE  /home/oracle/oracle/oradata/PROD/log1.log                        NO
     2 STALE   ONLINE  /home/oracle/oracle/oradata/PROD/log2.log                        NO
     3       ONLINE  /home/oracle/oracle/oradata/PROD/log3.log                        NO
     1 INVALID ONLINE  /home/oracle/oracle/oradata/PROD/log1b.rdo                        NO
     2 INVALID ONLINE  /home/oracle/oracle/oradata/PROD/log2b.rdo                        NO
     3 INVALID ONLINE  /home/oracle/oracle/oradata/PROD/log3b.rdo                        NO

6 rows selected.

SQL>


参考:

Oracle® Database Administrator's Guide 10g Release 2 (10.2) => Creating Redo Log Groups and Members


--EOF--


6.添加一个新的控制文件。

SQL> show parameter CONTROL_FILES

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
control_files                 string     /home/oracle/oracle/oradata/PR
                         OD/cntrl01.dbf, /home/oracle/o
                         racle/oradata/PROD/cntrl02.dbf
SQL> create pfile from spfile;

File created.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[oracle@localhost admin]$ cp /home/oracle/oracle/oradata/PROD/cntrl01.dbf /home/oracle/oracle/oradata/PROD/cntrl03.dbf
[oracle@localhost admin]$ ls -l /home/oracle/oracle/oradata/PROD/cntrl*
-rw-r----- 1 oracle oinstall 6832128 Jan  5 20:27 /home/oracle/oracle/oradata/PROD/cntrl01.dbf
-rw-r----- 1 oracle oinstall 6832128 Jan  5 20:27 /home/oracle/oracle/oradata/PROD/cntrl02.dbf
-rw-r----- 1 oracle oinstall 6832128 Jan  5 20:28 /home/oracle/oracle/oradata/PROD/cntrl03.dbf
[oracle@localhost admin]$ cd $ORACLE_HOME/dbs
[oracle@localhost dbs]$ cp  initPROD.ora initPROD.ora_bak
[oracle@localhost dbs]$ vim initPROD.ora
[oracle@localhost dbs]$ diff initPROD.ora initPROD.ora_bak
6c6
< *.control_files='/home/oracle/oracle/oradata/PROD/cntrl01.dbf','/home/oracle/oracle/oradata/PROD/cntrl02.dbf','/home/oracle/oracle/oradata/PROD/cntrl03.dbf'
---
> *.control_files='/home/oracle/oracle/oradata/PROD/cntrl01.dbf','/home/oracle/oracle/oradata/PROD/cntrl02.dbf'
[oracle@localhost dbs]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Sun Jan 5 20:30:47 2014

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> create spfile from pfile
  2  ;

File created.

SQL> startup
ORACLE instance started.

Total System Global Area  314572800 bytes
Fixed Size            1219160 bytes
Variable Size           96470440 bytes
Database Buffers      213909504 bytes
Redo Buffers            2973696 bytes
Database mounted.
Database opened.
SQL> show parameter CONTROL_FILES

NAME                     TYPE     VALUE
------------------------------------ ----------- ------------------------------
control_files                 string     /home/oracle/oracle/oradata/PR
                         OD/cntrl01.dbf, /home/oracle/o
                         racle/oradata/PROD/cntrl02.dbf
                         , /home/oracle/oracle/oradata/
                         PROD/cntrl03.dbf

SQL>

参考:
Oracle® Database Administrator's Guide 10g Release 2 (10.2) => Creating Additional Copies, Renaming, and Relocating Control Files

--EOF--


7.用dbms_stats包对表进行分析。

SQL> create table t as select * from dba_objects;

Table created.

SQL> exec dbms_stats.gather_table_stats(user,'T');

PL/SQL procedure successfully completed.

SQL>


--EOF--

0 0
原创粉丝点击