oracle linux 7.9 静默安装oracle 11g
搭建虚拟机步骤配置ip,步骤省略。
下载linux 版本 11g Oracle 安装包,通过sftp上传到虚拟机。
oracle11.2.4安装包及补丁包链接如下:
链接:https://pan.baidu.com/s/1TaVNOqXCoSjsJJZ-ADLkmw
提取码:ycxi
前两个zip包为oracle ,第三个为grid安装包,只安装数据,则下载1和2即可,如需搭建集群则需下载1,2,3安装包
sftp上传
登录linux配置本地光盘源,转移/etc/yum.repos.d/目录下所有文件,新建/etc/yum.repos.d/cr.repo文件
[base] name=cr7 baseurl=file:///mnt gpgcheck=0 enabled=1
配置后,执行yum list
联网环境也可使用oracle官方源,使用命令下载:
wget http:
//public-yum
.oracle.com
/public-yum-ol7
.repo
安装net-tools,安装net-tools,只是为了使用ifconfig 命令,命令如下:
yum install net-tools* -y
安装unzip ,解压oracle安装包使用unzip命令:
yum install unzip -y
安装oracle 依赖包
yum install -y binutils* yum install -y compat-libcap1* yum install -y gcc* yum install -y gcc-c++* yum install -y glibc* yum install -y glibc-devel* yum install -y ksh* yum install -y libaio* yum install -y libgcc* yum install -y libstdc* yum install -y libstdc++-devel* yum install -y libXi* yum install -y libXtst* yum install -y make* yum install -y sysstat* yum install -y elfutils-libelf-devel*
新建oracle 用户组
/usr/sbin/groupadd -g 1000 oinstall /usr/sbin/groupadd -g 1020 asmadmin /usr/sbin/groupadd -g 1021 asmdba /usr/sbin/groupadd -g 1022 asmoper /usr/sbin/groupadd -g 1031 dba /usr/sbin/groupadd -g 1032 oper useradd -u 1101 -g oinstall -G dba,asmdba,oper oracle mkdir -p /u01/app/oracle chown -R oracle:oinstall /u01 chown oracle:oinstall /u01/app/oracle chmod -R 775 /u01/
passwd oracle (修改oracle 密码为oracle)
更改/data 目录为/u01
[root@localhost ~]# umount /data [root@localhost ~]# [root@localhost ~]# mv /data/ /u01 [root@localhost ~]# cat /etc/fstab # # /etc/fstab # Created by anaconda on Tue Jun 13 06:54:52 2023 # # Accessible filesystems, by reference, are maintained under '/dev/disk' # See man pages fstab(5), findfs(8), mount(8) and/or blkid(8) for more info # /dev/mapper/ol-root / xfs defaults 0 0 /dev/mapper/ol-data /data xfs defaults 0 0 UUID=913737af-8c35-474c-a23a-e9fcacd182f2 /boot xfs defaults 0 0 /dev/mapper/ol-swap swap swap defaults 0 0 [root@localhost ~]# vi /etc/fstab [root@localhost ~]# [root@localhost ~]# mount /dev/mapper/ol-data /u01 [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# [root@localhost ~]# df -h Filesystem Size Used Avail Use% Mounted on devtmpfs 1.8G 0 1.8G 0% /dev tmpfs 1.8G 0 1.8G 0% /dev/shm tmpfs 1.8G 8.8M 1.8G 1% /run tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup /dev/mapper/ol-root 26G 1.9G 25G 7% / /dev/sda1 1014M 184M 831M 19% /boot tmpfs 365M 0 365M 0% /run/user/0 /dev/sr0 4.6G 4.6G 0 100% /mnt /dev/mapper/ol-data 40G 2.5G 38G 7% /u01 [root@localhost ~]# ls /u01/ p13390677_112040_Linux-x86-64_1of7.zip p13390677_112040_Linux-x86-64_2of7.zip [root@localhost ~]#
解压oracle 安装包
[root@localhost u01]# unzip p13390677_112040_Linux-x86-64_1of7.zip && unzip p13390677_112040_Linux-x86-64_2of7.zip [root@localhost u01]# [root@localhost u01]# [root@localhost u01]# du -sh database/ 2.5G database/ [root@localhost u01]#
解压后再次执行:
chown -R oracle:oinstall /u01 chown oracle:oinstall /u01/app/oracle chmod -R 775 /u01/
系统参数修改
修改,两个文件/etc/sysctl.conf,和/etc/security/limits.conf(两节点都需要修改)
/etc/sysctl.conf添加如下
kernel.msgmnb = 65536 kernel.msgmax = 65536 kernel.shmmax = 68719476736 kernel.shmall = 4294967296 fs.aio-max-nr = 1048576 fs.file-max = 6815744 kernel.shmall = 2097152 kernel.shmmax = 4294967295 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 = 1048586 net.ipv4.tcp_wmem = 262144 262144 262144 net.ipv4.tcp_rmem = 4194304 4194304 4194304
修改完毕执行sysctl -p。
/etc/security/limits.conf 添加如下
oracle soft nproc 2047 oracle hard nproc 16384 oracle soft nofile 1024 oracle hard nofile 65536
修改主机名,修改hosts文件对应,如下
[root@ora01 ~]# cat /etc/hostname ora01 [root@ora01 ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.11.128 ora01 [root@ora01 ~]#
编辑oracle 静默安装文件
oracle.install.responseFileVersion=/oracle/install/rspfmt_dbinstall_response_schema_v11_2_0 oracle.install.option=INSTALL_DB_SWONLY ORACLE_HOSTNAME=ora01 UNIX_GROUP_NAME=oinstall INVENTORY_LOCATION=/u01/app/oraInventory SELECTED_LANGUAGES=en ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1 ORACLE_BASE=/u01/app/oracle oracle.install.db.InstallEdition=EE 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 oracle.install.db.OPER_GROUP=oper oracle.install.db.CLUSTER_NODES= oracle.install.db.isRACOneInstall= oracle.install.db.racOneServiceName= 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.characterSet=ZHS16GBK oracle.install.db.config.starterdb.memoryOption=true oracle.install.db.config.starterdb.memoryLimit=512 oracle.install.db.config.starterdb.installExampleSchemas=false oracle.install.db.config.starterdb.enableSecuritySettings=true oracle.install.db.config.starterdb.password.ALL=oracle 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 oracle.install.db.config.starterdb.gridcontrol.gridControlServiceURL= oracle.install.db.config.starterdb.automatedBackup.enable=false oracle.install.db.config.starterdb.automatedBackup.osuid= oracle.install.db.config.starterdb.automatedBackup.ospwd= oracle.install.db.config.starterdb.storageType= oracle.install.db.config.starterdb.fileSystemStorage.dataLocation= oracle.install.db.config.starterdb.fileSystemStorage.recoveryLocation= oracle.install.db.config.asm.diskGroup= oracle.install.db.config.asm.ASMSNMPPassword= MYORACLESUPPORT_USERNAME= MYORACLESUPPORT_PASSWORD= SECURITY_UPDATES_VIA_MYORACLESUPPORT=false DECLINE_SECURITY_UPDATES=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=
切换到Oracle开始执行静默安装
/u01/database/runInstaller -ignoreSysPrereqs -silent -showProgress -responseFile /u01/database/response/db_install.rsp
执行进度如下图所示:
执行root脚本
[oracle@ora01 ~]$ /u01/app/oraInventory/orainstRoot.sh This script must be executed as root [oracle@ora01 ~]$ exit logout [root@ora01 ~]# /u01/app/oraInventory/orainstRoot.sh Changing permissions of /u01/app/oraInventory. Adding read,write permissions for group. Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall. The execution of the script is complete. [root@ora01 ~]# /u01/app/oracle/product/11.2.0/db_1/root.sh Check /u01/app/oracle/product/11.2.0/db_1/install/root_ora01_2023-06-13_00-42-04.log for the output of root script [root@ora01 ~]# tail -f /u01/app/oracle/product/11.2.0/db_1/install/root_ora01_2023-06-13_00-42-04.log Copying coraenv to /usr/local/bin ... Creating /etc/oratab file... Entries will be added to the /etc/oratab file as needed by Database Configuration Assistant when a database is created Finished running generic part of root script. Now product-specific root actions will be performed. Finished product-specific root actions. Finished product-specific root actions.
配置oracle 环境变量
export TMP=/tmp export TMPDIR=$TMP export ORACLE_SID=orcl export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1 export TNS_ADMIN=$ORACLE_HOME/network/admin export PATH=/usr/sbin:$PATH export PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib umask 022
创建数据库
编辑dbca.rsp 配置文件
[GENERAL] RESPONSEFILE_VERSION = "11.2.0" OPERATION_TYPE = "createDatabase" [CREATEDATABASE] GDBNAME = "orcl" SID = "orcl" NODELIST=ora01 TEMPLATENAME = "General_Purpose.dbc" SYSPASSWORD = "oracle" SYSTEMPASSWORD = "oracle" SYSMANPASSWORD = "oracle" DBSNMPPASSWORD = "oracle" CHARACTERSET = "ZHS16GBK" NATIONALCHARACTERSET= "UTF8"
执行创建数据库
dbca -silent -responsefile /u01/database/response/dbca.rsp
[oracle@ora01 ~]$ dbca -silent -responsefile /u01/database/response/dbca.rsp 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/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details. [oracle@ora01 ~]$
创建监听
编辑监听配置文件netca.rsp
[GENERAL] RESPONSEFILE_VERSION="11.2" CREATE_TYPE="CUSTOM" [oracle.net.ca] INSTALLED_COMPONENTS={"server","net8","javavm"} INSTALL_TYPE=""typical"" LISTENER_NUMBER=1 LISTENER_NAMES={"LISTENER"} LISTENER_PROTOCOLS={"TCP;1521"} LISTENER_START=""LISTENER"" NAMING_METHODS={"TNSNAMES","ONAMES","HOSTNAME"} NSN_NUMBER=1 NSN_NAMES={"EXTPROC_CONNECTION_DATA"} NSN_SERVICE={"PLSExtProc"} NSN_PROTOCOLS={"TCP;HOSTNAME;1521"}
执行监听创建命令如下命令行:
[oracle@ora01 ~]$ netca -silent -responsefile /u01/database/response/netca.rsp Parsing command line arguments: Parameter "silent" = true Parameter "responsefile" = /u01/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 [oracle@ora01 ~]$
查看监听状态
[oracle@ora01 ~]$ lsnrctl status LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JUN-2023 01:02:31 Copyright (c) 1991, 2013, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production Start Date 13-JUN-2023 01:01:37 Uptime 0 days 0 hr. 0 min. 53 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /u01/app/oracle/diag/tnslsnr/ora01/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521))) (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora01)(PORT=1521))) Services Summary... Service "orcl" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully [oracle@ora01 ~]$
测试连接数据库
[oracle@ora01 ~]$ sqlplus system/oracle@192.168.11.128:1521/orcl SQL*Plus: Release 11.2.0.4.0 Production on Tue Jun 13 01:04:20 2023 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL>