怎么创建oraclelistener

发布网友 发布时间:2022-04-23 13:39

我来回答

2个回答

热心网友 时间:2022-04-13 10:03

手动创建oracle数据库,手动创建listener,已经安装了oracle 软件,设置了

export ORACLE_BASE=/oracle
export ORACLE_HOME=$ORACLE_BASE/proct/10.2.0/db_1
# export ORACLE_SID=infodb
export PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
export LANGUAGE=CHINESE
unset USERNAME
stty erase ^H
export TREM=vt100

1. set ORACLE_SID
export ORACLE_SID=test

2. 建立密码文件
orapwd file=orapw$ORACLE_SID password=oracle entries=10
注意file=orapw$ORACLE_SID 没有扩展名
linux/Unix:file=orapw$ORACLE_SID
windows:file=orapwd$ORACLE_SID

3. 建立需要的目录
mkdir -p $ORACLE_BASE/admin/test/amp
mkdir -p $ORACLE_BASE/admin/test/bmp
mkdir -p $ORACLE_BASE/admin/test/cmp
mkdir -p $ORACLE_BASE/admin/test/dpmp
mkdir -p $ORACLE_BASE/admin/test/pfile
mkdir -p $ORACLE_BASE/admin/test/ump
mkdir -p $ORACLE_BASE/flash_recovery_area
mkdir -p $ORACLE_BASE/oradata/test

4. 创建初始化参数文件 init$ORACLE_SID.ora
为了快速的建立init文件,把原示例文件里的注释去掉用以下方法:
cat $ORACLE_HOME/dbs/init.ora |grep -v ^#|grep -v ^$ >>init$ORACLE_SID.ora
注意内存参数,除了加入
sga_target=280M
别加入别的内存参数,小心启不来数据库。
$ORACLE_HOME/dbs/init$ORACLE_SID.ora
内容如下:
job_queue_processes=10
db_block_size=8192
db_file_multiblock_read_count=16
open_cursors=300
db_domain=""
db_name=test
background_mp_dest=/oracle/admin/test/bmp
core_mp_dest=/oracle/admin/test/cmp
user_mp_dest=/oracle/admin/test/ump
control_files=("/oracle/oradata/test/control01.ctl",
"/oracle/oradata/test/control02.ctl",
"/oracle/oradata/test/control03.ctl")
compatible=10.2.0.1.0
processes=150
sga_target=280M
audit_file_dest=/oracle/admin/test/amp
remote_login_passwordfile=EXCLUSIVE
pga_aggregate_target=90M
undo_management=AUTO
undo_tablespace=UNDOTBS1

创建好后,启动数据库
$sqlplus /nolog
SQL>conn / as sysdba
SQL>startup /nomount pfile='$ORACLE_HOME/dbs/init$ORACLE_SID.ora'
启动数据库后创建spfile
SQL>create spfile from pfile;
重启数据库:
SQL>shutdown immediate
SQL>startup nomount

5.创建建立数据库的脚本
CREATE DATABASE TEST
MAXINSTANCES 2
MAXLOGHISTORY 1
MAXLOGFILES 50
MAXLOGMEMBERS 5
MAXDATAFILES 200
DATAFILE '/oracle/oradata/test/system01.dbf' SIZE 300M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL
SYSAUX DATAFILE '/oracle/oradata/test/sysaux01.dbf' SIZE 120M REUSE AUTOEXTEND ON NEXT 10240K MAXSIZE UNLIMITED
SMALLFILE DEFAULT TEMPORARY TABLESPACE TEMP TEMPFILE '/oracle/oradata/test/temp01.dbf' SIZE 20M REUSE AUTOEXTEND ON NEXT

0K MAXSIZE UNLIMITED
SMALLFILE UNDO TABLESPACE "UNDOTBS1" DATAFILE '/oracle/oradata/test/undotbs01.dbf' SIZE 200M REUSE AUTOEXTEND ON NEXT 5120K

MAXSIZE UNLIMITED
CHARACTER SET ZHS16GBK
NATIONAL CHARACTER SET AL16UTF16
LOGFILE GROUP 1 ('/oracle/oradata/test/redo01.log') SIZE 51200K,
GROUP 2 ('/oracle/oradata/test/redo02.log') SIZE 51200K,
GROUP 3 ('/oracle/oradata/test/redo03.log') SIZE 51200K
USER SYS IDENTIFIED BY oracle USER SYSTEM IDENTIFIED BY oracle;

6. 创建需要的表空间:
CREATE SMALLFILE TABLESPACE USERS LOGGING DATAFILE '/oracle/oradata/test/users01.dbf' SIZE 5M REUSE AUTOEXTEND ON NEXT

1280K MAXSIZE UNLIMITED
EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO;
ALTER DATABASE DEFAULT TABLESPACE USERS;

7.执行相关的数据字典脚本
conn sys/password as sysdba
@/oracle/proct/10.2.0/db_1/rdbms/admin/catalog.sql;
@/oracle/proct/10.2.0/db_1/rdbms/admin/catblock.sql;
@/oracle/proct/10.2.0/db_1/rdbms/admin/catproc.sql;
@/oracle/proct/10.2.0/db_1/rdbms/admin/catoctk.sql;
@/oracle/proct/10.2.0/db_1/rdbms/admin/owminst.plb;

conn system/password
@/oracle/proct/10.2.0/db_1/sqlplus/admin/pupbld.sql;
@/oracle/proct/10.2.0/db_1/sqlplus/admin/help/hlpbld.sql helpus.sql;

8. 启动监听(非标准端口1523)
配置之前,一定要先修改local_listener参数:
SQL> show parameter local_listener

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
local_listener string
SQL> alter system set local_listener='(address=(protocol=tcp)(host=192.168.2.111)(port=1523))' scope=both;

System altered.

如果在/etc/hosts 中加入:
127.0.0.1 localhost
192.168.2.111 infodb
在listener.ora和tnsnames.ora中HOST=? 既可以使用ip也可以使用主机名。

配置$ORACLE_HOME/network/admin/listener.ora
# listener.ora Network Configuration File: /oracle/proct/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /oracle/proct/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(SID_NAME = test)
(ORACLE_HOME = /oracle/proct/10.2.0/db_1)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.111)(PORT = 1523))
)
(DESCRIPTION=
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.111)(PORT = 1521))
)
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC0))
)
)

客户端配置本地命名服务:
# tnsnames.ora Network Configuration File: D:\oracle\proct\10.2.0\client_1\network\admin\tnsnames.ora
# Generated by Oracle configuration tools.

TEST23 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.111)(PORT = 1523))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)

TEST21 =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.111)(PORT = 1521))
)
(CONNECT_DATA =
(SERVICE_NAME = test)
)
)

配置好后,启动默认监听:
lsnrctl start
启动其他监听:
lsnrctl start LISTENER1

验证配置:
sqlplus /nolog
conn / as sysdba
conn as sysdba
在客户端测试连接:
SQL> conn as sysdba
已连接。
SQL> conn as sysdba
已连接。

热心网友 时间:2022-04-13 11:21

用netca命令创建

声明声明:本网页内容为用户发布,旨在传播知识,不代表本网认同其观点,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:11247931@qq.com