ITPub博客

静默安装Oracle11g数据库

原创 Oracle 作者:贺子_DBA时代 时间:2018-06-30 23:01:39 0 删除 编辑
1.1. 修改密码及创建目录和权限
1) 创建oracle用户和组
[root@ENMOEDU ~]# groupadd oinstall
[root@ENMOEDU ~]# groupadd dba
[root@ENMOEDU ~]# useradd -g oinstall -G dba -s /bin/bash oracle
[root@ENMOEDU ~]# passwd oracle
Changing password for user oracle.
New UNIX password:
BAD PASSWORD: it is based on a dictionary word
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
2) 创建相关目录并赋权
[root@ENMOEDU ~]# chown -R oracle:oinstall /data/u01
[root@ENMOEDU ~]# chmod -R 755 /data/u01
1.2. 设置oracle用户环境变量
[root@ENMOEDU ~]# su - oracle
[oracle@ENMOEDU ~]$
[oracle@ENMOEDU ~]$ vi .bash_profile
注:在文件的最下方增加如下内容
export ORACLE_BASE=/data/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/dbhome_1
export ORACLE_SID=ENMOEDU
export PATH=$PATH:$HOME/bin:$ORACLE_HOME/bin
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib
修改完成,使其修改生效,如下:
[oracle@ENMOEDU ~]$ . .bash_profile
[oracle@ENMOEDU ~]$
或者
[oracle@ENMOEDU ~]$ source .bash_profile
[oracle@ENMOEDU ~]$
再或者注销重新登录
注:
ORACLE_BASE:oracle产品基目录
ORACLE_HOME:数据库产品目录通常情况下HOME目录是BASE的子目录
ORACLE_SID:操作系统和oracle实例关联的纽带
PATH:将安装后的oracle命令追加到执行搜索路径
LD_LIBRARY_PATH:动态库的位置
1.3. 上传oracle安装介质并解压安装database软件
1)已经上传成功,解压之后会产生一个database目录;
并且/meadia/database/response下有db_install.rsp、dbca.rsp和netca.rsp三个应答文件,分别数据库安装文件、建立数据库实例和监听配置安装文件
[oracle@ENMOEDU software]$ unzip p13390677_112040_Linux-x86-64_1of7.zip
[oracle@ENMOEDU software]$ unzip p13390677_112040_Linux-x86-64_2of7.zip
[oracle@jianguan-EAST-fanxiqian-32 media]$ ll
database  
p13390677_112040_Linux-x86-64_1of7.zip  p13390677_112040_Linux-x86-64_2of7.zip
2)提前安装必要的包:
用yum安装:
[root@jianguan-EAST-fanxiqian-32 ~]yum install -y binutils*
yum install -y compat-libstdc*
yum install -y elfutils-libelf*
yum install -y gcc*
yum install -y glibc*
yum install -y ksh*
yum install -y libaio*
yum install -y libgcc*
yum install -y libstdc*
yum install -y make*
yum install -y sysstat*
yum install libXp* -y
yum install -y glibc-kernheaders
3)进入到database/response/目录,然后编辑用于安装Oracle软件的应答文件db_install.rsp;
[oracle@jianguan-EAST-fanxiqian-32 database]$ cd /media/database/response/
[oracle@jianguan-EAST-fanxiqian-32 database]$ vi db_install.rsp
oracle.install.option=INSTALL_DB_SWONLY            //29行 安装类型
ORACLE_HOSTNAME=jianguan-EAST-fanxiqian-32         //37行 主机名称
UNIX_GROUP_NAME=oinstall                              //42行 安装组
INVENTORY_LOCATION=/opt/oracle/inventory           //47行INVENTORY目录
SELECTED_LANGUAGES=zh_CN                              //78行 选择语言
ORACLE_HOME=/data/u01/app/oracle/product/11.2.0/dbhome_1   //83行oracle_home地址
ORACLE_BASE=/data/u01/app/oracle                               //88行oracle_base地址
oracle.install.db.InstallEdition=EE                //99行oracle版本
oracle.install.db.DBA_GROUP=dba                     //142行dba用户组
oracle.install.db.OPER_GROUP=oinstall              //147行oper用户组
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE  //160行 数据库类型
oracle.install.db.config.starterdb.globalDBName=eastfxq  //165行globalDBName
oracle.install.db.config.starterdb.SID=eastfxq             //170行SID
oracle.install.db.config.starterdb.memoryLimit=92160        //192行 自动管理内存的最小内存(M)
oracle.install.db.config.starterdb.password.ALL=oracle    //233行 设定所有数据库用户使用同一个密码
DECLINE_SECURITY_UPDATES=true             //385行 设置安全更新,一定要设置否则报错;
3)执行创建软件的脚本:
1.执行脚本之前需要编辑/etc/hosts
查看当前的主机名,一定注意需要填写当前的主机名,也就是hostname显示的名字!
[root@jianguan-EAST-fanxiqian-32 inventory]# hostname
jianguan-EAST-fanxiqian-32.38
[root@jianguan-EAST-fanxiqian-32 inventory]# vi /etc/hosts   ##添加如下内容,否则会后面会报错,说不能识别hostname,
10.1.32.38  jianguan-EAST-fanxiqian-32.38
2.执行安装脚本!
[oracle@jianguan-EAST-fanxiqian-32 database]$ ./runInstaller -silent -responseFile /media/database/response/db_install.rsp -ignorePrereq
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB.   Actual 86279 MB    Passed
Checking swap space: must be greater than 150 MB.   Actual 17999 MB    Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-06-25_12-19-25PM. Please wait ...[oracle@jianguan-EAST-fanxiqian-32 database]$
[oracle@jianguan-EAST-fanxiqian-32 database]$
[oracle@jianguan-EAST-fanxiqian-32 database]$
[oracle@jianguan-EAST-fanxiqian-32 database]$ You can find the log of this install session at:
 /home/oracle/inventory/logs/installActions2018-06-25_12-19-25PM.log
