https://blog.51cto.com/mflag/2420185
https://blog.csdn.net/zwl18210851801/article/details/80774980
一、环境准备
操作系统:Centos7.3(1161)
内核版本:Linux localhost.localdomain 3.10.0-514.el7.x86_64 #1 SMP Tue Nov 22 16:42:41 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
数据库版本号:Oracle12C R2(12.2.0.1.0)
二、安装前准备-1[系统级别]
1、yum下载wget、unzip等软件
[root@localhost data]# yum install wget -y [root@localhost data]# yum install unzip
2、下载oracle 12c安装包、rwlrap等
[root@localhost data]# wget http://172.18.1.8/soft-database/oracle_linux_12CR2_12.2.0.1.0__database.zip [root@localhost data]# wget http://172.18.1.8/rlwrap-0.42-1.el6.x86_64.rpm
3、关闭防火墙,禁止防火墙开机自启
[root@localhost data]#systemctl stop firewalld.service [root@localhost data]#systemctl disable firewalld.service
4、关闭selinux
[root@localhost data]# vi /etc/selinux/config SELINUX=disabled
5、安装依赖包并检查
[root@localhost data]#yum -y install 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
[root@localhost data]#rpm -q binutils compat-libcap1 compat-libstdc++-33 gcc gcc-c++ glibc glibc-devel ksh libaio libaio-devel libgcc libstdc++ libstdc++-devel libXi libXtst make sysstat unixODBC unixODBC-devel
三、安装前准备-2[oracle级别]
1、创建oinstall和dba组
[root@localhost data]#groupadd oinstall [root@localhost data]#groupadd dba
2、创建oracle用户并创建oracle密码、查看创建结果
[root@localhost data]#useradd -g oinstall -G dba oracle [root@localhost data]#echo "oracle" | passwd --stdin oracle [root@localhost data]#id oracle
3、修改内核参数
[root@localhost data]#vi /etc/sysctl.conf fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 17179869184 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 data]# sysctl -p
4、修改配置-1
[root@localhost data]# vi /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
5、修改配置-2
[root@localhost data]# vi /etc/pam.d/login session required /lib64/security/pam_limits.so session required pam_limits.so
6、修改配置-3
[root@localhost data]# 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
source /etc/profile
7、创建目录
[root@localhost data]# mkdir -p /data/u01/app/oracle [root@localhost data]# chown -R oracle:oinstall /data/u01/app/ [root@localhost data]# chmod -R 775 /data/u01/app/
8、配置oracle用户环境变量
[root@localhost data]# su - oracle cp /home/oracle/.bash_profile /home/oracle/.bash_profile.bak echo "umask 022">> /home/oracle/.bash_profile echo "export ORACLE_BASE=/data/u01/app/oracle">> /home/oracle/.bash_profile echo "export ORACLE_HOME=/data/u01/app/oracle/product/12.2.0/dbhome_1">> /home/oracle/.bash_profile echo "export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib">> /home/oracle/.bash_profile echo "export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib">> /home/oracle/.bash_profile echo "export PATH=$PATH:$ORACLE_HOME/bin">> /home/oracle/.bash_profile echo "export ORACLE_SID=orcl">> /home/oracle/.bash_profile
source /home/oracle/.bash_profile
四、安装包权限设置
1、root权限下,把安装包放到/data下,并把拥有者权限给oracle:oinstall
[root@localhost data]# chown -R oracle:oinstall /data/ [root@localhost data]# chown oracle:oinstall /data/oracle_linux_12CR2_12.2.0.1.0__database.zip
2、解压安装包
[oracle@localhost data]$ unzip /data/oracle_linux_12CR2_12.2.0.1.0__database.zip
五、数据库配置及安装
1、创建/data/rsp_install目录,用于复制“安装脚本”
进入oracle用户: [root@localhost data]# su - oracle [oracle@localhost data]$ mkdir /data/rsp_install
2、复制“安装脚本”
[oracle@localhost data]$ cp -r /data/database/response/*.rsp /data/rsp_install/
3、静默安装配置——安装脚本更改
[oracle@localhost data]$ chmod 700 /data/rsp_install/*.rsp
[oracle@localhost data]$ vi /data/rsp_install/db_install.rsp oracle.install.option=INSTALL_DB_SWONLY // 安装类型 UNIX_GROUP_NAME=oinstall // 安装组 INVENTORY_LOCATION=/data/u01/app/oraInventory //INVENTORY目录(不填就是默认值) ORACLE_HOME=/data/u01/app/oracle/product/12.2.0/dbhome_1 ORACLE_BASE=/data/u01/app/oracle oracle.install.db.InstallEdition=EE // 企业版本 oracle.install.db.OSDBA_GROUP=dba oracle.install.db.OSOPER_GROUP=oinstall oracle.install.db.OSBACKUPDBA_GROUP=oinstall oracle.install.db.OSDGDBA_GROUP=oinstall oracle.install.db.OSKMDBA_GROUP=oinstall oracle.install.db.OSRACDBA_GROUP=oinstall oracle.install.db.config.starterdb.type=GENERAL_PURPOSE //数据库类型 oracle.install.db.config.starterdb.globalDBName=orcl oracle.install.db.config.starterdb.SID=orcl oracle.install.db.config.starterdb.memoryLimit=8192 //自动管理内存的内存(M) oracle.install.db.config.starterdb.password.ALL=oracle //设定所有数据库用户使用同一个密码 oracle.install.db.config.starterdb.enableRecovery=true //归档日志是否要开启,开启为true,不开为false或默认 oracle.install.db.config.starterdb.storageType= //恢复区存储方式,选空默认即可 SECURITY_UPDATES_VIA_MYORACLESUPPORT=false //不允许用户设置My Oracle Support凭据的密码。 DECLINE_SECURITY_UPDATES=true //不配置安全更新
4、静默安装开始
[oracle@localhost database]$ cd /data/database/ [oracle@localhost database]$ ./runInstaller -silent -responseFile /data/rsp_install/db_install.rsp
注:如果出现错误,可以根据日志log进行排查
以root用户执行语句As a root user, execute the following script(s): /data/u01/app/oraInventory/orainstRoot.sh /data/u01/app/oracle/product/12.2.0/dbhome_1/root.sh
六、静默创建监听
1、查看配置文件/data/rsp_install/netca.rsp
默认情况下,有如下配置,第一个监听直接用默认即可
LISTENER_NUMBER=1 LISTENER_NAMES={"LISTENER"} LISTENER_PROTOCOLS={"TCP;1521"}
2、运行配置进行安装
[oracle@localhost ~]$ netca /silent /responsefile /data/rsp_install/netca.rsp
安装完成会自动启动监听,因为没有创建实例,所以无提示实例服务
七、静默创建数据库实例
1、静默建库配置文件修改
[oracle@localhost ~]$ vi /data/rsp_install/dbca.rsp responseFileVersion=/oracle/assistants/rspfmt_dbca_response_schema_v12.2.0 gdbName=orcl #32行 全局数据库名 sid=orcl #42行 系统标识符 databaseConfigType=SI #可以配SI/RAC/RACONENODEcreateAsContainerDatabase=false #容器如果不创建就用false,创建就用True templateName=/data/u01/app/oracle/product/12.2.0/dbhome_1/assistants/dbca/templates/General_Purpose.dbc #此处对应模板 sysPassword=oracle #Password for SYS user systemPassword=oracle #Password for SYSTEM user oracleHomeUserPassword=oracle #Password for Windows Service user emExpressPort=5500 #配置EM端口,此处好像没什么用,数据库装完后,直接在sql执行 exec DBMS_XDB_CONFIG.SETHTTPPORT(5500);即可 characterSet=AL32UTF8 nationalCharacterSet=AL16UTF16 listeners=LISTENER datafileJarLocation={ORACLE_HOME}/assistants/dbca/templates datafileDestination={ORACLE_BASE}/oradata/{DB_UNIQUE_NAME} recoveryAreaDestination={ORACLE_BASE}/fast_recovery_area/{DB_UNIQUE_NAME} #快速恢复区,默认是fast_recovery_area memoryPercentage=60 #Oracle物理内存的百分比 databaseType=MULTIPURPOSE #默认即为MULTIPURPOSE automaticMemoryManagement=false #自动内存管理AMM默认为true,但默认无用,必须设置为true才可以,amm模式下,总内存不能大于4G,否则不能使用amm功能 totalMemory=8192 #以MB为单位分配给Oracle的总内存#创建容器数据库需要设置为True,默认false
2、静默安装实例
[oracle@localhost ~]$dbca -silent -createDatabase -responseFile /data/rsp_install/dbca.rsp
3、一句执行静默安装、静默删除
(1)静默安装实例
su oracle -c "/u01/app/oracle/product/11.2.0/EE/bin/dbca -silent -createDatabase -templateName General_Purpose.dbc -gdbname BRCGS -sid BRCGS -responseFile NO_VALUE -characterSet ZHS16GBK -totalMemory 32768 -emConfiguration LOCAL -dbsnmpPassword oracle -sysPassword oracle -systemPassword oracle"
(2)静默删除实例
su oracle -c "/data/u01/app/oracle/product/12.2.0/dbhome_1/bin/dbca -silent -deleteDatabase -sourcedb orcl -sid orcl -sysDBAUserName system -sysDBAPassword oracle"
八、安装rlwrap:
1、安装报错:
[root@localhost data]# rpm -ivh rlwrap-0.42-1.el6.x86_64.rpm warning: rlwrap-0.42-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY error: Failed dependencies: perl >= 0:5.006 is needed by rlwrap-0.42-1.el6.x86_64 perl(AutoLoader) is needed by rlwrap-0.42-1.el6.x86_64 perl(Carp) is needed by rlwrap-0.42-1.el6.x86_64 perl(Config) is needed by rlwrap-0.42-1.el6.x86_64 perl(Data::Dumper) is needed by rlwrap-0.42-1.el6.x86_64 perl(Exporter) is needed by rlwrap-0.42-1.el6.x86_64 perl(Getopt::Std) is needed by rlwrap-0.42-1.el6.x86_64 perl(POSIX) is needed by rlwrap-0.42-1.el6.x86_64 perl(constant) is needed by rlwrap-0.42-1.el6.x86_64 perl(lib) is needed by rlwrap-0.42-1.el6.x86_64 perl(strict) is needed by rlwrap-0.42-1.el6.x86_64 perl(vars) is needed by rlwrap-0.42-1.el6.x86_64
2、安装perl
[root@localhost data]# yum install perl -y
3、再安装,仍然报错:
[root@localhost data]# rpm -ivh rlwrap-0.42-1.el6.x86_64.rpm warning: rlwrap-0.42-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY error: Failed dependencies: perl(Data::Dumper) is needed by rlwrap-0.42-1.el6.x86_64
4、安装perl-Data-Dumper.x86_64
[root@localhost data]# yum install perl-Data-Dumper -y
5、再安装rlwrap,成功安装
[root@localhost data]# rpm -ivh rlwrap-0.42-1.el6.x86_64.rpm warning: rlwrap-0.42-1.el6.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY Preparing... ################################# [100%] Updating / installing... 1:rlwrap-0.42-1.el6 ################################# [100%]
6、设置alias
[oracle@localhost ~]$ vi /home/oracle/.bashrc alias sqlplus='rlwrap sqlplus' alias rman='rlwarp rman'[oracle@localhost ~]$ source /home/oracle/.bashrc 再进入sqlplus就可以翻页和回退了。生效配置
九、问题解决:
1:automaticMemoryManagement
设置的为空,也就是默认的true,但不起作用,必须要给参数输入true后,才会安装amm模式
2:amm模式下,总内存不能大于4G,否则不能使用amm功能
3、Specified SGA size is greater than the shmmax on the system.This might make database creation to fail with ORA-27125 - Unable to create shared memory segment error.
ACTION: Specify SGA size lesser than or equal to the shmmax on the system.
解决:如果上述出现,去/etc/sysctl.conf中设置shmmx要大即可
4、archive log模式如何在配置文件中,直接创建启用?
archive log 模式启用在静默中没有选项,数据库创建完成后,直接在sql 启用即可。虽然没有启用方式,但可以设置归档日志路径
5、EM如何在静默中创建[em在静默中没有选项,数据库创建完成后,直接使用exec命令进行创建即可]
SQL> exec DBMS_XDB_CONFIG.SETHTTPPORT(5500);#且可以随时改端口号
6、默认值,字符集是什么样的
NLS_NCHAR_CHARACTERSET AL16UTF16
NLS_CHARACTERSET AL32UTF8
文章评论