首先需要的软件有:
1、 linux_11gR1_database.zip //可在Oracle的 官方网站 下载得到,有1.71GB够大吧。
2、 别忘了准备一份Oracle的官方帮助文档 ,是最权威的。
3、 CentOS-5.2-i386-bin-DVD.iso //可在CentOS 官方网站 下载得到,有3.74GB超级大。呵呵!!!
这些准备工作做好了之后,我们就开始安装Linux操作系统,在虚拟机中安装,详细安装过程这里就不描述,不过,值得提醒的是虚拟机在配置虚拟硬件环境 时,内存必须大于或等于1G,硬盘空间至少15G。
在安装好虚拟L inux 系统之后,因为是菜鸟级的嘛,所以只有在图形界面下来操作了。将事先下载好的 linux_11gR1_database.zip 拷贝至Linux虚拟机里边,建立一个存放目录如:
/u01/linux_11gR1_database.zip
将其解压,在终端输入些命令执行:
[root@oracle u01]# unzip linux_11gR1_database.zip
解压后的存放文件夹名为 database
首先查看你Linux内核版本是否符合oracle安装条件:
[root@oracle u01]# cat /proc/version
确定内核版本后,检查此版本Linux环境下安装Oracle所需要用到的包:
[root@oracle u01]# rpm -qa | grep <package_name>
binutils-2.17.50.0.6-2.el5
compat-libstdc++-33-3.2.3-61
elfutils-libelf-0.125-3.el5
elfutils-libelf-devel-0.125
gcc-4.1.1-52
gcc-c++-4.1.1-52
glibc-2.5-12
glibc-common-2.5-12
glibc-devel-2.5-12
glibc-headers-2.5-12
libaio-0.3.106
libaio-devel-0.3.106
libgcc-4.1.1-52
libstdc++-4.1.1
libstdc++-devel-4.1.1-52.e15
make-3.81-1.1
sysstat-7.0.0
unixODBC-2.2.11
unixODBC-devel-2.2.11
若检查之后所缺失的包,在 CentOS-5.2-i386-bin-DVD.iso 中 CentOS 目录中找到对应的包名,复制
/u01/rpmpackage 文件中。或者直接安装这些我或者可以通过命令的方式安装这些包:
[root@oracle u01]# rpm -ivh <package_name>.rpm
检查主机名是否完整合格:
[root@oracle ~]# cat /etc/hosts
因为是作为服务器使用,所以必须是静态的IP,若是DHCP分配的,则修改为静态的。
[root@oracle ~]# vi /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
192.168.0.66 oracle //oracle为本机主机名
创建oracle所需要的用户名(oracle)和组名(oinstall、dba),并设置相应的权限:
[root@oracle ~]# /usr/sbin/groupadd oinstall
[root@oracle ~]# /usr/sbin/groupadd dba
[root@oracle ~]# /usr/sbin/useradd -g oinstall -G dba oracle
[root@oracle ~]# passwd oracle //这里的命令为设置oracle的密码,输入二次进行确认。
创建oracle数据库安装的文件目录及路径,并设置文件权限:
[root@oracle ~]# mkdir -p /u01/app/oracle/product/ //设置oracle的安装目录
[root@oracle ~]# chown -R oracle:oinstall /u01 //设置安装目录所属的用户和组
[root@oracle ~]# chmod -R 775 /u01 //设置文件权限
接下来修改系统配置:
[root@oracle ~]# vi /etc/sysctl.conf
在最末尾的地方加上:
kernel.shmall = 2097152 //固定大小为2M
kernel.shmmax = 2147483648 //一般设置为物理的一半
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 4194304
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 262144
保存命令: :x
[root@oracle ~]# /sbin/sysctl -p //使修改后的配置文件生效
为 oracle 用户设置 Shell 限制 //这一步很重要
[root@oracle ~]# vi /etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
[root@oracle ~]# vi /etc/pam.d/login
session required pam_limits.so
[root@oracle ~]# vi /etc/profile
if [ $USER = "oracle" ]; then
if [ $SHELL = "/bin/ksh" ]; then
ulimit -p 16384
ulimit -n 65536
else
ulimit -u 16384 -n 65536
fi
fi
[root@oracle ~]# vi /etc/csh.login
if ( $USER == "oracle" ) then
limit maxproc 16384
limit descriptors 65536
endif
选择是开启还是关闭SELINUX的工作模式
[root@oracle ~]# vi /etc/selinux/config
# 设置SELINUX为disabled
SELINUX=disabled
修改系统的发行版本
[root@oracle ~]# vi /etc/redhat-release
将CentOS release 5 (Final) 修改成
Red Hat Enterprise Linux AS release 5 (Taroon)
(因为oracle公司没推出CentOS版本的oracle)
以上就是在安装之前所需要的配置过程,一定要仔细哟!
下面就在终端用新建的 oracle 用户登录进行操作:
[root@oracle ~]# su - oracle
[oracle@oracle ~]$ ls -la
修改 .bash_profile 此文件即为 oracle 用户的环境变量,以下是完整配置
[oracle@oracle ~]$ vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.1.0/db_1; export ORACLE_HOME
ORACLE_SID=ORCL; export ORACLE_SID
ORACLE_TERM=xterm; export ORACLE_TERM
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
PATH=$ORACLE_HOME/bin:$PATH; export PATH
NLS_LANG="SIMPLIFIED CHINESE_CHINA".GBK; export NLS_LANG
LC_CTYPE=zh_CN.GBK; export LC_CTYPE
LC_ALL=zh_CN.UTF8; export LC_ALL //此处为终端语言变量,故为UTF8
LANG=zh_CN.GBK; export LANG
LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/jdk/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
//注意,因为限于篇幅这段无法显示为一整行,但这里实际是一整行,若分开,则在进行oracle用户登录的时候会报错。
umask 022
保存退出
[oracle@oracle ~]$ source .bash_profile
用此命令载入刚配置好的环境变量文件。
[oracle@oracle ~]$ exit //退回到root用户下
[root@oracle ~]# xhost + //确保X窗口的正常显示
[root@oracle ~]# su - oracle //再次以oracle用户登录
[oracle@oracle ~]$ cd /u01/database //转到database目录下
[oracle@oracle database]$ ./runInstaller //运行runInstall命令开始安装oracle数据库安装完毕之后,需要手动执行一条脚本命令:
[root@oracle ~]# /u01/app/oraInventory/orainstRoot.sh
更改权限/u01/app/oraInventory 到 770.
更改组名/u01/app/oraInventory 到 oinstall.
脚本的执行已完成
[root@oracle ~]# /u01/app/oracle/product/11.1.0/db_1/root.sh
Running Oracle 11g root.sh script...
The following environment variables are set as:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/product/11.1.0/db_1
Enter the full pathname of the local bin directory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratab file as needed by
Database Configuration Assistant when a database is created
Finished running generic part of root.sh script.
Now product-specific root actions will be performed.
Finished product-specific root actions.
安装完成后设置"/etc/oratab"
[root@oracle ~]# vi /etc/oratab
#修改为
ORCL:/u01/app/oracle/product/11.1.0/db_1:Y
按照提示,一步一步安装,整个过程就非常简单。
安装完以后,重启则oracle 服务默认是没有被启动的,则需要手工进行启动。
需要以oracle用户身份登录,登录之后主要服务的启动方式为
数据库服务 启动 | 关闭
[oracle@oracle bin]$ dbstart | dbshut
监听器 启动 | 关闭。
[oracle@oracle bin]$ lsnrctl start | stop
em 控制台 启动 | 关闭
[oracle@oracle bin]$ emctl start | stop dbconsole
iSQL*Plus 启动 | 关闭
[oracle@oracle bin]$ isqlplusctl start | stop