3).可以通过查看前边提示的日志来跟进创建的过程:
[oracle@jianguan-EAST-fanxiqian-32 database]$tail  -f 100 /home/oracle/inventory/logs/installActions2018-06-25_12-19-25PM.log
4)最后按着提示打开新的终端,以root身份登录,执行脚本:
#/home/oracle/inventory/orainstRoot.sh
#/data/u01/app/oracle/product/11.2.0/dbhome_1/db_1/root.sh
至此Oracle软件创建成功。。。。。。。
1.4. 安装监听软件
1)编辑necat.rsp文件;
netca.rsp,主要改动以下参数配置:
INSTALL_TYPE=""custom""                   #安装的类型
LISTENER_NUMBER=1                          #监听器数量
LISTENER_NAMES={"LISTENER"}              #监听器的名称列表
LISTENER_PROTOCOLS={"TCP;1521"}         #监听器使用的通讯协议列表
LISTENER_START=""LISTENER""              #监听器启动的名称
 
2)执行netca来创建监听软件:
[oracle@jianguan-EAST-fanxiqian-32 response]$netca /silent /responseFile  /media/database/response/netca.rsp
3)尝试启动监听(有这个命令即可):
[oracle@jianguan-EAST-fanxiqian-32 response]$lsnrctl  start
至此监听创建成功。。。。
1.5. 创建Oracle数据库
1)编辑创建数据库的应答文件dbca.rsp,主要需要修改的参数如下(其余默认即可)
RESPONSEFILE_VERSION ="11.2.0"            //不能更改
OPERATION_TYPE ="createDatabase"
GDBNAME ="eastfxq"                          //数据库的名字
SID ="eastfxq"                            //对应的实例名字
TEMPLATENAME ="General_Purpose.dbc"       //建库用的模板文件 有两个一个为新的名字
SYSPASSWORD ="oracle"                     //SYS管理员密码
SYSTEMPASSWORD ="oracle"                  //SYSTEM管理员密码
SYSMANPASSWORD= "oracle"
DBSNMPPASSWORD= "oracle"
DATAFILEDESTINATION =/data/u01/app/oracle/oradata     
//数据文件存放目录,默认为$ORACLE_BASE/oradata;
RECOVERYAREADESTINATION=/data/u01/app/oracle/flash_recovery_area   
//快速恢复区的目录,默认为$ORACLE_BASE/flash_recovery_area;
CHARACTERSET ="ZHS16GBK"                                  
//字符集,重要!!!建库后一般不能更改,所以建库前要确定清楚;
TOTALMEMORY ="92160"                      //92160MB,物理内存*80%左右
2)执行dbca,开始创建数据库;
[oracle@jianguan-EAST-fanxiqian-32 response]$ dbca -silent -responseFile /media/database/response/dbca.rsp
Copying database files
1% complete
3% complete
11% complete
至此Oracle数据库创建成功。。。。。
1.6. 调整Oracle的参数以及配置:
1.关于Oracle数据库游标相关的参数
1)OPEN_CURSORS 每个会话最大的游标数(活动的SQL语句),推荐设置成500
SQL> alter system set open_cursors=200 scope=spfile;
2)session_cached_cursors  每个会话缓存的游标个数,推荐设置成 200
SQL> alter system set session_cached_cursors=200 scope=spfile;
2.关于存储的相关参数:
1)DB_FILES 数据库能创建的最大物理文件数,根据数据量大小可以设置成1500或者更多。
SQL> alter system set  db_files=1500 scope=spfile;
2)设置数据块(存储在物理文件或被缓存到SGA中)的大小,对于在线交易系统通常设置为8192,对于数据仓库可设置为16K或32K。默认是8192也就是8k;
3.关于Oracle的内存相关设置:
前提需要先调整/dev/shm的大小,保证初始化参数MEMORY_TARGET或MEMORY_MAX_TARGET不能大于共享内存(/dev/shm)
(1)查看大小
df -h /dev/shm
(2)修改大小 ,(注意格式,逗号后面不能有空格)
vi /etc/fstab
tmpfs /dev/shm tmpfs defaults,size=102400M 0 0
(3)重新挂载
umount /dev/shm
mount /dev/shm
(4)查看修改后的大小
df -h /dev/shm
不重起修改tmpfs大小 mount -o remount,size=100g /dev/shm
1)Oracle11g开启自动化内存管理:可以设置memory_target和memory_max_target:
(1)memory_target:该参数设置整个oracle数据库实例可以使用的内存量,oralce数据库实例在运行过程中会根据需求自动的调节SGA与PGA的大小。可以使用相应的alter system命令动态的修改memory_target的值。该参数是动态初始化参数。
(2)memory_max_target:该参数设置oracle实例可以使用的最大内存量。在调整memory_target的值时必须保持以下的约束关系memory_target<=memory_max_target.该参数是静态初始化参数,修改需要重启才能生效。
Alter system  set memory_target=90g;
Alter system  set  memory_max_target=100g scope=spfile;   #(total_mem * 80%)
然后设置SGA_TARGET和PGA_AGGREGATE_TARGET的值,开启自动内存管理之后,这俩值代表各自的最小值:
Alter system  set SGA_TARGET=50G;               ##(memory_target*80%*80%)
Alter system  set PGA_AGGREGATE_TARGET=10G;  ##(memory_target*80%*20%)
2)不开启Oracle11g自动化内存管理,采用10g的自动化共享内存管理:
SGA_TARGET 当数据库使用自动共享内存管理方式时,SGA各内存区域总的内存大小。
推荐设置值:
在线交易系统: SGA_TARGET = (total_mem * 80%) * 80%
数据仓库: SGA_TARGET = (total_mem * 80%) * 50%
PGA_AGGREGATE_TARGET 设置与服务进程相关联的 PGA 内存大小。
推荐设置值:
在线交易系统: PGA_AGGREGATE_TARGET = (total_mem * 80%) * 20%
数据仓库: PGA_AGGREGATE_TARGET = (total_mem * 80%) * 50%
4.关于连接和会话:
PROCESSES 设置数据库实例能够启动的最大进程数,可设置为500~1000。
Alter system set PROCESSES =800 scope=spfile;
SESSIONS 数据库的最大会话数。默认值是(1.5 * PROCESSES) + 22。
Alter system set PROCESSES =1300 scope=spfile;
5. 添加日志组成员,提高redo的安全度!
SQL> alter database add logfile member '/oracle/logfile/redo1_02.log' to group 1;
Database altered.
SQL> alter database add logfile member '/oracle/logfile/redo2_02.log' to group 2;
Database altered.
SQL> alter database add logfile member '/oracle/logfile/redo3_02.log' to group 3;
Database altered.
SQL> select member from v$logfile;
 
