Qucick Start to Oracle Connections快速连接到Oracle

This chapter is designed to help novice users set up and test a simple but common configuration—one between a client application and a database over a TCP/IP network.

This chapter contains these topics:

健哥翻译:本章旨在帮助那些菜鸟去创建和测试一个简单但是常用的配置:通过TCP/IP协议是客户程序连接到服务器的配置,主要包括以下主题。

Prerequisites to Establishing Connectivity

The tasks in this quick start guide show a TCP/IP connection between a client computer and a database server. The following about the database server and client computers is assumed:

  • Database Server Computer

    • It is running on the same network as the client.

    • An Oracle database is installed.

    • TCP/IP protocol support is installed.

    • A listener is configured.

  • Client Computer

    • It is running on the same network as the database server.

    • Oracle Client is installed.

    • TCP/IP protocol support is installed.

译:这个快速指南的任务展示基于TCP/IP协议的客户端到Oracle服务器端的连接,下面的内容假定是成立的:

数据库服务器电脑:

1.跟客户端在一个通络中运行。

2.Oracle数据库服务器已安装

3.TCP/IP协议已安装。

4.监听器已配置

客户端电脑:

1.跟数据库服务器运行在同一个网络。

2.Oracle客户端已安装。

3.TCP/IP协议已安装。

 

Task 1: Confirm Network Availability

Before using Oracle Net to connect a client computer to a database server, confirm that the client computer can successfully communicate with the database server computer. Evaluating network connectivity can eliminate network-based errors.

To confirm network connectivity:

在使用Oracle Net连接服务器的时候,首先要确认客户端电脑能与数据库所在电脑成功通信。评估网络的连通性能消除基于网络的错误。Confirm that the database server computer can communicate with itself with a loopback test.

  1. A loopback test is a connection from the database server back to itself. Many network protocols provide a means of testing network connections. The utility PING can be used for TCP/IP network.

    In a TCP/IP network, each computer has a unique IP address. A name resolution service, such as Domain Name System (DNS), can be used to map the IP address of a computer with its host name. If a name resolution service is not used, then the mapping is typically stored in a centrally maintained file called hosts. This file is located in the /etc directory on UNIX and the /winnt directory on Windows. For example, an entry for a database server computer named sales-server may look like the following:#IP address of server     host name       alias
    144.25.186.203            sales-server    sales.us.acme.com

  2. To use PING, enter the following at the command line:

    ping database_server_host
    
    

    The database_server_host is the host name of the database server computer. For example:

    ping sales-server
    
    

    If the loopback was unsuccessful, try using the IP address of the database server. For example:

    ping 144.25.186.203
    
    
  3. Verify the client computer can successfully communicate with the database server computer.

    This varies according to the network protocol. For TCP/IP, you can use PING, FTP or TELNET utilities. If the client computer cannot reach the server, verify that the network cabling and network interface cards are correctly connected. Contact your network administrator to correct these problems.

Task 2: Start the Listener and the Database Server

The listener and database server must be running in order for the database server to receive connections.

  1. Start the listener with the Listener Control utility. From the command line, enter:

    lsnrctl
    LSNRCTL> START [listener_name]
    
    

    where listener_name is the name of the listener defined in the listener.ora file. It is not necessary to identify the listener if you are using the default listener, named LISTENER.

    A status message indicating that the listener has started successfully displays.

  2. Start the database:

    1. Start SQL*Plus without connecting to the database:

      sqlplus /nolog
      
      
    2. Connect to the database as SYSDBA:

      SQL> CONNECT username/password as sysdba
      
      

      For example, SYSTEM/MANAGER is a SYSDBA user.

    3. Enter the STARTUP command, specifying the database name and full path of the parameter file:

      SQL> STARTUP database_name pfile=file
      
      

      If you do not specify the PFILE option, the Oracle database uses the standard initialization parameter file located in the $ORACLE_BASE/admin/db_name/pfile/sid directory on UNIX platforms, and ORACLE_BASE/admin/db_name/pfile/sid directory on Windows. If you do not specify a database name, then the database uses the value of the DB_NAME parameter specified in the initialization parameter file.

      See Also:

      Oracle Database Administrator's Guide for further information about starting the database
  3. Confirm that database service registration with the listener has completed. From the Listener Control utility, enter:

    LSNRCTL> SERVICES [listener_name]
    
    

    The SERVICES command lists the services supported by the database, along with at lease one available service handler.

Task 3: Configure the Client for Connection to a Database

Once network connectivity has been verified, you can use easy connect naming to connect to the database.

