这里不使用图形用户界面安装数据库,使用的是静默安装。
操作系统版本:CentOS release 6.5 (Final)
打算安装一个实例名为orcl的Oracle。
1. 检查硬件要求
1.1 内存要求
最小需要: 1 GB
推荐: 2 GB及以上
内存与交换内存关系推荐配置:
#查看内存大小
free -m
从Oracle Database 11g开始,自动内存管理功能需要更多的共享内存(/dev/shm)和文件描述符。共享内存的大小应至少为该计算机上每个Oracle实例的memory_MAX_TARGET和memory_TARGET中的较大者。
确定可用的共享内存量
df -h /dev/shm/
1.2 磁盘空间要求
df -h /tmp #/tmp目录至少需要1G
下表描述了Linux x86-64上每种安装类型的软件文件和数据文件的磁盘空间要求:
2. 检查软件要求
2.1 操作系统要求
Oracle Database 11g Release 2(11.2)需要以下或更高版本的操作系统:
- Asianux Server 3 SP2
- Asianux Server 4 SP3
- Oracle Linux 4 Update 7
- Oracle Linux 5 Update 2 (with Red Hat Compatible Kernel)
- Oracle Linux 5 Update 5
- Oracle Linux 6
- Oracle Linux 6 (with Red Hat Compatible Kernel)
- Oracle Linux 7
- Oracle Linux 7 (with the Red Hat Compatible Kernel)
- Red Hat Enterprise Linux 4 Update 7
- Red Hat Enterprise Linux 5 Update 2
- Red Hat Enterprise Linux 6
- Red Hat Enterprise Linux 7
- SUSE Linux Enterprise Server 10 SP2
- SUSE Linux Enterprise Server 11
- SUSE Linux Enterprise Server 12 SP1
- NeoKylin Linux Advanced Server 6
- NeoKylin Linux Advanced Server 7
#查看操作系统版本
cat /proc/version
2.2 内核版本
以下是Oracle Database 11g Release 2(11.2)的核心要求:
On Oracle Linux 4 and Red Hat Enterprise Linux 4
2.6.9 or later
On Oracle Linux 5 Update 2 with Red Hat Compatible Kernel
2.6.18 or later
On Oracle Linux 5 Update 5 with Red Hat Compatible Kernel
2.6.18 or later
On Oracle Linux 5 Update 5 with Unbreakable Enterprise Kernel
2.6.32-100.0.19 or later
On Oracle Linux 6
2.6.32-100.28.5.el6.x86_64 or later
On Oracle Linux 6 with Red Hat Compatible Kernel
2.6.32-71.el6.x86_64 or later
On Oracle Linux 7
3.8.13-33.el7uek.x86_64 or later
On Oracle Linux 7 with Red Hat Compatible Kernel
3.10.0-54.0.1.el7.x86_64 or later
On Red Hat Enterprise Linux 5 Update 2
2.6.18 or later
On Red Hat Enterprise Linux 5 Update 5
2.6.18 or later
On Red Hat Enterprise Linux 6
2.6.32-71.el6.x86_64 or later
On Red Hat Enterprise Linux 7
3.10.0-54.0.1.el7.x86_64 or later
On Asianux Server 3
2.6.18 or later
On Asianux Server 4
2.6.32-71.el6.x86_64 or later
On SUSE Linux Enterprise Server 10
2.6.16.21 or later
On SUSE Linux Enterprise Server 11
2.6.27.19 or later
On SUSE Linux Enterprise Server 12
3.12.49-11 or later
On NeoKylin Linux Advanced Server 6
2.6.32-431.el6.x86_64 or later
On NeoKylin Linux Advanced Server 7
3.10.0-327.el7.x86_64 or later
#查看内核版本
uname -r
2.3 软件包要求
#检查哪些软件包未安装
rpm -q binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel expat gcc gcc-c++ glibc glibc-common glibc-devel glibc-headers libaio libaio-devel libgcc libstdc++ libstdc++-devel make numactl pdksh sysstat unixODBC unixODBC-devel | grep "not installed"
package compat-libstdc++-33 is not installed
package elfutils-libelf-devel is not installed
package libaio-devel is not installed
package pdksh is not installed
package unixODBC is not installed
package unixODBC-devel is not installed
#安装未安装的软件包
yum install compat-libstdc++-33 elfutils-libelf-devel libaio-devel pdksh unixODBC unixODBC-devel -y
--若提示No package pdksh available,则下载rpm包进行安装:
wget http://vault.centos.org/5.11/os/x86_64/CentOS/pdksh-5.2.14-37.el5_8.1.x86_64.rpm
rpm -ivh pdksh-5.2.14-37.el5_8.1.x86_64.rpm
3. 对OS进行配置
3.1 创建相关用户和用户组
groupadd oinstall
groupadd oper
groupadd dba
useradd -g oinstall -G dba,oper oracle
passwd oracle
3.2 配置内核参数
vi /etc/sysctl.conf
修改以下各参数,最小设置如下(如果参数值比下面的大,则保持不变即可):
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048576
--注意,这里kernel.shmmax 仅设置的500M,请根据实际情况调大些(
初始化参数MEMORY_TARGET或MEMORY_MAX_TARGET不能大于共享内存,所以该参数值需要大于MEMORY_TARGET
)。
3.3 配置资源限制
vi /etc/security/limits.conf
新增如下内容:
oracle soft nofile 65536
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle stack nproc 10240
oracle stack nproc 10240
运行sysctl -p应用以上参数
/sbin/sysctl -p
3.4 创建相关目录
mkdir -p /u01/app/oracle/product/11.2.0.4/db_1
mkdir -p /u01/app/oracle/oradata
mkdir -p /u01/app/oracle/flash_recovery_area
mkdir -p /u01/app/oracle/archlog
chown -R oracle:oinstall /u01
3.5 配置oracle用户环境变量
su - oracle
vi .bash_profile
添加:
# Oracle Settings
COLUMNS=132; export COLUMNS
LINES=47; export LINES
EDITOR=vi; export EDITOR
TMP=/tmp; export TMP
TMPDIR=$TMP; export TMPDIR
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0.4/db_1; export ORACLE_HOME
ORACLE_SID=orcl; export ORACLE_SID
SHLIB_PATH=$LD_LIBRARY_PATH;export SHLIB_PATH
NLS_LANG=American_America.zhs16gbk;export NLS_LANG
ORA_NLS10=$ORACLE_HOME/nls/data;export ORA_NLS10
TNS_ADMIN=$ORACLE_HOME/network/admin;export TNS_ADMIN
ORACLE_TERM=xterm; export ORACLE_TERM
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/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib; export CLASSPATH
alias glance=/opt/perf/bin/glance:x
alias gohome='cd /u01/app/oracle/product/11.2.0.4'
alias cdb='cd /u01/app/oracle/admin/orcl/bdump'
alias cdu='cd /u01/app/oracle/admin/orcl/udump'
修改完执行:source .bash_profile生效。
3.6 修改操作系统发行版本
由于 oracle 还没有推出支持 CentOS 的安装包,所以需要修改发行版本,以便通过 oracle 的安装检查。
vi /etc/redhat-release
把CentOS release 6.5 (Final) 注释掉,前面加上一行redhat-4,当oracle安装完成后,再修改回来。
如:
#CentOS release 6.5 (Final)
redhat-4
4.安装数据库
4.1 解压安装包
cd /download
unzip p13390677_112040_Linux-x86-64_1of7.zip
unzip p13390677_112040_Linux-x86-64_2of7.zip
解压完成后,在安装包所在路径下自动生成了database文件夹:
[root@ZooKeeper-node2 download]# ll | grep database
drwxr-xr-x. 7 root root 4096 Aug 27 2013 database
4.2 安装oracle软件
4.2.1 新建静默安装的应答文件
cd database/response
修改db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=数据库服务器的主机名
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/app/oraInventory
ORACLE_HOME=/u01/app/oracle/product/11.2.0.4/db_1
ORACLE_BASE=/u01/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oper
oracle.install.db.config.starterdb.password.ALL=oracle
DECLINE_SECURITY_UPDATES=true
oracle.installer.autoupdates.option=SKIP_UPDATES
4.2.2 静默安装Oracle
su - oracle
cd /download/database/
./runInstaller -silent -responseFile /download/database/response/db_install.rsp
/*
假如报错:[FATAL] PRVF-0002 : Could not retrieve local nodename
需要配置/etc/hosts,加上ip和主机名的对应关系
假如安装过程中报错了,已经在$ORACLE_HOME和/u01/app/oraInventory下生成了很多文件目录。想再次安装的话,需要先删除这些文件:
[oracle@ser6-52 app]$ rm -rf /u01/app/oraInventory
cd $ORACLE_HOME/
rm -rf *
*/
按提示运行两个脚本
sh /u01/app/oraInventory/orainstRoot.sh
sh /u01/app/oracle/product/11.2.0.4/db_1/root.sh
4.3 建库
4.3.1 建响应文件
cd database/response
修改dbca.rsp文件:
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "orcl"
SYSTEMPASSWORD = "orcl"
SYSMANPASSWORD = "orcl"
DBSNMPPASSWORD = "orcl"
DATAFILEDESTINATION ="/u01/app/oracle/oradata"
STORAGETYPE=FS
CHARACTERSET = "ZHS16GBK"
DATABASETYPE = "MULTIPURPOSE"
4.3.2 建库
su - oracle
dbca -silent -responseFile /download/database/response/dbca.rsp
执行完成后,数据库自动打开了:
export ORACLE_SID=orcl
#开启补充日志
alter database add supplemental log data;
SQL> select SUPPLEMENTAL_LOG_DATA_MIN from v$database;
SUPPLEME
--------
YES
4.4 配监听
netca -silent -responseFile /download/database/response/netca.rsp
5. 设置数据库开机自启动
5.1 修改dbstart文件
vi $ORACLE_HOME/bin/dbstart
将ORACLE_HOME_LISTNER=$1修改为ORACLE_HOME_LISTNER=$ORACLE_HOME
5.2 修改/etc/oratab
将orcl:/u01/app/oracle/product/11.2.0.4/db_1:N改为
orcl:/u01/app/oracle/product/11.2.0.4/db_1:Y
5.3 修改/etc/rc.d/rc.local
添加一行:
su oracle -lc /u01/app/oracle/product/11.2.0.4/db_1/bin/dbstart
reboot重启主机验证下Oracle数据库及监听是否可以开机自启动。
6 开放1521端口
如果防火墙开启了的话,要开1521端口,允许远程访问。
vi /etc/sysconfig/iptables
直接在配置文件里已有的-A INPUT那些命令下面
添加一行:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 1521-j ACCEPT
重启防火墙
[root@ser6-52 mongodb]# /etc/init.d/iptables restart
7.后续配置
7.1 还原操作系统发行版本
vi /etc/redhat-release
取消CentOS release 6.5 (Final) 注释,删除redhat-4
7.2 开启归档模式
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP MOUNT;
SQL> ALTER DATABASE ARCHIVELOG;
#查看归档
SQL> archive log list;