MEMBER
--------------------------------------------------------------------------------
/data/u01/app/oracle/oradata/eastfxq/redo03.log
/data/u01/app/oracle/oradata/eastfxq/redo02.log
/data/u01/app/oracle/oradata/eastfxq/redo01.log
/oracle/logfile/redo1_02.log
/oracle/logfile/redo2_02.log
/oracle/logfile/redo3_02.log
6 rows selected.
6.关于rman的相关修改,参考如下:
RMAN> show all;
using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ACCDB are:
CONFIGURE RETENTION POLICY TO RECOVERY WINDOW OF 31 DAYS;
CONFIGURE BACKUP OPTIMIZATION ON;
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '/caadb/backup/accdb/backup/rman/20180629/accdb_lev0_201806290230_%F';
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BASIC' AS OF RELEASE 'DEFAULT' OPTIMIZE FOR LOAD TRUE ; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON ALL STANDBY;
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/home/oracle/app/oracle/product/11.2.0/dbhome_1/dbs/snapcf_accdb.f'; # default
7.关于归档的目录修改:以防默认选择的归档路径为快速恢复区!
SQL> alter system set log_archive_dest_1='location=/data/u01/app/oracle/archivelog'
8.可以适当修改快速恢复区的大小:
SQL> alter system set db_recovery_file_dest_size=6g;
 
