在Linux生产环境中为了提供系统的最大性能,一般是不安装图形桌面的。因此在安装像Oracle这种比较复杂的数据库的时候就显的比较束手无策,其实不然,Oracle已经为我们考虑好了这种环境下的安装情况,那就是传说中的静默安装啦。
#内存
grep MemTotal /proc/meminfo
#交换空间
##阿里云ecs默认是不提供swap分区的,这里需要自己动手加一下
#使用dd命令创建一个swap交换文件,创建一个2G的文件
dd if=/dev/zero of=/swap bs=1024 count=2048000
#制作为swap格式文件
mkswap /swap
#更改swap文件权限
chmod 600 /swap
#用swapon命令把这个文件分区挂载swap分区
swapon /swap
#查看swap空间
grep SwapTotal /proc/meminfo
#为防止重启后swap分区变为0,设置开机自动挂载
vim /etc/fstab
#在末尾追加
/swap swap swap default 0 0
#磁盘空间
df -ah
#查看主机名信息
hostnamectl status
#只查看静态、瞬态或灵活主机名,分别使用“--static”,“--transient”或“--pretty”选项。
hostnamectl --static
hostnamectl --transient
hostnamectl --pretty
#同时修改所有三个主机名:静态、瞬态和灵活主机名为oradb
hostnamectl set-hostname oradb
vim /etc/hosts
127.0.0.1 oradb
sed -i "s/SELINUX=enforcing/SELINUX=disabled/" /etc/selinux/config
setenforce 0
这里通过安装Oracle YUM 源来安装所依赖的包
cd /etc/yum.repos.d
wget http://public-yum.oracle.com/public-yum-ol7.repo
#导入RPM-GPG-KEY-oracle
wget http://public-yum.oracle.com/RPM-GPG-KEY-oracle-ol7 -O /etc/pki/rpm-gpg/RPM-GPG-KEY-oracle
#安装oracle-rdbms-server-11gR2-preinstall快速配置Oracle安装环境
yum install oracle-rdbms-server-11gR2-preinstall -y
#oracle-rdbms-server-11gR2-preinstall包所干的事情
(1)自动安装oracle所需的RPM包
(2)自动创建oracle用户和group组
(3)自动配置/etc/sysctl.conf内核参数
(4)自动配置/etc/security/limits.conf参数
(5)关闭NUMA=OFF (关闭非一致内存访问)
#安装完后查看后台日志内容
more /var/log/oracle-rdbms-server-11gR2-preinstall/results/orakernel.log
Adding group oinstall with gid 54321
Adding group dba
Adding user oracle with user id 54321, initial login group oinstall, supplementary group dba and home directory /home/oracle
Changing ownership of /home/oracle to oracle:oinstall
Please set password for oracle user
uid=54321(oracle) gid=54321(oinstall) groups=54321(oinstall),54322(dba)
Creating oracle user passed
Saving a copy of the initial sysctl.conf
Verifying kernel parameters as per Oracle recommendations...
Adding fs.file-max = 6815744
Adding kernel.sem = 250 32000 100 128
Adding kernel.shmmni = 4096
Adding kernel.shmall = 1073741824
Adding kernel.shmmax = 4398046511104
Adding kernel.panic_on_oops = 1
Adding net.core.rmem_default = 262144
Adding net.core.rmem_max = 4194304
Adding net.core.wmem_default = 262144
Adding net.core.wmem_max = 1048576
Changing net.ipv4.conf.all.rp_filter to match preinstall config
net.ipv4.conf.all.rp_filter = 2
Changing net.ipv4.conf.default.rp_filter to match preinstall config
net.ipv4.conf.default.rp_filter = 2
Adding fs.aio-max-nr = 1048576
Adding net.ipv4.ip_local_port_range = 9000 65500
Setting kernel parameters as per oracle recommendations...
Altered file /etc/sysctl.conf
Saved a copy of the current file in /etc/sysctl.d/99-oracle-rdbms-server-11gR2-preinstall-sysctl.conf
Check /etc/sysctl.d for backups
Verifying & setting of kernel parameters passed
Setting user limits using /etc/security/limits.conf
Verifying oracle user OS limits as per Oracle recommendations...
Adding oracle soft nofile 1024
Adding oracle hard nofile 65536
Adding oracle soft nproc 16384
Adding oracle hard nproc 16384
Adding oracle soft stack 10240
Adding oracle hard stack 32768
Adding oracle hard memlock 134217728
Adding oracle soft memlock 134217728
Setting oracle user OS limits as per Oracle recommendations...
Altered file /etc/security/limits.conf
Original file backed up at /var/log/oracle-rdbms-server-11gR2-preinstall/backup/Jan-08-2018-11-18-56
Verifying & setting of user limits passed
Saving a copy of /etc/default/grub file in /etc/default/grub-initial.orabackup
Saving a copy of /etc/default/grub in /var/log/oracle-rdbms-server-11gR2-preinstall/backup/Jan-08-2018-11-18-56...
Verifying kernel boot parameters as per Oracle recommendations...
old boot params: "crashkernel=auto rhgb quiet net.ifnames=0 serial=tty0 console=ttyS0,115200n8"
new boot params: "crashkernel=auto rhgb quiet net.ifnames=0 serial=tty0 console=ttyS0,115200n8 numa=off"
old boot params: "crashkernel=auto rhgb quiet net.ifnames=0 serial=tty0 console=ttyS0,115200n8 numa=off"
new boot params: "crashkernel=auto rhgb quiet net.ifnames=0 serial=tty0 console=ttyS0,115200n8 numa=off transparent_hugepage=never"
Setting kernel boot parameters as per Oracle recommendations...
G_DIR=/boot/grub2
Default kernel is -> /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64
Default saved_entry is -> CentOS Linux (3.10.0-693.2.2.el7.x86_64) 7 (Core)
Default saved_entry_line is -> linux16 /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64 root=UUID=eb448abb-3012-4d8d-bcde-94434d586a31 ro crashkernel=auto rhgb quiet net.if
names=0 serial=tty0 console=ttyS0,115200n8
Saving a copy of grubenv... in /var/log/oracle-rdbms-server-11gR2-preinstall/backup/Jan-08-2018-11-18-56
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.2.2.el7.x86_64.img
Found linux image: /boot/vmlinuz-3.10.0-693.el7.x86_64
Found initrd image: /boot/initramfs-3.10.0-693.el7.x86_64.img
Found linux image: /boot/vmlinuz-0-rescue-f0f31005fb5a436d88e3c6cbf54e25aa
Found initrd image: /boot/initramfs-0-rescue-f0f31005fb5a436d88e3c6cbf54e25aa.img
done
Unable to obtain the replica of saved entry line in new grub.cfg. Defaulting to first line matching the kernel
The saved kernel /boot/vmlinuz-3.10.0-693.2.2.el7.x86_64 is now at position - 0
Boot parameters will be effected on next reboot
Altered file /etc/default/grub
Copy of the changed file is in - /etc/default/grub-oracle-rdbms-server-11gR2-preinstall.orabackup
Copy of the original file is in - /var/log/oracle-rdbms-server-11gR2-preinstall/backup/Jan-08-2018-11-18-56
Verifying & setting of boot parameters passed
Trying to add NOZEROCONF parameter...
Taking a backup of existing file to /etc/sysconfig/network.orabackup
Successfully added parameter NOZEROCONF to /etc/sysconfig/network
Setting /etc/sysconfig/network parameters passed
Disabling Transparent Hugepages.
Refer Oracle Note:1557478.1
Disabling defrag.
Refer Oracle Note:1557478.1
Taking a backup of old config files under /var/log/oracle-rdbms-server-11gR2-preinstall/backup/Jan-08-2018-11-18-56
#以上日志内容可以看到oracle-rdbms-server-11gR2-preinstall为我们做得事情
#最后可以看到备份文件的位置,是不是突然觉得世界很美好呢,什么参数、内核等等统统都配置好了
#1、创建安装的目录
mkdir -p /u01/oracle/product/11.2.0/db_1
#更改oracle目录的属主
chown oracle:oinstall -R /u01
#更改oracle目录的权限
chmod 755 -R /u01/oracle
#2、设置Oracle环境变量
su - oracle
vim .bash_profile
#追加以下内容
export TMP=/tmp #安装oracle软件过程中使用的临时文件目录
export TMPDIR=$TMP #安装oracle软件过程中使用的临时文件目录
export ORACLE_BASE=/u01/oracle #Oracle的BASE目录,所有关于Oracle的文件全部存放在这个目录中
export ORACLE_HOME=/u01/oracle/product/11.2.0/db_1 #安装Oracle软件存放的目录
export ORACLE_SID=orcl #将要创建的数据库实例的名字
export ORACLE_TERM=xterm #安装的时候指定终端的定义资源文件xterm表示窗口方式,rt100表示终端调试模式
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH #SHELL可执行文件的搜索路径
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib #库文件的搜索路径
export CLASSPATH=$ORACLE_HOME/jre:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib #java的class文件执行搜索的bin路径
export EDITOR=vim #在oracle操作环境下嵌入使用的文本编辑工具
export NLS_LANG=AMERICAN_AMERICA.UTF8 #oracle用户这个客户端所识别的字符集
export NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS' #oracle用户这个客户端所识别的时间显式格式
#使环境变量生效
source .bash_profile
#3、解压Oracle数据库
unzip linux.x64_11gR2_database_1of2.zip
unzip linux.x64_11gR2_database_2of2.zip
[oracle@oradb u01]$ ls -lrt
total 2295608
drwxr-xr-x 8 oracle oinstall 4096 Aug 21 2009 database
-rw-r--r-- 1 oracle oinstall 1239269270 Aug 21 2009 linux.x64_11gR2_database_1of2.zip
-rw-r--r-- 1 oracle oinstall 1111416131 Aug 21 2009 linux.x64_11gR2_database_2of2.zip
drwxr-xr-x 3 oracle oinstall 4096 Jan 8 13:35 oracle
#Oracle静默安装需要用到的应答文件
[oracle@oradb response]$ pwd
/u01/database/response
[oracle@oradb response]$ ll
total 76
-rw-rw-r-- 1 oracle oinstall 44969 Feb 14 2009 dbca.rsp #创建数据库应答
-rw-rw-r-- 1 oracle oinstall 22557 Aug 15 2009 db_install.rsp #安装应答
-rwxrwxr-x 1 oracle oinstall 5740 Feb 26 2009 netca.rsp #建立监听、本地服务名等网络设置的应答
#4、配置应答文件
[oracle@oradb response]$ cat 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=oradb
UNIX_GROUP_NAME=oinstall
INVENTORY_LOCATION=/u01/oracle/oraInventory
SELECTED_LANGUAGES=en,zh_CN
ORACLE_HOME=/u01/oracle/product/11.2.0/db_1
ORACLE_BASE=/u01/oracle
oracle.install.db.InstallEdition=EE
oracle.install.db.isCustomInstall=false
oracle.install.db.customComponents=oracle.server:11.2.0.1.0,oracle.sysman.ccr:10.2.7.0.0,oracle.xdk:11.2.0.1.0,oracle.rdbms.oci:11.2.0.1.0,oracle.network:11.2.0.1.0,oracle.network.listener:11.2.0.1.0,oracle.rdbms:11.2.0.1.0,oracle.options:11.2.0.1.0,oracle.rdbms.partitioning:11.2.0.1.0,oracle.oraolap:11.2.0.1.0,oracle.rdbms.dm:11.2.0.1.0,oracle.rdbms.dv:11.2.0.1.0,orcle.rdbms.lbac:11.2.0.1.0,oracle.rdbms.rat:11.2.0.1.0
oracle.install.db.DBA_GROUP=dba
oracle.install.db.OPER_GROUP=oinstall
oracle.install.db.CLUSTER_NODES=
oracle.install.db.config.starterdb.type=GENERAL_PURPOSE
oracle.install.db.config.starterdb.globalDBName=ora11g
oracle.install.db.config.starterdb.SID=ORCL
oracle.install.db.config.starterdb.characterSet=AL32UTF8
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.dbcontrol.enableEmailNotification=false
oracle.install.db.config.starterdb.dbcontrol.emailAddress=
oracle.install.db.config.starterdb.dbcontrol.SMTPServer=
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=FILE_SYSTEM_STORAGE
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=
DECLINE_SECURITY_UPDATES=true
PROXY_HOST=
PROXY_PORT=
PROXY_USER=
PROXY_PWD=
#5、安装数据库软件
[oracle@oradb database]$ /u01/database/runInstaller -silent -force -ignorePrereq -responseFile /u01/database/response/db_install.rsp
Starting Oracle Universal Installer...
Checking Temp space: must be greater than 120 MB. Actual 22087 MB Passed
Checking swap space: must be greater than 150 MB. Actual 1999 MB Passed
Preparing to launch Oracle Universal Installer from /tmp/OraInstall2018-01-08_02-28-33PM. Please wait ...[oracle@oradb database]$ [WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
[WARNING] [INS-32055] The Central Inventory is located in the Oracle base.
CAUSE: The Central Inventory is located in the Oracle base.
ACTION: Oracle recommends placing this Central Inventory in a location outside the Oracle base directory.
You can find the log of this install session at:
/u01/oracle/oraInventory/logs/installActions2018-01-08_02-28-33PM.log
#等待5分钟左右出现
[oracle@oradb database]$ The following configuration scripts need to be executed as the "root" user.
#!/bin/sh
#Root scripts to run
/u01/oracle/oraInventory/orainstRoot.sh
/u01/oracle/product/11.2.0/db_1/root.sh
To execute the configuration scripts:
1. Open a terminal window
2. Log in as "root"
3. Run the scripts
4. Return to this window and hit "Enter" key to continue
Successfully Setup Software.
#在root用户下执行上面2个脚本
[root@oradb ~]# /u01/oracle/oraInventory/orainstRoot.sh
Changing permissions of /u01/oracle/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions for world.
Changing groupname of /u01/oracle/oraInventory to oinstall.
The execution of the script is complete.
[root@oradb ~]# /u01/oracle/product/11.2.0/db_1/root.sh
Check /u01/oracle/product/11.2.0/db_1/install/root_oradb_2018-01-08_14-36-51.log for the output of root script
#到这里Oracle软件就安装完了,下面接着安装监听程序
#6、安装监听
[oracle@oradb database]$ $ORACLE_HOME/bin/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/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@oradb database]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-JAN-2018 14:40:56
Copyright (c) 1991, 2009, Oracle. All rights reserved.
TNS-01106: Listener using listener name LISTENER has already been started
#查看监听状态成功
[oracle@oradb database]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-JAN-2018 14:41:03
Copyright (c) 1991, 2009, 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.1.0 - Production
Start Date 08-JAN-2018 14:39:22
Uptime 0 days 0 hr. 1 min. 41 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/diag/tnslsnr/oradb/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oradb)(PORT=1521)))
The listener supports no services
The command completed successfully
#7、静默dbca建立数据库
[oracle@oradb response]$ vim /u01/database/response/dbca.rsp
GDBNAME = "orcl.oradb" #78行,全局数据库名字 sid+hostname
SID = "orcl" #149行
CHARACTERSET = "AL32UTF8" #415行,编码
NATIONALCHARACTERSET= "UTF8" #425行
#开始安装
[oracle@oradb response]$ $ORACLE_HOME/bin/dbca -silent -responseFile /u01/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/oracle/cfgtoollogs/dbca/orcl/orcl.log" for further details.
#安装完成后启动数据库(一般会自动启动)
[oracle@oradb ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Mon Jan 8 14:57:49 2018
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 413372416 bytes
Fixed Size 2213896 bytes
Variable Size 268437496 bytes
Database Buffers 138412032 bytes
Redo Buffers 4308992 bytes
Database mounted.
Database opened.
SQL>
SQL> select INSTANCE_NAME,VERSION from v$instance;
INSTANCE_NAME VERSION
-------------- ----------------------------------------
orcl 11.2.0.1.0
#监听情况
[oracle@oradb ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 08-JAN-2018 15:01:42
Copyright (c) 1991, 2009, 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.1.0 - Production
Start Date 08-JAN-2018 14:39:22
Uptime 0 days 0 hr. 22 min. 21 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/oracle/diag/tnslsnr/oradb/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=oradb)(PORT=1521)))
Services Summary...
Service "orcl.oradb" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB.oradb" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
#监听正常
以上是Oracle 11gR2 在Centos7中静默安装的全过程,大家在安装的过程中遇到的问题,欢迎留言~~~