一、静默安装oracle11G
1.配置本地yum并装oracle所需包[root@linux01 /]# yum install -y libXp* xterm* unixODBC sysstat* make* libstdc++* libgomp* libgcc* libaio* kernel-headers* glibc gcc* elfutils binutils* caching-nameserver compat-libcap1* compat-libstdc++-33* openssh xdpyinfo vi unzip2.添加主机名与IP对应记录vi /etc/hosts
[root@linux01 ~]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4::1 localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.80.173 linux013.关闭Selinux[root@linux01 sysconfig]# vi selinux# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:# enforcing - SELinux security policy is enforced.# permissive - SELinux prints warnings instead of enforcing.# disabled - No SELinux policy is loaded.SELINUX=disable# SELINUXTYPE= can take one of these two values:# targeted - Targeted processes are protected,# mls - Multi Level Security protection.SELINUXTYPE=targeted"selinux" 13L, 456C written
[root@linux01 sysconfig]# pwd/etc/sysconfig[root@linux01 sysconfig]# 4.将oracle11g安装包传到本地5.系统配置groupadd -g 1000 oinstallgroupadd -g 1200 asmadmingroupadd -g 1201 dbagroupadd -g 1202 operuseradd -u 1000 -g oinstall -G dba,oper -d /home/grid -s /bin/bash -c "Grid Infrastructure Owner" -m oraclepasswd oracle创建相应安装目录mkdir -p /u01/app/oraclemkdir -p /u01/app/oraInventorymkdir -p /u01/app/oracle/oradatamkdir -p /u01/app/oracle/recovery_datachown -R oracle:oinstall /u01/app/chmod -R 755 /u01/app/修改系统内核参数fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 //此行默认已有,确认不低于此数即可 kernel.shmmax = 536870912 //此行默认已有,确认不低于此数即可 kernel.shmmni = 4096 kernel.sem = 250 32000 100128 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# sysctl -p #使配置生效调整会话限制vi /etc/pam.d/login 文件最后添加:session required pam_limits.so调整oracle用户的进程数与最大文件句柄数vi /etc/security/limits.conf 文件的最后添加:oracle soft nproc 10000oracle hard nproc 16384oracle soft nofile 52768oracle hard nofile 6553root soft nproc 2047root hard nproc 16384root soft nofile 1024root hard nofile 65536soft是最小值,hard是最大值,nofile是文件句柄,也就是这个用户能打开的文件数,nproc是进程数6.增加环境变量
cat /home/oracle/.bash_profile # .bash_profile# Get the aliases and functions
if [ -f ~/.bashrc ]; then . ~/.bashrcfi# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1export ORACLE_SID=testdb export ORACLE_TERM=xtermexport PATH=/usr/sbin:$PATHexport PATH=/u01/app/ogg:$ORACLE_HOME/bin:$PATHexport LD_LIBRARY_PATH=/u01/app/ogg:$ORACLE_HOME/lib:/lib:/usr/lib:$LD_LIBRARY_PATHexport CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlibexport NLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS"export NLS_LANG=AMERICAN_AMERICA.AL32UTF8export LANG=Cexport ORACLE_UNQNAME=testdbsource /home/oracle/.bash_profile
7.应答文件修改
路径/home/oracle/database/response在db_install.rsp中添加oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=linux01UNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/u01/app/oraInventorySELECTED_LANGUAGES=en,zh_CN,zh_TWORACLE_BASE=/u01/app/oracleORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1oracle.install.db.InstallEdition=EEoracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=oinstalloracle.install.db.config.starterdb.characterSet=AL32UTF8oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGEoracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/app/oracle/oradataoracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/recovery_dataoracle.install.db.config.starterdb.globalDBName=testdboracle.install.db.config.starterdb.SID=testdboracle.install.db.config.starterdb.memoryLimit=500oracle.install.db.config.starterdb.password.ALL=oracleSECURITY_UPDATES_VIA_MYORACLESUPPORT=falseDECLINE_SECURITY_UPDATES=true8.静默安装oracle11g软件
./runInstaller -silent -responseFile /home/oracle/database/response/db_install.rsp #查看日志看进度 /u01/app/oraInventory/logs/installActions2018-05-29_07-17-34PM.log安装成功[oracle@linux01 database]$ The installation of Oracle Database 11g was successful.Please check '/u01/app/oraInventory/logs/silentInstall2019-07-10_11-25-57PM.log' for more details.As a root user, execute the following script(s):
1. /u01/app/oraInventory/orainstRoot.sh 2. /u01/app/oracle/product/11.2.0/db_1/root.sh Successfully Setup Software.root用户执行两个脚本即完成软件安装。
命令行创建监听
静默建库*********************************************************************vi /home/oracle/database/response/dbca.rsp, 覆盖以下选项:注意:一定要按原来的参数所在的位置修改,不然报错
复制代码
RESPONSEFILE_VERSION = "11.2.0" //不能更改 OPERATION_TYPE = "createDatabase" GDBNAME = "dg1" //全局数据库的名字=SID+主机域名 SID = "dg1" //对应的实例名字 TEMPLATENAME = "General_Purpose.dbc" //建库用的模板文件 SYSPASSWORD = "sys" //SYS管理员密码 SYSTEMPASSWORD = "sys" //SYSTEM管理员密码 DATAFILEDESTINATION = /u01/app/oracle/oradata //数据文件存放目录 RECOVERYAREADESTINATION=/u01/app/oracle/oradata_back //恢复数据存放目录 CHARACTERSET = " AL32UTF8" //字符集,重要!!! 建库后一般不能更改,所以建库前要确定清楚。 TOTALMEMORY = "4069" //oracle内存4069MB复制代码**********************************************************************netca /silent /responsefile /home/oracle/database/response/netca.rsp二、手动创建数据库。
1.指定sidexport ORACLE_SID=testdb2.创建pfile[root@linux01 dbs]# cat inittestdb.ora db_name='testdb'control_files='/u01/app/oracle/oradata/testdb/control01.ctl','/u01/app/oracle/oradata/testdb/control02.ctl'memory_target=900m 3.打开空实例创建spfilesqlplus / as sysdbacreate spfile from pfile;
startup nomount 启动到nomount状态。
4.创建createdb.sql
vi /home/oracle/createdb.sqlCREATE DATABASE testdb
USER SYS IDENTIFIED BY oracleUSER SYSTEM IDENTIFIED BY oracleLOGFILE GROUP 1 ('/u01/app/oracle/oradata/testdb/redo01a.log','/u01/app/oracle/oradata/testdb/redo01b.log') SIZE 100M BLOCKSIZE512,GROUP 2 ('/u01/app/oracle/oradata/testdb/redo02a.log','/u01/app/oracle/oradata/testdb/redo02b.log') SIZE 100M BLOCKSIZE 512,GROUP 3 ('/u01/app/oracle/oradata/testdb/redo03a.log','/u01/app/oracle/oradata/testdb/redo03b.log') SIZE 100M BLOCKSIZE 512MAXLOGFILES 5MAXLOGMEMBERS 5MAXLOGHISTORY 1MAXDATAFILES 100CHARACTER SET AL32UTF8NATIONAL CHARACTER SET AL16UTF16EXTENT MANAGEMENT LOCALDATAFILE '/u01/app/oracle/oradata/testdb/system01.dbf' SIZE 325M REUSESYSAUX DATAFILE '/u01/app/oracle/oradata/testdb/sysaux01.dbf' SIZE 325M REUSEDEFAULT TABLESPACE usersDATAFILE '/u01/app/oracle/oradata/testdb/users01.dbf'SIZE 500M REUSE AUTOEXTEND ON MAXSIZE UNLIMITEDDEFAULT TEMPORARY TABLESPACE tempts1 TEMPFILE '/u01/app/oracle/oradata/testdb/temp01.dbf'SIZE 20M REUSEUNDO TABLESPACE undotbsDATAFILE '/u01/app/oracle/oradata/testdb/undotbs01.dbf'SIZE 200M REUSE AUTOEXTEND ON MAXSIZE UNLIMITED;sqlplus / as sysdba
@createdb.sql
5.执行脚本
@?/rdbms/admin/catalog.sql
@?/rdbms/admin/catproc.sql@?/rdbms/admin/utlrp.sql@?/sqlplus/admin/pupbld.sql6.手工创建数据库成功SYS@testdb> select open_mode from v$database;OPEN_MODE
--------------------READ WRITE1 row selected.
SYS@testdb>