Oracle10g安装过程
一、环境要求
Linux内核2.6.9以上,RedHat 4.3版本可以满足
物理内存:512M以上,课程要求物理内存1.5G~2G,实在不足就调整到1G
/TMP目录至少有400M空间
磁盘空间:1、安装oracle软件空间1.5G
2、创建数据库至少1G
课程过程中会产生大量的数据,要求Oracle路径下磁盘空间预留20G~30G
二、内核参数设置
/etc/sysctl.conf
1、共享内存
# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736 (64G) --最大的共享内存段大小。单位:字节
安装Oracle的时候想办法将Oracle的使用内存在一个共享内存段内,性能最高。
# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296 --共享内存段的最大大小,单位:页
32bit Linux 页大小4K
32bit系统支持最大内存4G,2的32次方4294967296字节,实际上最大是3.2G。
按照页大小,这个值默认应该是:1048576
缺省下是1024G。
4294967296--这个是当前64bit系统支持的最大内存量16384G内存
缺省值都是最大的上限,不是实际情况,所以保持默认值即可。
kernel.shmmni = 4096 --oracle建议的默认值
kernel.shmmax <= kernel.shmall * 4K
设置这个参数的时候实际的物理内存小于等于kernel.shmmax这个值,那么整个Linux使用全部在一个共享内存段。
2、信号量--控制资源访问的
kernel.sem = 250 32000 100 128
第一段:每个信号量集合的最大信号量数。Oracle所有的信号量是一个信号量集合。
第二段:整个Linux所有用户所有的信号量的最大值。
第三段:每个semop系统调用可以设置信号量的最大值。oracle建议取100.
第四段:信号量集合的最大数量。Oracle建议值。
(2)= (1)*(4)
所以只需要修改前两段参数。
3、打开文件参数
fs.file-max = 65536 整个Linux可以同时打开的最大的文件数量。
4、网络参数
端口参数
net.ipv4.ip_local_port_range = 1024 65000
root用户使用1024以下的端口,其他的用户使用1025~65000端口
通信
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144
综上:添加的参数如下:
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 262144
net.core.wmem_max = 262144
参数生效:
[[email protected] ~]# sysctl -p
三、设置安全管理参数
[[email protected] ~]# vim /etc/security/limits.conf --A文件
-------------------------------------------------------
* soft nproc 2047
* hard nproc 32000
* soft nofile 1024
* hard nofile 65536
* - memlock unlimited --关闭虚拟内存
----------------------------------------------------------
[[email protected] ~]# vim /etc/pam.d/login --启动文件,将文件A的配置文件放入启动文件,启动的时候文件A就能生效
----------------------------------------------------------
session required /lib/security/pam_limits.so
------------------------------------------------------------
/lib/security/pam_limits.so文件是文件limits.conf的配置文件
四、防火墙禁用
[[email protected] ~]# vim /etc/selinux/config
SELINUX=disabled
五、安装rpm软件包
32bit--按照顺序安装
make-3.81-3.el5.i386.rpm --OVA已有
gcc-4.1.2-48.el5.i386.rpm --OVA已有
glibc-headers-2.5-49.i386.rpm --OVA已有
glibc-devel-2.5-49.i386.rpm --OVA已有
compat-db-4.2.52-5.1.i386.rpm
compat-gcc-34-3.4.6-4.i386.rpm
compat-gcc-34-c++-3.4.6-4.i386.rpm
compat-libstdc++-33-3.2.3-61.i386.rpm --OVA已有
libXp-1.0.0-8.1.el5.i386.rpm
openmotif-2.3.1-2.el5_4.1.i386.rpm
setarch-2.0-1.1.i386.rpm --OVA已有
64bit--按顺序安装
binutils-2.15.92.0.2-10.EL4 --OVA已有
compat-db-4.1.25-9 --32bit和64bit的都要装,先装64的再装32的
control-center-2.8.0-12 --OVA已有
gcc-3.4.3-9.EL4 --OVA已有
gcc-c++-3.4.3-9.EL4 --OVA已有
glibc-2.3.4-2 --OVA已有
glibc-common-2.3.4-2 --OVA已有
libstdc++-3.4.3-9.EL4 --OVA已有
libstdc++-devel-3.4.3-9.EL4 --OVA已有
make-3.80-5 --OCR已有
pdksh-5.2.14-30 --安装冲突,先卸载
sysstat-5.0.5-1
xloadimage-4.1-34.RHEL4
xscreensaver-4.18-5.rhel4.2
libaio-0.3.96 --OVA已有
libXp 32bit
六、创建安装和管理Oracle软件的用户和组
oinstall组--管理oracle数据库软件的用户组
dba组--管理数据库的用户组
[[email protected] rpm10g32]# groupadd oinstall
[[email protected] rpm10g32]# groupadd dba
创建oracle用户并添加到上述组
[[email protected] rpm10g32]# useradd -m -g oinstall -G dba oracle
设置oracle用户的密码
[[email protected] rpm10g32]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
创建安装oracle数据库软件的目录
[[email protected] rpm10g32]# mkdir -p /u01/oracle/product/10.2.0/db_1
更改属主:
[[email protected] rpm10g32]# chown -R oracle:oinstall /u01/oracle
更改权限
[[email protected] rpm10g32]# chmod -R 775 /u01/oracle
七、解决版本冲突的问题
[[email protected] rpm10g32]# vi /etc/redhat-release
将5.5改为5.0
将安装介质解压缩
[[email protected] u01]# unzip 10201_database_linux32.zip
出现database目录
[[email protected] install]# pwd
/u01/database/install
[[email protected] install]# vim oraparam.ini
[Certified Versions]
Linux=redhat-3,SuSE-9,redhat-4,redhat-5,UnitedLinux-1.0,asianux-1,asianux-2
---------
[UnitedLinux-1.0-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-redhat-3.0-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-SuSE-9-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-redhat-4.0-optional]
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
[Linux-redhat-5.0-optional] --添加
TEMP_SPACE=80
SWAP_SPACE=150
MIN_DISPLAY_COLORS=256
八、设置Oracle用户的环境变量
[[email protected] install]# su - oracle
[[email protected] ~]$ vim .bash_profile
---------------------------------------------------------------------------
export PATH
export TMP=/tmp --安装Oracle软件过程中使用的临时文件的目录
export TMPDIR=$TMP --安装Oracle软件过程中使用的临时文件的目录
export ORACLE_BASE=/u01/oracle --oracle的base目录,所有关于Oralce的文件全部存储在这个目录中
export ORACLE_HOME=/u01/oracle/product/10.2.0/db_1 --oracle的home目录,oracle软件的安装目录
export ORACLE_SID=ORCL --将要创建的Oracle数据库的名字
export ORACLE_TERM=xterm --安装的时候指定的终端的定义资源文件:xterm是窗口模式,rt100是终端调用模式
export PATH=/usr/sbin:$PATH --
export PATH=$ORACLE_HOME/bin:$PATH --shell脚本执行的搜索路径
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib --库文件的搜索路径
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib --java程序bin执行的搜索路径
export EDITOR=vim --表示在oralce管理工具下调用linux文件编辑器的名称
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK --表示oracle用户客户端定义的中文字符集
export NLS_DATE_FORMAT=‘YYYY-MM-DD HH24:MI:SS‘ --表示oracle用户客户端定义的时间显示格式
----------------------------------------------------------------------------
[[email protected] ~]$ source .bash_profile --环境变量运行生效
九、安装数据库软件和创建数据库
[[email protected] ~]# xhost +
access control disabled, clients can connect from any host --测试调用图形界面环境是否是可用的。
如果客户端安装了xmanager,这个命令会自动将Xmanager - Passive服务启动支持图形界面。
[[email protected] ~]# su - oracle
[[email protected] ~]$ export DISPLAY="10.1.1.250:0.0" --IP地址是客户端的IP地址
[[email protected] ~]$ export LANG=en_US
[[email protected] database]$ ./runInstaller --执行解压缩目录中的脚本
安装过程参考插图。
注意最后一个步骤要先在root下执行两个脚本后再点击OK。
十、验证
[[email protected] db_1]# su - oracle
[[email protected] ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Jun 4 16:32:44 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba --验证数据库
Connected.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
------------------------验证数据库的监听器-----------------------------------
[[email protected] ~]$ lsnrctl status
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 04-JUN-2014 16:32:54
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 04-JUN-2014 16:19:42
Uptime 0 days 0 hr. 13 min. 12 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s). --看到数据库ORCL正在被监听
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCLXDB" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCL_XPT" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
----------------------------------------------------------------------------------------------------------
案例:Oracle的启动和关闭
Oracle需要启动两个服务:
1、先把监听器启动。
2、再把数据库启动。
关闭--
[[email protected] ~]$ lsnrctl stop --关闭监听器
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 09:36:58
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
The command completed successfully
[[email protected] ~]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 5 09:37:07 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> shutdown immediate --关闭数据库
Database closed.
Database dismounted.
ORACLE instance shut down.
启动--
[[email protected] ~]$ lsnrctl start --启动监听
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 09:38:27
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Starting /u01/oracle/product/10.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 05-JUN-2014 09:38:27
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[[email protected] ~]$ sqlplus /nolog --打开SQLPLUS工具
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Jun 5 09:38:32 2014
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba --以管理员身份连接
Connected to an idle instance. --连接到一个停顿的实例
SQL> startup --启动数据库
ORACLE instance started.
Total System Global Area 608174080 bytes
Fixed Size 1220844 bytes
Variable Size 171970324 bytes
Database Buffers 432013312 bytes
Redo Buffers 2969600 bytes
Database mounted.
Database opened.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
[[email protected] ~]$ lsnrctl status --确认监听器正在监听数据库实例
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 05-JUN-2014 09:38:51
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 05-JUN-2014 09:38:27
Uptime 0 days 0 hr. 0 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oracle3)(PORT=1521)))
Services Summary...
Service "ORCL" has 1 instance(s). --表示正在监听。“READY”状态
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCLXDB" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "ORCL_XPT" has 1 instance(s).
Instance "ORCL", status READY, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
-----------------------------------------------------------------------------------------
通过win客户端访问Oracle Server
1、安装win的Oracle客户端
10201_client_win32
注意--1、安装的模式要选择“管理员”方式 2、用administrator用户安装(可能没有激活,在DOS命令行下激活net user administrator /active:yes)
2、安装PLSQL Developer
PL.SQL.Developer.v7.0.1.1066
注意--安装的路径若包含“(X86)”,要将“(X86)”删掉。
3、本地创建连接串
在“开始”的oracle安装目录中,打开“网络配置助手”,选择“本地Net服务名配置”,填写服务名“ORCL”(数据库名字),填写oracle server的IP地址,端口号默认是1521,其他步骤都是默认,最后填写网络服务名,这个名字自取。
4、测试
掌握三种连接方式:
A 通过Oralce客户端安装后自带的工具--Oracle自带的SQLPlus工具
通过DOS命令行也能打开这个工具
B 通过PLSQL Developer连接
---------------------------------------------------------------------------------