环境准备
Linux centos7
Oracle 11g linux.x64_11gR2_database_1of2.zip linux.x64_11gR2_database_2of2.zip
1.下载oracle安装包
https://www.oracle.com/database/technologies/oracle-database-software-downloads.html
选择X64安装包
2.关闭防火墙与selinux
关闭selinux
编辑 /etc/selinux/config文件,设置SELINUX= enforcing 为SELINUX=disabled
关闭防火墙
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
3.安装Oracle 11g依赖包
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 libXext.x86_64 libXrender.x86_64 libXtst.x86_64
4.添加oinstall 、dba 组
[root@localhost ~]# groupadd oinstall
[root@localhost ~]# groupadd dba
[root@localhost ~]# useradd -g oinstall -G dba oracle
[root@localhost ~]# passwd oracle
Changing password for user oracle.
New password:oracle//根据自己需要定义密码
Retype new password:oracle//确认密码
passwd: all authentication tokens updated successfully.
[root@localhost ~]# id oracle
uid=1000(oracle) gid=1000(oinstall) groups=1000(oinstall),1004(dba)
5.修改内核参数
编辑 /etc/sysctl.conf,添加以下设置:
io-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
让参数生效:
[root@localhost etc]#sysctl -p
修改用户的限制文件
编辑 /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
session required pam_limits.so
修改/etc/profile文件:
[root@localhost ~]# vi /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
6.创建安装目录、修改文件权限
[root@localhost ~]# mkdir -p /usr/local/app/oracle/product/11.2.0
[root@localhost ~]# mkdir /usr/local/app/oracle/oradata
[root@localhost ~]# mkdir /usr/local/app/oracle/inventory
[root@localhost ~]# mkdir /usr/local/app/oracle/fast_recovery_area
[root@localhost ~]# chown -R oracle:oinstall /usr/local/app/oracle
[root@localhost ~]# chmod -R 775 /usr/local/app/oracle
7..解压oracle软件包
[root@localhost tmp]# unzip linux.x64_11gR2_database_1of2.zip && unzip linux.x64_11gR2_database_2of2.zip
8.设置oracle用户环境变量
切换到oracle用户,设置oracle用户环境变量
[root@localhost tmp]# cd database/
[root@localhost database]# su - oracle
-bash-4.2$ vi .bash_profile
添加:
ORACLE_BASE=/usr/local/app/oracle
ORACLE_HOME=$ORACLE_BASE/product/11.2.0
ORACLE_SID=orcl
PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_BASE ORACLE_HOME ORACLE_SID PATH
9.编辑静默安装响应文件
(1)切换到root 用户进入oracle安装包解压后的目录 /tmp/database/response/下备份db_install.rsp文件。
-bash-4.2$ exit
[root@localhost database]# cd /tmp/database/response/
[root@localhost response]# cp db_install.rsp db_install.rsp.bak
(2)编辑 /tmp/database/response/db_install.rsp文件
[root@localhost response]# vi db_install.rsp
修改以下参数:
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=localhost
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/usr/local/app/oracle/inventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/usr/local/app/oracle/product/11.2.0
ORACLE_BASE=/usr/local/app/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=dba
DECLINE_SECURITY_UPDATES=true
10.根据响应文件安装oracle 11g
[root@localhost response]# cd ../
[root@localhost database]# su - oracle
[oracle@localhost ~]# cd /tmp/database
[oracle@localhost database]# ./runInstaller -silent -ignorePrereq -ignoreSysPrereqs -responseFile /tmp/database/response/db_install.rsp
开始Oracle在后台静默安装。安装过程中,如果提示[WARNING]不必理会,此时安装程序仍在后台进行,如果出现[FATAL],则安装程序已经停止了。
此时再打开另外一个终端选项卡,输入提示的会话日志目录:
看到日志文件会持续输出安装信息没有输入异常信息,则表明安装过程正常。
[root@localhost ~]# tail -f /usr/local/app/oracle/inventory/logs/installActions2020-05-06_12-57-19PM.log
按照提示切换root用户运行脚本
[oracle@localhost database]$ exit
[root@localhost database]# /usr/local/app/oracle/inventory/orainstRoot.sh
[root@localhost database]# /usr/local/app/oracle/product/11.2.0/root.sh
11.配置监听
用oracle用户登录配置监听
[oracle@localhost ~]$ su - oracle
[oracle@localhost ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp
出现上图情况时,则需要配置DISPLAY变量,配完之后重新netca:
[oracle@localhost ~]$ export DISPLAY=localhost:0.0
[oracle@localhost ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp
出现上图情况时,则需要安装libXext,安装完之后重新netca:
[root@localhost ~]$ yum install libXext.x86_64
[root@localhost ~]$ yum install libXrender.x86_64
[root@localhost ~]$ yum install libXtst.x86_64
[root@localhost ~]$ su - oracle
[oracle@localhost ~]$ netca -silent -responseFile /tmp/database/response/netca.rsp
成功运行后,会在/usr/local/app/oracle/product/11.2.0/network/admin/ 中生成listener.ora和sqlnet.ora两个文件。
查看监听端口:
切换到root账号:
[oracle@localhost ~]# su
[root@localhost admin]# netstat -tnulp | grep 1521
12.建立新库,同时建立对应的实例
切换到root用户,编辑 /tmp/database/response/dbca.rsp
[root@localhost oracle]# vi /tmp/database/response/dbca.rsp
修改以下参数:
GDBNAME = "orcl"
SID = "orcl"
SYSPASSWORD = "oracle"
SYSTEMPASSWORD = "oracle"
SYSMANPASSWORD = "oracle"
DBSNMPPASSWORD = "oracle"
DATAFILEDESTINATION =/usr/local/app/oracle/oradata
RECOVERYAREADESTINATION=/usr/local/app/oracle/fast_recovery_area
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "1638"
13.进行静默配置
[root@localhost oracle]# su - oracle
[oracle@localhost ~]$ dbca -silent -responseFile /tmp/database/response/dbca.rsp
14.查询建库状态
完成建库后进行实例检查
[oracle@localhost ~]$ ps -ef | grep ora_ | grep -v grep
查看监听状态
[oracle@localhost ~]$ lsnrctl status
解决监听未启动方法
[oracle@localhost ~]$ vi /usr/local/app/oracle/product/11.2.0/network/admin/listener.ora
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(SID_NAME = orcl)
)
)
[oracle@localhost ~]$ lsnrctl reload
[oracle@localhost ~]$ lsnrctl status
15.启动数据库
[oracle@localhost dbs]$ sqlplus / as sysdba
#启动数据库:
SQL> startup
看到以下信息,表明数据库实例已经启动成功,至此,oracle 11g静默安装完成结束。