Linux静默安装oracle 11G


静默安装Oracle 11g

1、修改主机名及hosts

[root@localhost ~]# hostname
localhost.localdomain
[root@localhost ~]# hostname oracledb
[root@localhost ~]# vim /etc/hosts

2、关闭selinux和防火墙

[root@localhost ~]# setenforce 0	// 不重启系统生效
[root@localhost ~]# vim /etc/selinux/config  		# 修改为SELINUX=disabled   重启系统后生效
[root@localhost ~]# systemctl status firewalld.service	# 查看状态
[root@localhost ~]# systemctl stop firewalld.service 	# 停止 firewall
[root@localhost ~]# systemctl disable firewalld.service # 禁止 firewall 开机启动

3、安装依赖包

[root@localhost ~]# yum -y install gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static elfutils-libelf-devel ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

4、检查依赖包

[root@localhost ~]# rpm --query --queryformat "%{NAME}-%{VERSION}.%{RELEASE} (%{ARCH})\n" gcc make binutils gcc-c++ compat-libstdc++-33 elfutils-libelf-devel elfutils-libelf-devel-static ksh libaio libaio-devel numactl-devel sysstat unixODBC unixODBC-devel pcre-devel

5、创建Oracle用户及所属组

[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# useradd -g oinstall -G dba oracle

6、 修改内核参数

[root@localhost ~]# vim /etc/sysctl.conf
fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 1073741824
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

7、使内核参数生效

[root@localhost ~]# sysctl -p

8、修改用户的限制文件

[root@localhost ~]# 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

9、修改/etc/pam.d/login文件

[root@localhost ~]#  vim /etc/pam.d/login
session required /lib/security/pam_limits.so

10、修改/etc/profile文件

[root@localhost ~]# vim /etc/profile
[root@localhost ~]# source /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

11、创建安装目录

[root@localhost ~]# mkdir -p /home/oracle/app/oracle/product/11.2.0
[root@localhost ~]# mkdir /home/oracle/app/oracle/oradata
[root@localhost ~]# mkdir /home/oracle/app/oracle/inventory
[root@localhost ~]# mkdir /home/oracle/app/oracle/fast_recovery_area
[root@localhost ~]# chown -R oracle:oinstall /home/oracle/app/oracle
[root@localhost ~]# chmod -R 775 /home/oracle/app/oracle
#!/bin/bash
mkdir -p /home/oracle/app/oracle/product/11.2.0
mkdir /home/oracle/app/oracle/oradata
mkdir /home/oracle/app/oracle/inventory
mkdir /home/oracle/app/oracle/fast_recovery_area
chown -R oracle:oinstall /home/oracle/app/oracle
chmod -R 775 /home/oracle/app/oracle

12、配置oracle用户的环境变量

[root@localhost ~]# su - oracle
[oracle@oracledb ~]$ vim .bash_profile
[oracle@oracledb ~]$ source /home/oracle/.bash_profile
export LANG=en_US
export NSL_LANG=american_america.ZHS16GBK
export ORACLE_BASE=/home/oracle
export ORACLE_HOME=$ORACLE_BASE/app/oracle/product/11.2.0
export ORACLE_SID=orcl
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export CLASSPATH=$CLASSPATH:$ORACLE_HOME/rdbms/jlib:$ORACLE_HOME/jlib:$ORACLE_HOME/network/lib

13、 解压

[oracle@oracledb ~]$  exit
[root@localhost ~]# unzip p13390677_112040_Linux-x86-64_1of7.zip 
[root@localhost ~]# unzip p13390677_112040_Linux-x86-64_2of7.zip

14、移动解压后的文件,并修改所属用户

[root@localhost Tools]# mv database/ /home/oracle
[root@localhost Tools]# cd /home/oracle
[root@localhost oracle]# chown -R oracle:oinstall database/
[root@localhost oracle]# chown -R oracle:oinstall app/

15、配置静默安装响应文件

[root@localhost response]# su - oracle
[oracle@oracledb ~]$ cd database/response/
[oracle@oracledb response]$ cp db_install.rsp db_install.rsp.bak	# 备份
[oracle@oracledb response]$ vim db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY					// 29行
ORACLE_HOSTNAME=oracledb								// 37行
UNIX_GROUP_NAME=oinstall								// 42行
INVENTORY_LOCATION=/home/oracle/app/oracle/inventory	// 49行
SELECTED_LANGUAGES=en,zh_CN								// 86行
ORACLE_HOME=/home/oracle/app/oracle/product/11.2.0		// 91行
ORACLE_BASE=/home/oracle/app/oracle						// 96行
oracle.install.db.InstallEdition=EE						// 107行
oracle.install.db.DBA_GROUP=dba							// 154行
oracle.install.db.OPER_GROUP=dba						// 160行
DECLINE_SECURITY_UPDATES=true							// 400行

16、执行安装

[oracle@oracledb response]$ cd /home/oracle/database/
[oracle@oracledb database]$ ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /home/oracle/database/response/db_install.rsp

17、以root用户执行脚本

[root@localhost ~]# sh /home/oracle/app/oracle/inventory/orainstRoot.sh
[root@localhost ~]# sh /home/oracle/app/oracle/product/11.2.0/root.sh

18、创建监听

[oracle@oracledb database]$ cd /home/oracle/app/oracle/product/11.2.0/bin
[oracle@oracledb bin]$ ./netca -silent -responseFile /home/oracle/database/response/netca.rsp

19、建库

[oracle@oracledb bin]$ cd /home/oracle/database/response
[oracle@oracledb response]$ cp dbca.rsp dbca.rsp.bak
[oracle@oracledb response]$ vim dbca.rsp
[oracle@oracledb response]$ vim dbca.rsp
[oracle@oracledb bin]$ cd /home/oracle/app/oracle/product/11.2.0/bin
[oracle@oracledb bin]$ ./dbca -silent -responseFile /home/oracle/database/response/dbca.rsp
GDBNAME = "orcl"														// 78行
SID = "orcl"															// 170行
SYSPASSWORD = "Yangxiaopeng214"											// 211行
SYSTEMPASSWORD = "Yangxiaopeng214"										// 221行
SYSMANPASSWORD = "Yangxiaopeng214"										// 252行
DBSNMPPASSWORD = "Yangxiaopeng214"										// 262行
DATAFILEDESTINATION =/home/oracle/app/oracle/oradata					// 360行
RECOVERYAREADESTINATION=/home/oracle/app/oracle/fast_recovery_area		// 370行
CHARACTERSET = "ZHS16GBK"												// 418行
TOTALMEMORY = "2048"													// 553行

20、验证

[oracle@oracledb bin]$ lsnrctl status 	# 查看监听状态
[oracle@oracledb bin]$ lsnrctl restart	# 重启监听
[oracle@oracledb bin]$ lsnrctl stop		# 停止监听
[oracle@oracledb bin]$ lsnrctl start	# 启动监听

[oracle@oracledb bin]$ sqlplus
  • 输入用户名和密码
  • select sysdate from dual;

其他

  • 启动服务

先启动监听,再启动数据库

[oracle@oracledb ~]$ lsnrctl start		# 启动监听
[oracle@oracledb ~]$ sqlplus /nolog		# 打开sqlplus
SQL> conn / as sysdba					# 连接数据库
SQL> startup							# 启动数据库
SQL> shutdown							# 关闭数据库
SQL> exit								# 退出
[oracle@oracledb ~]$ lsnrctl stop		# 停止监听