很多同学使用图形化安装oracle数据库,可是生产上大多数,是不会安装图形化包的,所以必须掌握怎么静默安装oracle数据库,下面就详细介绍怎么静默安装oracle11g数据库。
vi /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=host100
vi /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.0.100 host100
先检查哪些包没安装
for i in binutils compat-gcc-44 compat-libstdc++-33 control-center
gcc gcc-c++ glibc glibc-common glibc-devel libaio libgcc elfutils-libelf-devel libstdc++ libstdc++-devel libXp make compat-libcap1 compat-libstdc++-33 libaio-devel sysstat unixODBC unixODBC-devel kshdo rpm -q $i &>/dev/null || F="$F $i"
done ;echo $F;unset F’
缺少的包,用YUM安装就可以
vi /etc/sysctl.conf 到末尾 以下只出自oracle-rdbms-server-11gR2-preinstall自动做的修改
用#注释掉kernel.shmmax和kernel.shmall开头的两行
添加如下:
kernel.shmmax = 4398046511104
kernel.shmall = 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
fs.aio-max-nr = 1048576
fs.file-max = 6815744
vm.swAppiness=10
以上参数为使用oracle 验证包自动配置的参数结果,vm.swappiness=10为减少使用SWAP,该值默认是60
kernel.shmall:表示共享内存总量,以页为单位
kernel.shmmax:参数用来定义单个共享内存段的最大值,单位为Byte(字节)。
可以用一下脚本,设置kernel.shmall,kernel.shmmax参数值,其它值不用修改
#!/bin/bash
page_size=`getconf PAGE_SIZE`
phys_pages=`getconf _PHYS_PAGES`
if [ -z "$page_size" ]; then
echo Error: cannot determine page size
exit 1
fi
if [ -z "$phys_pages" ]; then
echo Error: cannot determine number of memory pages
exit 2
fi
shmall=`expr $phys_pages`
shmmax=`expr $shmall * $page_size`
echo # Maximum shared segment size in bytes
echo kernel.shmmax = $shmmax
echo # Maximum number of shared memory segments in pages
echo kernel.shmall = $shmall
vi /etc/security/limits.conf 末尾添加:
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft nproc 16384
oracle hard nproc 16384
oracle soft stack 10240
oracle hard stack 32768
vi /etc/pam.d/login 末尾添加:
session required pam_limits.so
关闭的防火墙:
linux6:
service iptables stop
chkconfig iptables off
linux7:
systemctl stop firewalld
systemctl mask firewalld
禁用selinux:
setenforce 0
getenforce
vi /etc/selinux/config 确保以下内容
SELINUX=disabled
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
umask 022
fi
groupadd -g 501 oinstall
groupadd -g 502 dba
useradd -u 501 -g oinstall -G dba oracle -d /home/oracle
passwd oracle
[root@ ~]#
mkdir -p /u01/app/oracle/product/11.2.0/db_1
mkdir -p /oracle/oradata
chmod -R 775 /oracle
chmod -R 775 /u01
chown -R oracle:oinstall /oracle
chown -R oracle:oinstall /u01
su - oracle
vi .bash_profile 末尾添加:
export ORACLE_BASE=/u01/app
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export ORACLE_SID=crmdbexport PATH=$PATH:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
export NLS_LANG=AMERICAN_AMERICA.ZHS16GBKexport ORACLE_UNQNAME=crmdbexport NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
如果是UT8,可以设置export NLS_LANG=AMERICAN_AMERICA.AL32UTF8
fallocate -l 250M /swapfile
chmod 600 /swapfile
mkswap /swapfileswapon /swapfileswapon -s
在/etc/fstab中添加以下内容
/swapfile swap swap sw 0 0
INVENTORY_LOCATION不要存放在ORACLE_BASE之下
cat db_install.rsp |grep -v "#"|sed '/^ *$/d'
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0oracle.install.option=INSTALL_DB_SWONLYORACLE_HOSTNAME=cbov10-tidb57-206UNIX_GROUP_NAME=oinstallINVENTORY_LOCATION=/u01/app/oraInventorySELECTED_LANGUAGES=en,zh_CNORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/app/oracleoracle.install.db.InstallEdition=EEoracle.install.db.EEOptionsSelection=falseoracle.install.db.optionalComponents=oracle.rdbms.partitioning:11.2.0.4.0,oracle.oraolap:11.2.0.4.0,oracle.rdbms.dm:11.2.0.4.0,oracle.rdbms.dv:11.2.0.4.0,oracle.rdbms.lbac:11.2.0.4.0,oracle.rdbms.rat:11.2.0.4.0
oracle.install.db.DBA_GROUP=dbaoracle.install.db.OPER_GROUP=oinstallSECURITY_UPDATES_VIA_MYORACLESUPPORT=false
DECLINE_SECURITY_UPDATES=trueoracle.installer.autoupdates.option=SKIP_UPDATES./runInstaller -silent -showProgress -responseFile /u01/soft/database/response/dbinstall.rsp
export DISPLAY=127.0.0.1:1.0
netca -silent -responsefile /u01/soft/database/response/netca.rsp在/u01/app/oracle/product/11.2.0/db_1/network/admin目录下创建tnsnames.ora文件
CRMDB = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = cbov10-tidb57-206)(PORT = 1521))
(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = crmdb) ) )
如果监听一直出不来,可以使用alter system register手工注册
[GENERAL]
RESPONSEFILE_VERSION = "11.2.0"
OPERATION_TYPE = "createDatabase"
[CREATEDATABASE]GDBNAME = "crmdb"
SID="crmdb"
TEMPLATENAME = "General_Purpose.dbc"
CHARACTERSET = "ZHS16GBK"
TOTALMEMORY = "512"
SYSPASSword = "oracle"
SYSTEMPASSWORD = "oracle"
/u01/app/oracle/product/11.2.0/db_1/assistants/dbca/templates/General_Purpose.dbc
在上述文件中,可以修改数据库文件,redo,归档模式,Controlfile存放位置和大小
dbca -silent -initParams log_archive_dest_1='location=/oracle/archivelog' -responseFile /u01/soft/database/response/db_create.rsp
设置timestamp时间显示格式
alter system set nls_date_format='yyyy-mm-dd hh24:mi:ss' scope=spfile;
/u03/app/oracle/product/11.2.0/db_1/assistants/dbca/templates/General_Purpose.dbc文件修改
<?xml version = '1.0'?>
<DatabaseTemplate name="General_Purpose" description="" version="11.1.0.0.0">
<CommonAttributes>
<option name="OMS" value="false"/>
<option name="JSERVER" value="true"/>
<option name="SPATIAL" value="true"/>
<option name="IMEDIA" value="true"/>
<option name="XDB_PROTOCOLS" value="true">
<tablespace id="SYSAUX"/>
</option>
<option name="ORACLE_TEXT" value="true">
<tablespace id="SYSAUX"/>
</option>
<option name="SAMPLE_SCHEMA" value="false"/>
<option name="CWMLITE" value="true">
<tablespace id="SYSAUX"/>
</option>
<option name="EM_REPOSITORY" value="true">
<tablespace id="SYSAUX"/>
</option>
<option name="APEX" value="true"/>
<option name="OWB" value="true"/>
<option name="DV" value="false"/>
</CommonAttributes>
<Variables/>
<CustomScripts Execute="false"/>
<InitParamAttributes>
<InitParams>
<initParam name="db_name" value=""/>
<initParam name="dispatchers" value="(PROTOCOL=TCP) (SERVICE={SID}XDB)"/>
<initParam name="audit_file_dest" value="{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/adump"/>
<initParam name="compatible" value="11.2.0.0.0"/>
<initParam name="remote_login_passwordfile" value="EXCLUSIVE"/>
<initParam name="processes" value="150"/>
<initParam name="undo_tablespace" value="UNDOTBS1"/>
<initParam name="control_files" value="("{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/control01.ctl", "{ORACLE_BASE}/flash_recovery_area/{DB_UNIQUE_NAME}/control02.ctl")"/>
<initParam name="diagnostic_dest" value="{ORACLE_BASE}"/>
<initParam name="db_recovery_file_dest" value="{ORACLE_BASE}/flash_recovery_area"/>
<initParam name="audit_trail" value="db"/>
<initParam name="memory_target" value="250" unit="MB"/>
<initParam name="db_block_size" value="8" unit="KB"/>
<initParam name="open_cursors" value="300"/>
<initParam name="db_recovery_file_dest_size" value="" unit="MB"/>
<initParam name="nls_date_format" value="yyyy-mm-dd hh24:mi:ss"/>
</InitParams>
<MiscParams>
<databaseType>MULTIPURPOSE</databaseType>
<maxUserConn>20</maxUserConn>
<percentageMemTOSGA>40</percentageMemTOSGA>
<customSGA>false</customSGA>
<archiveLogMode>true</archiveLogMode>
<initParamFileName>{ORACLE_BASE}/admin/{DB_UNIQUE_NAME}/pfile/init.ora</initParamFileName>
</MiscParams>
<SPfile useSPFile="true">{ORACLE_HOME}/dbs/spfile{SID}.ora</SPfile>
</InitParamAttributes>
<StorageAttributes>
<DataFiles>
<Location>{ORACLE_HOME}/assistants/dbca/templates/Seed_Database.dfb</Location>
<SourceDBName>seeddata</SourceDBName>
<Name id="1" Tablespace="SYSTEM" Contents="PERMANENT" Size="670" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/system01.dbf</Name>
<Name id="2" Tablespace="SYSAUX" Contents="PERMANENT" Size="440" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/sysaux01.dbf</Name>
<Name id="3" Tablespace="UNDOTBS1" Contents="UNDO" Size="25" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/undotbs01.dbf</Name>
<Name id="4" Tablespace="USERS" Contents="PERMANENT" Size="5" autoextend="true" blocksize="8192">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/users01.dbf</Name>
</DataFiles>
<TempFiles>
<Name id="1" Tablespace="TEMP" Contents="TEMPORARY" Size="20">{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/temp01.dbf</Name>
</TempFiles>
<ControlfileAttributes id="Controlfile">
<maxDatafiles>100</maxDatafiles>
<maxLogfiles>16</maxLogfiles>
<maxLogMembers>3</maxLogMembers>
<maxLogHistory>1</maxLogHistory>
<maxInstances>8</maxInstances>
<image name="control01.ctl" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
<image name="control02.ctl" filepath="{ORACLE_BASE}/flash_recovery_area/{DB_UNIQUE_NAME}/"/>
</ControlfileAttributes>
<RedoLogGroupAttributes id="1">
<reuse>false</reuse>
<fileSize unit="KB">51200</fileSize>
<Thread>1</Thread>
<member ordinal="0" memberName="redo01a.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
<member ordinal="1" memberName="redo01b.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
</RedoLogGroupAttributes>
<RedoLogGroupAttributes id="2">
<reuse>false</reuse>
<fileSize unit="KB">51200</fileSize>
<Thread>1</Thread>
<member ordinal="0" memberName="redo02a.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
<member ordinal="1" memberName="redo02b.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
</RedoLogGroupAttributes>
<RedoLogGroupAttributes id="3">
<reuse>false</reuse>
<fileSize unit="KB">51200</fileSize>
<Thread>1</Thread>
<member ordinal="0" memberName="redo03a.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
<member ordinal="1" memberName="redo03b.log" filepath="{ORACLE_BASE}/oradata/{DB_UNIQUE_NAME}/"/>
</RedoLogGroupAttributes>
</StorageAttributes>
</DatabaseTemplate>
解除密码180天有效期限制,这个一步非常重要
alter profile default limit password_life_time unlimited;