NOTE:

Oracle Database 10g does not support the use of Oracle Names. Neither Oracle Database 10g clients nor Oracle Databases can use Oracle Names, including by LDAP proxy, to resolve naming. Oracle8 i and Oracle9 i clients can still use Oracle Names to resolve naming for an Oracle Database 10g database; however, customers are strongly recommended to migrate(迁移) to LDAP to take advantage of the new features of Oracle Database 10g.

The easy connect naming method can eliminate(消除) the need for service name lookup in the tnsnames.ora files for TCP/IP environments. This naming method provides out-of-the-box TCP/IP connectivity to databases. It extends the functionality of the host naming method by enabling clients to connect to a database server with an optional port and service name in addition to the host name of the database.

CONNECT username/password@host[:port][/service_name][/instance_name]
where:

If you have performed Oracle Database server install in Typical mode, the default service name used by oracle instance is ORCL, and the following easy connect syntax can be used to connect to that instance:

CONNECT username/password@host/ORCL

Alternate Connection using Oracle Net Configuration Assistant

If you do not wish to use the easy connect naming method, you can use Oracle Net Configuration Assistant to create a net service name, a simple name for the database service. The net service name resolves to the connect descriptor, that is, the network address of the database and the name of the database service. The client will use the net service name to connect to the database.

The following example shows the net service name sales mapped to a connect descriptor for a database called sales.us.acme.com. A client can use sales mapped to connect to sales.us.acme.com.

sales= 
 (DESCRIPTION= 
   (ADDRESS=(PROTOCOL=tcp)(HOST=sales-server)(PORT=1521))
   (CONNECT_DATA=
     (SERVICE_NAME=sales.us.acme.com)))

To configure a client with a net service name:

  1. Start Net Configuration Assistant.

    The Welcome page appears.

  2. Select Local Net Service Name Configuration.

  3. Click Next.

    The Net Service Name Configuration page appears.

  4. Click Add, and then click Next.

    The Net Service Name Configuration, Database Version page appears:

  1. If the destination service is an Oracle9i or Oracle8i database, then select Oracle8i or later database or service. If destination service is an Oracle8 release 8.0 database, then select Oracle8 release 8.0 database or service.

  2. Click Next.

    The Net Service Name Configuration, Service Name appears.

  3. Enter the name that identifies the database.

    The service name is defined during database creation. If you are unsure what the service name is, ask the Database Administrator who created the database.

  4. Click Next.

    The Net Service Name Configuration, Select Protocols page appears.

  5. Select the protocol on which the listener is configured to listen. Note that this protocol must also be installed on the client. The listener is configured to listen on TCP/IP by default.

  6. Click Next.

    The page appropriate for the selected protocol appears.

  7. Enter the appropriate protocol parameters for the selected protocol in the fields provided, and then click Next.

    The Net Service Name Configuration, Test page appears.

  8. Click Yes perform a test.

    During a test, Oracle Net Configuration Assistant contacts the remote database service, establishes a connection, and ends contact.

    A successful test results in the following message:

    Connecting...Test successful.
    
    

    If the test fails, it can be because the:

    • Default username (scott) and password (tiger) are not valid

    • Protocol address information does not match the listener information

    • Listener is not running

    • Destination database service is down

    Depending on your diagnosis of the problem, perform one of the following tasks:

  9. Click Next.

    The Net Service Name Configuration, Net Service Name page appears.

  10. Accept the default net service name or enter another net service name in the Net Service Name field. The name you enter should be unique to the client.

  11. Click Next.

    The Net Service Name Configuration, Another Net Service Name page appears.

  12. Click No, and then click Next.

    The Net Service Name Configuration, Configuration Done page appears.

  13. Click Next, and then click Finish.

Task 4: Connect to the Database

From the client computer, connect to the database server as follows.

  1. Start SQL*Plus:

    sqlplus
    
    

Connect to the database as follows:

CONNECT username/password@net_service_name

where username and password are the database user and password, and net_service_name is the net service name that you created in "Task 3: Configure the Client for Connection to a Database".s

注释:

host naming

A naming method resolution that enables users in a TCP/IP environment to resolve names through their existing name

resolution service. This name resolution service might be Domain Name System (DNS), Network Information Service (NIS),

or simply a centrally-maintained set of /etc/hosts files. Host Naming enables users to connect to an Oracle database

server by simply providing the server computer's host name or host name alias. No client configuration is required to

take advantage of this feature. This method is recommended for simple TCP/IP environments.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值