1、系统配置
1.1、系统版本
[root@dbserver~]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.6 (Maipo)
1.2、禁用SELinux
[root@dbserver~]# sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
1.3、创建用户与组
# groupadd oinstall
# groupadd dba
# groupadd oper
# useradd -g oinstall -G dba,oper oracle
# echo oracle_4U|passwd --stdin oracle
1.4、创建安装目录
[root@dbserver~]# mkdir -p /u01/app/oracle
[root@dbserver~]# mkdir -p /u01/app/oraInventory
[root@dbserver~]# mkdir -p /u01/app/oracle/oradata
[root@dbserver~]# mkdir -p /u01/app/oracle/fast_recovery_area
[root@dbserver~]# chown -R oracle:oinstall /u01/app/
[root@dbserver~]# chmod -R 755 /u01/app/
1.5、修改内核参数
# cat <<EOF>>/etc/sysctl.conf
kernel.shmmax = 277495689510912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
net.core.rmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_default = 262144
net.core.wmem_max = 1048586
fs.file-max = 6815744
kernel.shmall = 4294967296
net.ipv4.ip_local_port_range = 9000 65500
net.ipv4.tcp_tw_reuse = 1
net.core.somaxconn = 262144
net.ipv4.tcp_max_orphans = 262144
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syn_retries = 1
net.ipv4.tcp_fin_timeout = 1
net.ipv4.tcp_keepalive_time = 30
net.ipv4.tcp_keepalive_probes = 6
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_timestamps = 0
fs.aio-max-nr = 1048576
EOF
# /sbin/sysctl -p
1.6、修改系统限制
# cat <<EOF>>/etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
EOF
修改会话限制
# cat <<EOF>>/etc/pam.d/login
session required /lib64/security/pam_limits.so
EOF
1.7、修改环境变量
# su - oracle
$ cat <<EOF>>.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=\$ORACLE_BASE/product/11.2.0/db_1
export ORACLE_SID=orcl
export PATH=\$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=\$ORACLE_HOME/lib
EOF
$ source .bash_profile
1.8、添加全局变量
[root@dbserver ~]# cat <<EOF>>/etc/profile
export PATH=$PATH:/u01/app/oracle/product/11.2.0/db_1/bin
EOF
[root@dbserver ~]# source /etc/profile
1.9、配置yum源
# mount /dev/sr0 /mnt
# cat <<EOF>>/etc/yum.repos.d/oel7.repo
[oel7]
name=oel7
baseurl=file:///mnt
enable=1
gpgcheck=0
EOF
# yum makecache
1.10、安装包
# yum install -y bc binutils elfutils-libelf glibc glibc-devel ksh libaio libXrender libX11 libXau libXi libXtst libgcc libstdc++ libxcb make policycoreutils policycoreutils-python smartmontools sysstat gcc libaio-devel elfutils-libelf-devel gcc-c++ libstdc++-devel unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
# rpm -q bc binutils elfutils-libelf glibc glibc-devel ksh libaio libXrender libX11 libXau libXi libXtst libgcc libstdc++ libxcb make policycoreutils policycoreutils-python smartmontools sysstat gcc libaio-devel elfutils-libelf-devel gcc-c++ libstdc++-devel unixODBC unixODBC*.i686 unixODBC-devel unixODBC-devel*.i686
1.11、安装包
上传安装包
[root@dbserver ~]# mkdir /soft
sftp> cd /soft
sftp> lcd F:\installmedium\11g
sftp> put p13390677_112040_Linux-x86-64_1of7.zip
sftp> put p13390677_112040_Linux-x86-64_2of7.zip
[oracle@dbserver soft]$ cd /soft
解压安装包
[oracle@dbserver soft]$ ls *.zip | xargs -n1 unzip -o –q
解压后在/soft/database/response目录下有三个.rsp文件
文件作用分别是:
db_install.rsp:安装应答
dbca.rsp:创建数据库应答
netca.rsp:建立监听、本地服务名等网络设置的应答
[oracle@dbserver database]$ cd response/
[oracle@dbserver response]$ ll
total 80
-rwxr-xr-x 1 oracle oinstall 44533 Aug 27 2013 dbca.rsp
-rw-r--r-- 1 oracle oinstall 25116 Aug 27 2013 db_install.rsp
-rwxr-xr-x 1 oracle oinstall 5871 Aug 27 2013 netca.rsp
1.12、修改应答文件
[oracle@dbserver response]$ cp db_install.rsp db_install_bak.rsp
[oracle@dbserver response]$ vi db_install.rsp
说明:按照如下参数修改
[oracle@dbserver response]$ less /soft/database/response/db_install.rsp |grep -v "#"|grep -v "^$"
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0
oracle.install.option=INSTALL_DB_SWONLY
ORACLE_HOSTNAME=dbserver #主机名
UNIX_GROUP_NAME=oinstall #指定oracle inventory目录的所有者,通常会是oinstall或者dba
INVENTORY_LOCATION=/u01/app/oralnventory #指定产品清单oracle inventory目录路径,如果是Win平台下可以省略
SELECTED_LANGUAGES=en,zh_CN,zh_TW #指定数据库语言,选择多个时用逗号隔开。选择en, zh_CN,zh_TW (英文和简体中文和繁体中文)
ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 #设置ORALCE_HOME的路径
ORACLE_BASE=/u01/app/oracle #设置ORALCE_BASE的路径
oracle.install.db.InstallEdition=EE #选择Oracle安装数据库软件的版本(企业版,标准版,标准版1),不同的版本功能不同
oracle.install.db.EEOptionsSelection=false
oracle.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=dba #指定拥有OSDBA、OSOPER权限的用户组,通常会是dba组
oracle.install.db.OPER_GROUP=oper
oracle.install.db.CLUSTER_NODES= # 如果是RAC的安装,在这里指定所有的节点
oracle.install.db.isRACOneInstall=
oracle.install.db.racOneServiceName=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE #选择数据库的用途,一般用途/事物处理,数据仓库
oracle.install.db.config.starterdb.globalDBName=orcl #指定GlobalName
oracle.install.db.config.starterdb.SID=orcl #指定SID
oracle.install.db.config.starterdb.characterSet=AL32UTF8 #通常中文选择的有ZHS16GBK简体中文库,建议选择unicode的AL32UTF8国际字符集
oracle.install.db.config.starterdb.memoryOption=true # 11g的新特性自动内存管理,SGA_TARGET和PAG_AGGREGATE_TARGET都不用设置,Oracle会自动调整大小
oracle.install.db.config.starterdb.memoryLimit=1500 #指定Oracle自动管理内存的大小,最小是256MB,通常为物理内存的40%
oracle.install.db.config.starterdb.installExampleSchemas=false #是否载入模板示例
oracle.install.db.config.starterdb.enableSecuritySettings=true #是否启用安全设置
oracle.install.db.config.starterdb.password.ALL=oracle_4U #设定所有数据库用户使用同一个密码,其它数据库用户就不用单独设置
oracle.install.db.config.starterdb.password.SYS=
oracle.install.db.config.starterdb.password.SYSTEM=
oracle.install.db.config.starterdb.password.SYSMAN=
oracle.install.db.config.starterdb.password.DBSNMP=
oracle.install.db.config.starterdb.control=DB_CONTROL #数据库本地管理工具DB_CONTROL,远程集中管理工具GRID_CONTROL
oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL= #GRID_CONTROL需要设定grid control的远程路径URL
oracle.install.db.config.starterdb.automatedBackup.enable=false #设置自动备份,和OUI里的自动备份一样。
oracle.install.db.config.starterdb.automatedBackup.osuid=
oracle.install.db.config.starterdb.automatedBackup.ospwd=
oracle.install.db.config.starterdb.storageType=FILE_SYSTEM_STORAGE #自动备份,要求指定使用的文件系统还是ASM存放数据库文件
oracle.install.db.config.starterdb.fileSystemStorage.dataLocation=/u01/app/oracle/oradata #使用文件系统存放数据库文件才需要指定数据文件、控制文件、Redo log的存放目录
oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation=/u01/app/oracle/fast_recovery_area #使用文件系统存放数据库文件才需要指定备份恢复目录
oracle.install.db.config.asm.diskGroup= #使用ASM存放数据库文件才需要指定存放的磁盘组
oracle.install.db.config.asm.ASMSNMPPassword= #使用ASM存放数据库文件才需要指定ASM实例密码
MYORACLESUPPORT_USERNAME= #指定metalink账户用户名
MYORACLESUPPORT_PASSWORD= #指定metalink账户密码
SECURITY_UPDATES_VIA_MYORACLESUPPORT=false #用户是否可以设置metalink密码
DECLINE_SECURITY_UPDATES=true注意:在11.2的静默安装中疑似有一个BUG, Response File中必须指定为true,否则会提示错误,不管是否正确填写了邮件地址
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
PROXY_REALM=
COLLECTOR_SUPPORTHUB_URL=
oracle.installer.autoupdates.option=SKIP_UPDATES
oracle.installer.autoupdates.downloadUpdatesLoc=
AUTOUPDATES_MYORACLESUPPORT_USERNAME=
AUTOUPDATES_MYORACLESUPPORT_PASSWORD=
说明:修改完参数后,重启主机开始安装
2、安装数据库
[oracle@dbserver response]$ cd /soft/database
[oracle@dbserver database]$ ./runInstaller -silent -force -responseFile /soft/database/response/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 43197 MB Passed
Checking swap space: must be greater than 150 MB. Actual 10238 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2022-04-01_07-05-05PM. Please wait ...[oracle@dbserver database]$
[oracle@dbserver database]$ [WARNING] [INS-13014] Target environment do not meet some optional requirements.
CAUSE: Some of the optional prerequisites are not met. See logs for details.
/tmp/OraInstall2022-04-01_08-28-07PM/installActions2022-04-01_08-28-07PM.log
ACTION: Identify the list of failed prerequisite checks from the log:
/tmp/OraInstall2022-04-01_08-28-07PM/installActions2022-04-01_08-28-07PM.log.
Then either from the log file or from installation manual find the appropriate
configuration to meet the prerequisites and fix it manually.You can find the log of this install session at:
/u01/app/oralnventory/logs/installActions2022-04-01_08-28-07PM.log
The installation of Oracle Database 11g was successful.
Please check '/u01/app/oralnventory/logs/silentInstall2022-04-01_08-28-07PM.log' for more details.
As a root user, execute the following script(s):
1. /u01/app/oralnventory/orainstRoot.sh
2. /u01/app/oracle/product/11.2.0/db_1/root.shSuccessfully Setup Software.
执行脚本
[root@dbserver ~]# /u01/app/oralnventory/orainstRoot.sh
Changing permissions of /u01/app/oralnventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/app/oralnventory to oinstall.
The execution of the script is complete.
[root@dbserver ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh
Check /u01/app/oracle/product/11.2.0/db_1/install/root_dbserver_2022-04-01_20-34-46.log for the output of root script
说明:安装过程可查看安装进度
[oracle@dbserver ~]$ tail -f /u01/app/oralnventory/logs/installActions2022-04-01_08-28-07PM.log
3、配置监听
[oracle@dbserver database]$ $ORACLE_HOME/bin/netca /silent /responsefile /soft/database/response/netca.rsp
Parsing command line arguments:
Parameter "silent" = true
Parameter "responsefile" = /soft/database/response/netca.rsp
Done parsing command line arguments.
Oracle Net Services Configuration:
Profile configuration complete.
Oracle Net Listener Startup:
Running Listener Control:
/u01/app/oracle/product/11.2.0/db_1/bin/lsnrctl start LISTENER
Listener Control complete.
Listener started successfully.
Listener configuration complete.
Oracle Net Services configuration successful. The exit code is 0
4、创建数据库
修改如下文件:
[root@dbserver~]# vi /soft/database/response/dbca.rsp
GDBNAME = "orcl" //78行
SID="orcl" //149行
CHARACTERSET="AL32UTF8" //418行
NATIONALCHARACTERSET="UTF8" //428行
开始安装:
[oracle@dbserver~]$ $ORACLE_HOME/bin/dbca -silent -responseFile /soft/database/response/dbca.rsp
Enter SYS user password:
Enter SYSTEM user password:
Copying database files
1% complete
3% complete
11% complete
18% complete
26% complete
37% complete
Creating and starting Oracle instance
40% complete
45% complete
50% complete
55% complete
56% complete
60% complete
62% complete
Completing Database Creation
66% complete
70% complete
73% complete
85% complete
96% complete
100% complete
Look at the log file "/u01/app/cfgtoollogs/dbca/orcl/orcl.log" for further details.
5、数据库信息
SQL> select tablespace_name,file_id,file_name from dba_data_files order by tablespace_name
TABLESPACE_NAME FILE_ID FILE_NAME
-------------------- ---------- --------------------------------------------------
SYSAUX 2 /u01/app/oradata/orcl/sysaux01.dbf
SYSTEM 1 /u01/app/oradata/orcl/system01.dbf
UNDOTBS1 3 /u01/app/oradata/orcl/undotbs01.dbf
USERS 4 /u01/app/oradata/orcl/users01.dbf
SQL> select name from v$controlfile
NAME
--------------------------------------------------
/u01/app/oradata/orcl/control01.ctl
/u01/app/fast_recovery_area/orcl/control02.ctl
SQL> r
1* select * from v$logfile
GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
3 ONLINE /u01/app/oradata/orcl/redo03.log NO
2 ONLINE /u01/app/oradata/orcl/redo02.log NO
1 ONLINE /u01/app/oradata/orcl/redo01.log NO