一.安装前准备
1.内存及swap要求
$ grep MemTotal /proc/meminfo
MemTotal: 16178832 kB
$ grep SwapTotal /proc/meminfo
SwapTotal: 8126460 kB
2.修改主机名,及ip对应关系
--设置主机名,也可以直接修改配置文件/etc/sysconfig/network,不过这个是重启之后才起作用
#sed -i "s/HOSTNAME=localhost.localdomain/HOSTNAME=DB_2/g" /etc/sysconfig/network
--如果不想重启,则使用下面命令,使当前生效
#hostname DB_2
--添加主机名与IP对应记录
#vi /etc/hosts
10.10.0.48 DB_2
3.下载oracle11gR2
官网下载地址:http://www.oracle.com/technetwork/database/enterprise-edition/downloads/112010-linx8664soft-100572.html
二.修改内核参数
1./etc/sysctl.conf
--修改或添加,具体参数意思,请百度或参考oracle官网解释
#vi/etc/sysctl.conf
net.ipv4.ip_local_port_range= 9000 65500
fs.file-max = 6815744
kernel.shmall = 10523004
kernel.shmmax = 6465333657
kernel.shmmni = 4096
kernel.sem = 250 32000 100128
net.core.rmem_default=262144
net.core.wmem_default=262144
net.core.rmem_max=4194304
net.core.wmem_max=1048576
fs.aio-max-nr = 1048576
# sysctl -p #使配置生效
2.用户的限制文件/etc/security/limits.conf
#vim /etc/security/limits.conf 在文件后增加
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
--修改/etc/pam.d/login文件,增加如下:
session required /lib64/security/pam_limits.so //64为系统,千万别写成/lib/security/pam_limits.so,否则导致无法登录
session required pam_limits.so
三.创建用户及组
//创建用户及组
#groupadd oinstall
#groupadd dba
#useradd -g oinstall -G dba -d /home/oracle oracle
#passwd oracle
//创建安装目录
#mkdir -p /home/oracle/app/oracle/product/11.2.0/dbhome_1
//数据文件存放目录
#mkdir -p /home/oracle/app/oracle/oradata
//数据恢复目录
#mkdir -p /home/oracle/app/oracle/recovery_area
//数据库创建及使用过程中的日志目录
#mkdir -p /home/oracle/app/oracle/oraInventory
//修改安装目录权限
#chown -R oracle:oinstall /home/oracle/app/oracle
#chmod 775 /home/oracle/app/oracle
//登录oracle用户,设置环境变量
#su - oracle
$view .bash_profile
export ORACLE_BASE=/home/oracle/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export PATH=$PATH:$ORACLE_HOME/bin
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64
export ORACLE_SID=lambert
//如果设置NLS_LANG,容易产生导入sql或dmp出错,因为其他环境下的不是utf8
export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
$source .bash_profile //使设置生效
四.安装oracle
1.安装依赖包
# yum -y install gcc gcc-c++ make binutilscompat-libstdc++-33 elfutils-libelf elfutils-libelf-develglibc glibc-commonglibc-devel libaio libaio-devel libgcclibstdc++libstdc++-devel unixODBC unixODBC-devel ksh
或
# yum -y installbinutils compat-libstdc++-33 compat-libstdc++-33.i686 elfutils-libelfelfutils-libelf-devel gcc gcc-c++ glibc glibc.i686 glibc-common glibc-devel glibc-devel.i686glibc-headers ksh libaio libaio.i686 libaio-devel libaio-devel.i686 libgcclibgcc.i686 libstdc++ libstdc++.i686 libstdc++-devel make sysstat unixODBC unixODBC-devel
2.解压安装包
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
3.数据库安装
db_install.rsp 安装应答配置文件
dbca.rsp 创建数据库应答
netca.rsp 建立监听、本地服务名等网络设置应答
3.1 修改配置文件db_install.rsp,并安装
下面把主要修改的地方贴出来,具体详细文件,请查看另一篇文章:【Oracle 11gR2】db_install.rsp详解】http://www.cnblogs.com/yingsong/p/6031452.html
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=DB_m2
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/home/oracle/app/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/home/oracle/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.config.starterdb.characterSet=AL32UTF8
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/home/oracle/app/oracle/oradata
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/home/oracle/app/oracle/recovery_data
DECLINE_SECURITY_UPDATES=true //一定要设为true
登录oracle用户,执行安装
$./runInstaller -silent -responseFile /home/oracle/softwares/database/response/db_install.rsp -ignorePrereq
//安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在进行,如果出现[FATAL],则安装程序已经停止了。
//打开另一个终端,执行命令
#tail -100 f /home/oracle/app/oracle/oraInventory/logs/installActions......log
//可以实时跟踪查看安装日志,了解安装的进度。
//当出现
The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/home/oracle/app/oracle/oraInventory/orainstRoot.sh
/home/oracle/app/oracle/product/11.2.0/dbhome_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
//出现这个的话,说明已安装成功,则需要按提示操作,操作完返回Enter成功
3.2 配置监听配置文件response/netca.rsp
3.2 配置监听配置文件response/netca.rsp
$netca /silent /responsefile /home/oracle/softwares/database/response/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /home/oracle/softwares/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/home/oracle/app/oracle/product/11.2.0/dbhome_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
//成功运行后,在/home/oracle/app/oracle/11.2.0/network/admin目录下生成sqlnet.ora和listener.ora两个文件。
//完成后通过命令“netstat -tlnp”可以查看到1521端口已开
tcp 0 0 :::1521 :::* LISTEN 5477/tnslsnr
3.3 修改配置文件vim response/dbca.rsp,静默建立新库
RESPONSEFILE_VERSION = "11.2.0" //不能更改
OPERATION_TYPE = "createDatabase"
GDBNAME = "hello.dlxg.gov.cn" //全局数据库的名字=SID+主机域名
SID = "hello" //对应的实例名字
TEMPLATENAME = "General_Purpose.dbc" //建库用的模板文件
DATAFILEDESTINATION = /home/oracle/app/oracle/oradata //数据文件存放目录
RECOVERYAREADESTINATION=/home/oracle/app/oracle/recovery_data //恢复数据存放目录
CHARACTERSET = "AL32UTF8" //字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。
TOTALMEMORY = "5120" //oracle内存5120MB
配置完之后,执行命令
$dbca -silent -responseFile /home/oracle/softwares/database/response/dbca.rsp
1Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
57% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
74% complete
85% complete
96% complete
100% complete
Look at the log file "/home/oracle/app/oracle/cfgtoollogs/dbca/credit/credit.log" for further details.
查看日志文件
$ tail -f /home/oracle/app/oracle/cfgtoollogs/dbca/wang/wang.log
监听问题
解决方法一:
在oracle/product/11.2.0/dbhome_1/network/admin/listener.ora里面添加了一行
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = hello)
(SID_NAME = hello)
)
)