Centos7_Minimal 静默安装 Oracle 12c版本
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Centos7_Minimal 静默安装 Oracle 12c版本相关的知识,希望对你有一定的参考价值。
Centos7_Minimal 静默安装 Oracle 12c版本
1.检查系统版本
[[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.4.1708 (Core)
2.关闭selinux
[[email protected] ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config [[email protected] ~]# getenforce Disabled
3.关闭防火墙
[[email protected] ~]# systemctl stop firewalld
4.修改主机名和hosts文件
[[email protected] ~]# cat /etc/hostname oracle [[email protected] ~]# cat /etc/hosts oracle 172.18.135.72
5.升级系统
[[email protected] ~]# yum update -y
6.安装依赖包和java环境
[[email protected] ~]#yum -y install binutils compat-libstdc++ compat-libstdc++-33 elfutils-libelf-devel gcc gcc-c++ glibc-devel glibc-headers ksh libaio-devel libstdc++-devel make sysstat unixODBC-devel binutils-* compat-libstdc++* elfutils-libelf* glibc* gcc-* libaio* libgcc* libstdc++* make* sysstat* unixODBC* wget unzip [[email protected] ~]# yum -y install java-1.8.0-openjdk*
7.创建用户,组
[[email protected] ~]# groupadd oinstall [[email protected] ~]# groupadd dba [[email protected] ~]# useradd -g oinstall -G dba oracle [[email protected] ~]# passwd oracle Changing password for user oracle. New password: BAD PASSWORD: The password is shorter than 8 characters Retype new password: passwd: all authentication tokens updated successfully. [[email protected] ~]# id oracle uid=1004(oracle) gid=1005(oinstall) groups=1005(oinstall),1006(dba)
8.创建软件安装目录,并赋权限
[[email protected] ~]# mkdir -p /opt/oracle $ORACLE_BASE [[email protected] ~]# mkdir -p /opt/oracle/12c $ORACLE_HOME [[email protected] ~]# mkdir /opt/oracle/oradata 数据存放目录 [[email protected] ~]# mkdir /opt/oracle/inventory 清单目录 [[email protected] ~]# mkdir /opt/oracle/flash_recovery_area 数据恢复目录 [[email protected] ~]# chown -R oracle:oinstall /opt/oracle [[email protected] ~]# chmod -R 775 /opt/oracle
9.修改系统参数
[[email protected] ~]# vim /etc/sysctl.conf
fs.file-max = 6815744 kernel.sem = 250 32000 100 128 kernel.shmmni = 4096 kernel.shmall = 1073741824 kernel.shmmax = 4398046511104 net.core.rmem_default = 262144 net.core.rmem_max = 4194304 net.core.wmem_default = 262144 net.core.wmem_max = 1048576 fs.aio-max-nr = 1048576 net.ipv4.ip_local_port_range = 9000 65500
[[email protected] ~]# sysctl -p (启动生效)
10. 修改用户限制文件
[[email protected] ~]# vim /etc/security/limits.conf
oracle soft nofile 1024 oracle hard nofile 65536 oracle soft nproc 2047 oracle hard nproc 16384 oracle soft stack 10240 oracle hard stack 32768
11.关联设置
[[email protected] ~]# vi /etc/pam.d/login
session required /lib64/security/pam_limits.so session required pam_limits.so
12.设置环境变量
[[email protected] ~]# 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
[[email protected] ~]# source /etc/profile (执行)
13.配置oracle用户环境变量(切换oracle用户)
[[email protected] ~]$ vim .bash_profile
# For Oracle export ORACLE_BASE=/opt/oracle export ORACLE_HOME=/opt/oracle/12c export ORACLE_SID=orcl export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/lib if [ $USER = "oracle" ]; then if [ $SHELL = "/bin/ksh" ]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fi umask 022 fi
[[email protected] ~]$ source .bash_profile
14.官网下载oracle 12c版本安装包,上传至/opt/oracle 目录
[[email protected] oracle]$ pwd /opt/oracle [[email protected] oracle]$ ls 12c flash_recovery_area inventory linuxamd64_12102_database_1of2.zip linuxamd64_12102_database_2of2.zip oradata
15.接下来用oracle用户解压
[[email protected] oracle]$ unzip linuxamd64_12102_database_1of2.zip [[email protected] oracle]$ unzip linuxamd64_12102_database_2of2.zip
16.解压完成可以看到目录/opt/oracle/database/response有3个应答文件,
分别数据库安装文件、建立数据库实例和监听配置安装文件
[[email protected] oracle]$ ll /opt/oracle/database/response/ total 112 -rwxrwxr-x 1 oracle oinstall 74822 Apr 4 2014 dbca.rsp -rw-rw-r-- 1 oracle oinstall 25036 Jul 7 2014 db_install.rsp -rwxrwxr-x 1 oracle oinstall 6038 Jan 24 2014 netca.rsp [[email protected] oracle]$
17.修改数据库安装文件db_install.rsp
[[email protected] oracle]$ vim /opt/oracle/database/response/db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY #安装类型 ORACLE_HOSTNAME=oracle #主机名称 UNIX_GROUP_NAME=oinstall #安装组 INVENTORY_LOCATION=/opt/oracle/inventory #清单目录 SELECTED_LANGUAGES=en,zh_CN #选择语言 ORACLE_HOME=/opt/oracle/12c/ # oracle_home ORACLE_BASE=/opt/oracle #oracle_base oracle.install.db.InstallEdition=EE #oracle版本 oracle.install.db.DBA_GROUP=dba #dba用户组 oracle.install.db.OPER_GROUP=oinstall #oper用户组 oracle.install.db.BACKUPDBA_GROUP=dba oracle.install.db.DGDBA_GROUP=dba oracle.install.db.KMDBA_GROUP=dba oracle.install.db.config.starterdb.type=GENERAL_PURPOSE #数据库类型 oracle.install.db.config.starterdb.globalDBName=orcl #globalDBName oracle.install.db.config.starterdb.SID=orcl #SID oracle.install.db.config.starterdb.memoryLimit=81920 #自动管理内存的最小内存(M) oracle.install.db.config.starterdb.password.ALL=oracle #设定所有数据库用户使用同一个密码 DECLINE_SECURITY_UPDATES=true #设置安全更新
18.开始安装,等的时间有点长,可以通过下图查看后台日志安装进程,tail -f log ,安装过程有警告可忽略,如下图即为安装成功,根据图示操作
[[email protected] ~]$ cd /opt/oracle/database/ [[email protected] database]$ ./runInstaller -silent -responseFile /opt/oracle/database/response/db_install.rsp -ignorePrereq
19.切换root用户执行上图脚本,然后回到oracle用户按enter就可以
20.查看默认的监听文件,并安装监听应答文件
[[email protected] ~]$ vim /opt/oracle/database/response/netca.rsp
INSTALL_TYPE=""custom""安装的类型 LISTENER_NUMBER=1监听器数量 LISTENER_NAMES={"LISTENER"}监听器的名称列表 LISTENER_PROTOCOLS={"TCP;1521"}监听器使用的通讯协议列表 LISTENER_START=""LISTENER""监听器启动的名称
[[email protected] ~]$ netca /silent /responseFile /opt/oracle/database/response/netca.rsp
21.上述命令执行成功后,会在/opt/oracle/12c/network/admin中生成listener.ora和sqlnet.ora文件
[[email protected] ~]$ ls /opt/oracle/12c/network/admin/
listener.ora samples shrept.lst sqlnet.ora
22.安装完成后可以查看端口1521是否起来
[[email protected] ~]$ netstat -tulnp |grep 1521
23.添加数据库实例,修改dbca.rsp文件
[[email protected] ~]$ vim /opt/oracle/database/response/dbca.rsp
RESPONSEFILE_VERSION = "12.1.0" #默认 OPERATION_TYPE = "createDatabase" #默认 GDBNAME = "orcl" #数据库名字 SID = "orcl" #对应的实例名 TEMPLATENAME = "General_Purpose.dbc" #默认 SYSPASSWORD = "oracle" #sys密码 SYSTEMPASSWORD = "oracle" #system密码 DBSNMPPASSWORD = "oracle" #dbs密码 DATAFILEDESTINATION =/opt/oracle/oradata #清单目录 RECOVERYAREADESTINATION=/opt/oracle/flash_recovery_area #恢复数据目录 CHARACTERSET = "AL32UTF8" #字符集,重要!!!建库后一般不能更改
24.执行数据库实例安装
[[email protected] ~]$ cd /opt/oracle/12c/bin/
[[email protected] bin]$ dbca -silent -responseFile /opt/oracle/database/response/dbca.rsp
25.查看实例进程,监听状态
[[email protected] bin]$ ps -ef |grep ora_ |grep -v grep
26.查看实例状态
[[email protected] ~]$ sqlplus / as sysdba
27.oracle的一些命令
开启racle服务:
$dbstart
$lsnrctl start
$sqlplus / as sysdba
SQL>startup
关闭oracle服务:
$dbshut
$lsnrctl stop
$sqlplus / as sysdba
SQL>shutdown /shutdown immediate
以上是关于Centos7_Minimal 静默安装 Oracle 12c版本的主要内容,如果未能解决你的问题,请参考以下文章