1.7. 最后验证
1)查看实例名:
SQL> select instance_name from v$instance;
 
INSTANCE_NAME
----------------
Eastfxq
2)查看数据库名:
SQL> select  name from v$database;
 
NAME
---------
EASTFXQ
或者
SQL> select instance_name from v$instance;
 
INSTANCE_NAME
----------------
eastfxq
3)查看监听状态:
[oracle@jianguan-EAST-fanxiqian-32 ~]$ lsnrctl status
 
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 25-JUN-2018 17:12:57
 
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
 
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.1.32.38)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                25-JUN-2018 14:32:17
Uptime                    0 days 2 hr. 40 min. 39 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /data/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /data/u01/app/oracle/diag/tnslsnr/jianguan-EAST-fanxiqian-32/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.1.32.38)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "eastfxq" has 2 instance(s).
  Instance "eastfxq", status UNKNOWN, has 3 handler(s) for this service...
  Instance "eastfxq", status READY, has 1 handler(s) for this service...
Service "eastfxqXDB" has 1 instance(s).
  Instance "eastfxq", status READY, has 1 handler(s) for this service...
The command completed successfully
4)检查Oracle数据库的字符集:
SQL> select userenv('language') nls_lang from dual;
 
NLS_LANG
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
5)查看数据文件的目录:
SQL> select name from v$datafile;
 
NAME
--------------------------------------------------------------------------------
/data/u01/app/oracle/oradata/eastfxq/system01.dbf
/data/u01/app/oracle/oradata/eastfxq/sysaux01.dbf
/data/u01/app/oracle/oradata/eastfxq/undotbs01.dbf
/data/u01/app/oracle/oradata/eastfxq/users01.dbf
6)查看redo日志的路径:
SQL> select GROUP#,MEMBER from v$logfile;
 
    GROUP# MEMBER
--------------------------------------------------------------------------------------------
 3 /data/u01/app/oracle/oradata/eastfxq/redo03.log
 2 /data/u01/app/oracle/oradata/eastfxq/redo02.log
 1 /data/u01/app/oracle/oradata/eastfxq/redo01.log
 1 /oracle/logfile/redo1_02.log
 2 /oracle/logfile/redo2_02.log
 3 /oracle/logfile/redo3_02.log
6 rows selected.
至此Oracle数据库环境准备就绪。。。。。。
 

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29654823/viewspace-2157150/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2014-05-12

  • 博文量
    218
  • 访问量
    1506825