注意:以下命令使用 root 用户操作
安装依赖包
主要思路为配置 oracle yum 仓库,直接使用 yum 命令来安装依赖包,避免手工逐个的安装依赖包。
配置 yum 仓库以下载 orcale 依赖包
注意:这里是CentOS 6.X 的 oracle 依赖仓库,其他版本不同的。
导入 GPG Keys
wget https://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol6 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle --no-check-certificate</div>
安装 oracle 依赖
yum install oracle-rdbms-server-11gR2-preinstall</div>
设置 hostname
打开文件 /etc/sysconfig/network,并修改 HOSTNAME。
vi /etc/sysconfig/network NETWORKING=yes HOSTNAME=oracle.buzheng.org</div>
打开 /etc/host, 添加服务器本机IP地址 指向到 HOSTNAME
vi /etc/hosts 192.168.1.15 oracle.buzheng.org oracle</div>
oracle 用户设置
当安装好 oracle 依赖之后, oracle 用户已经创建好了,不需要手工创建 oracle 用户和相关的用户组。
修改 oracle 用户密码
[root@oracle ~]# passwd oracle 更改用户 oracle 的密码 。 新的 密码: 重新输入新的 密码: passwd: 所有的身份验证令牌已经成功更新。</div>
修改系统限制
在文件 /etc/security/limits.d/90-nproc.conf 中添加如下的最后一行
[root@oracle ~]# vi /etc/security/limits.d/90-nproc.conf # Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 1024 root soft nproc unlimited * - nproc 16384</div>
修改 SELinux 为 permissive 模式
修改文件 /etc/selinux/config 如下所示
[root@oracle ~]# vi /etc/selinux/config # This file controls the state of SELinux on the system. # SELINUX= can take one of these three values: # enforcing - SELinux security policy is enforced. # permissive - SELinux prints warnings instead of enforcing. # disabled - No SELinux policy is loaded. SELINUX=permissive # SELINUXTYPE= can take one of these two values: # targeted - Targeted processes are protected, # mls - Multi Level Security protection. SELINUXTYPE=targeted</div>
重启机器
[root@oracle]# reboot</div>
创建 oracle 安装目录,并授权
[root@oracle]# mkdir -p /u01/app/oracle/product/11.2.0/dbhome_1 [root@oracle]# chown -R oracle:oinstall /u01 [root@oracle]# chmod -R 775 /u01</div>
授权 oracle 用户能够访问 X Server
[root@oracle]# xhost + # 要在主机上运行,不能是远程 shell</div>
注意:以下命令使用 oracle 用户操作
配置 oracle 安装环境变量
切换到 oracle 用户, 编辑 .bash_profile 文件, 如下所示, 添加环境配置。
[root@oracle]# su oracle [oracle@oracle]# vi .bash_profile # Oracle Settings TMP=/tmp; export TMP TMPDIR=$TMP; export TMPDIR ORACLE_HOSTNAME=oracle.buzheng.org; export ORACLE_HOSTNAME ORACLE_UNQNAME=orcl; export ORACLE_UNQNAME ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1; export ORACLE_HOME ORACLE_SID=orcl; export ORACLE_SID PATH=/usr/sbin:$PATH; export PATH PATH=$ORACLE_HOME/bin:$PATH; export PATH LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib; export LD_LIBRARY_PATH CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH export PATH</div>
下载 oracle 安装文件,解压缩后安装
下载 oracle
打开 oracle 下载页面,http://www.oracle.com/technetwork/database/enterprise-edition/downloads/index.html , 下载下面两个文件到 /home/oracle
linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip</div>
解压缩文件并运行
unzip linux.x64_11gR2_database_1of2.zip unzip linux.x64_11gR2_database_2of2.zip cd database ./runInstaller</div>
若为中文系统,安装界面会出现中文乱码,需要先将环境变为英文,在安装
export LANG=en_US ./runInstaller</div>
没有截图, 安装步骤大致包括以下几步:
- Create and configure a database
- Server Class
- Single instance database installation
- Advanced install
- Language: English
- Enterprise Edition
- database type: General Purpose / Transaction Processing
- Memory: Enable Automatic Memory Management
- Character sets: Use Unicode(AL32UTF8)
图性界面安装最后会提示以ROOT 执行下面两个脚本
[root@oracle ~]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall. The execution of the script is complete.</div>
[root@oracle ~]# /u01/app/oracle/product/11.2.0/dbhome_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.2.0/dbhome_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.</div>
出现的问题
1, 当环境变量中的 ORACLE_SID 与 安装时实际配置不一致时,会导致 startup 出错,出错信息如下:
ORA-01078: failure in processing system parameters LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/dbhome_1/dbs/initDB11G.ora'</div>
2, 如果远程客户端连接是报错:ora-12514 tns 监听程序当前无法识别连接描述符中请求的服务,则需要配置 listener.ora,添加如下节点:
SID_LIST_LISTENER = (SID_LIST= (SID_DESC = (SID_NAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/dbhome_1) ) )</div>
好了,到此已经安装完成,通过访问 web 管理界面可验证。下面步骤也很重要,请继续。
注意:以下命令使用 root 用户操作
配置防火墙规则,开放侦听端口
将 1521(你配置的 oracle 侦听端口) 端口添加到防火墙规则,以便远程用户能顺利的访问到 oracle 服务。
iptables -I INPUT 4 -m state --state NEW -p tcp --dport 1521 -j ACCEPT service iptables save serv