安装依赖包
代码语言:javascript复制[root@node01 ~]# yum -y install gcc gcc-c make elfutils-libelf-devel elfutils-libelf-devel-static binutils compat-libcap1 compat-libstdc -33 compat-libstdc -33*i686 compat-libstdc -33*.devel compat-libstdc -33 compat-libstdc -33*.devel gcc gcc-c glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio*.i686 libaio-devel libaio-devel*.devel libgcc libgcc*.i686 libstdc libstdc *.i686 libstdc -devel libstdc -devel*.devel libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
添加用户和组
代码语言:javascript复制[root@node01 ~]# groupadd oinstall
[root@node01 ~]# groupadd dba
[root@node01 ~]# useradd -g oinstall -G dba oracle
[root@node01 ~]# echo 123456 | passwd --stdin oracle
配置内核参数
代码语言:javascript复制[root@node01 ~]# vim /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
[root@node01 ~]# sysctl -p
修改用户限制
代码语言:javascript复制[root@node01 ~]# 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
oracle hard stack 10240
代码语言:javascript复制[root@node01 ~]# vim /etc/pam.d/login
session required /lib/security/pam_limits.so
session required pam_limits.so
代码语言:javascript复制[root@node01 ~]# vim /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@node01 ~]# source /etc/profile
创建安装目录
代码语言:javascript复制[root@node01 ~]# mkdir -pv /data/oracle/product/11.2.0
[root@node01 ~]# mkdir -pv /data/oracle/oradata
[root@node01 ~]# mkdir -pv /data/oracle/inventory
[root@node01 ~]# mkdir -pv /data/oracle/fast_recovery_area
[root@node01 ~]# chown -R oracle.oinstall /data/oracle/
[root@node01 ~]# chmod -R 775 /data/oracle
切换到oracle用户,设置oracle用户环境变量
代码语言:javascript复制[root@node01 ~]# su - oracle
[oracle@node01 ~]$ vim .bash_profile
export ORACLE_BASE=/data/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=dbsrv2
export LANG=american_america.ZHS16GBK
export LD_LIBRARY_PATH=$ORACLE_HONE/lib
alias oratrace="cd $ORACLE_BASE/diag/rdbms/$ORACLE_SID/$ORACLE_SID/trace && ls|grep alert"
alias oradata="cd /data/oracle/dbsrv2"
alias topc="ps -e -o pcpu,pid,user,tty,args | sort -k 1 -r | head"
alias topm="ps -e -o pmem,pid,user,tty,args | sort -k 1 -r | head"
[root@node01 ~]# source .bash_profile
上传安装包,编辑静默安装响应文件
代码语言:javascript复制[oracle@node01 ~]$ vim /home/oracle/database/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=node01
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/data/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/data/oracle/product/11.2.0
ORACLE_BASE=/data/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=orcl
oracle.install.db.config.starterdb.SID=dbsrv2
DECLINE_SECURITY_UPDATES=true
根据响应文件,安装oracle 11g
代码语言:javascript复制[oracle@node01 ~]$ cd /home/oracle/database
[oracle@node01 ~]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/oracle/database/response/db_install.rsp
安装完成后,切换到root用户运行两个脚本
代码语言:javascript复制[root@node01 ~]# /data/oracle/inventory/orainstRoot.sh
[root@node01 ~]# /data/oracle/product/11.2.0/root.sh
用oracle用户登录,配置监听
代码语言:javascript复制[root@node01 ~]# export DISPLAY=localhost:0.0
[root@node01 ~]# netca -silent -responseFile /home/oracle/database/response/netca.rsp
[root@node01 ~]# netstat -anuto | grep 1521
创建数据库
代码语言:javascript复制[oracle@node01 ~]$ /home/oracle/database/response/dbca.rsp
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/data/oracle/oradata
RECOVERYAREADESTINATION=/data/oracle/fast_recovery_area
CHARACTERSET = "AL32UTF8"
TOTALMEMORY = "1638"
静默配置
代码语言:javascript复制[root@node01 ~]# dbca -silent -responseFile /home/oracle/database/response/dbca.rsp
查看监听状态
代码语言:javascript复制[root@node01 ~]# lsnrctl status # 查看监听状态
[root@node01 ~]# lsnrctl start # 启动监听
[root@node01 ~]# lsnrctl stop # 关闭监听
登录数据库
代码语言:javascript复制su - oracle
sqlplus / as sysdba # 以系统管理员的身份来登录
sqlplus 用户名/密码 # 以普通用户的身份登录