##安装桌面##安装桌面yum -y groupinstall "Server with GUI"#启动桌面startx
#设置启动模式[root@rhel7-ora12c-ip21 ~]# systemctl get-defaultmulti-user.target[root@rhel7-ora12c-ip21 ~]# cat /etc/inittab# inittab is no longer used when using systemd.## ADDING CONFIGURATION HERE WILL HAVE NO EFFECT ON YOUR SYSTEM.## Ctrl-Alt-Delete is handled by /usr/lib/systemd/system/ctrl-alt-del.target## systemd uses 'targets' instead of runlevels. By default, there are two main targets:## multi-user.target: analogous to runlevel 3#多用户模式# graphical.target: analogous to runlevel 5#图形化模式## To view current default target, run:# systemctl get-default## To set a default target, run:# systemctl set-default TARGET.target#[root@rhel7-ora12c-ip21 ~]# systemctl set-default graphical.targetRemoved symlink /etc/systemd/system/default.target.Created symlink from /etc/systemd/system/default.target to /usr/lib/systemd/system/graphical.target.[root@localhost ~]# systemctl get-defaultgraphical.target
##创建用户和组groupadd -g 500 oinstallgroupadd -g 501 dbagroupadd -g 502 opergroupadd -g 600 asmadmingroupadd -g 601 asmdbagroupadd -g 602 asmoperuseradd -u 1000 -g oinstall -G dba,oper,asmdba oracleuseradd -u 1001 -g oinstall -G dba,asmdba,asmadmin,asmoper grid
##packages for linux 7rpm -qa | grep binutils-2.23.52.0.1-12.el7.x86_64rpm -qa | grep compat-libcap1-1.10-3.el7.x86_64rpm -qa | grep compat-libstdc++-33-3.2.3-71.el7.i686rpm -qa | grep compat-libstdc++-33-3.2.3-71.el7.x86_64rpm -qa | grep gcc-4.8.2-3.el7.x86_64rpm -qa | grep gcc-c++-4.8.2-3.el7.x86_64rpm -qa | grep glibc-2.17-36.el7.i686rpm -qa | grep glibc-2.17-36.el7.x86_64rpm -qa | grep glibc-devel-2.17-36.el7.i686rpm -qa | grep glibc-devel-2.17-36.el7.x86_64rpm -qa | grep kshrpm -qa | grep libaio-0.3.109-9.el7.i686rpm -qa | grep libaio-0.3.109-9.el7.x86_64rpm -qa | grep libaio-devel-0.3.109-9.el7.i686rpm -qa | grep libaio-devel-0.3.109-9.el7.x86_64rpm -qa | grep libgcc-4.8.2-3.el7.i686rpm -qa | grep libgcc-4.8.2-3.el7.x86_64rpm -qa | grep libstdc++-4.8.2-3.el7.i686rpm -qa | grep libstdc++-4.8.2-3.el7.x86_64rpm -qa | grep libstdc++-devel-4.8.2-3.el7.i686rpm -qa | grep libstdc++-devel-4.8.2-3.el7.x86_64rpm -qa | grep libXi-1.7.2-1.el7.i686rpm -qa | grep libXi-1.7.2-1.el7.x86_64rpm -qa | grep libXtst-1.2.2-1.el7.i686rpm -qa | grep libXtst-1.2.2-1.el7.x86_64rpm -qa | grep make-3.82-19.el7.x86_64rpm -qa | grep sysstat-10.1.5-1.el7.x86_64
yum -y install binutils compat-libcap1 compat-libstdc++-33 compat-libstdc++-33*.i686 gcc gcc-c++ glibc glibc*.i686 glibc-devel glibc-devel*.i686 ksh libaio libaio-*.i686 libaio-devel libaio-devel*.i686 libgcc libgcc*.i686 libstdc++ libstdc++-*.i686 libstdc++-devel libstdc++devel*.i686 libXi libXi*.i686 libXtst libXtst*.i686 make sysstat unixODBC unixODBC-devel unixODBC*.i686yum -y localinstall compat-libstdc++-33-3.2.3-72.el7.*#单独下载
##vi /etc/sysctl.conffs.aio-max-nr = 1048576fs.file-max = 6815744kernel.shmall = 2097152kernel.shmmax = 536870912kernel.shmmni = 4096kernel.sem = 250 32000 100 128net.ipv4.ip_local_port_range = 9000 65500net.core.rmem_default = 262144net.core.rmem_max = 4194304net.core.wmem_default = 262144net.core.wmem_max = 1048576
/sbin/sysctl -p

##官方文档对shmmax的设置解释,(文档 ID 567506.1),我一般直接使用当前设置/sbin/sysctl -a | grep shm#Oracle Global Customer Support officially recommends a " maximum" for SHMMAX of "1/2 of physical RAM".#The maximum size of a shared memory segment is limited by the size of the available user address space. On 64-bit systems, this is a theoretical 2^64bytes. So the "theoretical limit" for SHMMAX is the amount of physical RAM that you have.However, to actually attempt to use such a value could potentially lead to a situation where no system memory is available for anything else.Therefore a more realistic "physical limit" for SHMMAX would probably be "physical RAM - 2Gb".#In an Oracle RDBMS application, this "physical limit" still leaves inadequate system memory for other necessary functions. Therefore, the common "Oracle maximum" for SHMMAX that you will often see is "1/2 of physical RAM". Many Oracle customers chose a higher fraction, at their discretion.#Occasionally, Customers may erroneously think that that setting the SHMMAX as recommended in this NOTE limits the total SGA.That is not true.Setting the SHMMAX as recommended only causes a few more "shared memory segments" to be used for whatever total SGA that you subsequently configure in Oracle. For additional detail, please see
##vi /etc/security/limits.conforacle soft nproc 2047oracle hard nproc 16384oracle soft nofile 1024oracle hard nofile 65536oracle soft stack 10240oracle hard stack 10240grid soft nproc 2047grid hard nproc 16384grid soft nofile 1024grid hard nofile 65536grid soft stack 10240grid hard stack 10240
##创建安装目录mkdir -p /u01/app/gridmkdir -p /u01/app/gridhomemkdir -p /u01/app/oraclechown grid:oinstall /u01/app/gridchown grid:oinstall /u01/app/gridhomechown -R oracle:oinstall /u01/app/oracle

##修改hosts文件ip add | grep enp0s8 | grep inet | awk '{print $2}' | awk -F"/" '{printf $1" "}{cmd="hostname";system(cmd)}' >> /etc/hostscat /etc/hosts

##关闭防火墙和selinux[root@rhel7-ora12c-ip21 ~]# systemctl stop firewalld[root@rhel7-ora12c-ip21 ~]# systemctl disable firewalldRemoved symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.Removed symlink /etc/systemd/system/basic.target.wants/firewalld.service.[root@rhel7-ora12c-ip21 ~]# getenforceEnforcing[root@rhel7-ora12c-ip21 ~]# setenforce 0[root@rhel7-ora12c-ip21 ~]# getenforcePermissive[root@rhel7-ora12c-ip21 ~]# vi /etc/selinux/configSELINUX=disabled或sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

##udev绑定裸设备,这里只绑定权限
[root@rhel7-ora12c-ip21 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdb11ATA_VBOX_HARDDISK_VBc9bd6bdf-a347ac26[root@rhel7-ora12c-ip21 ~]# /usr/lib/udev/scsi_id -g -u /dev/sdc11ATA_VBOX_HARDDISK_VB8aeda10c-71ca412a[root@rhel7-ora12c-ip21 ~]# vi /etc/udev/rules.d/99-oracle-asmdevices.rulesKERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/lib/udev/scsi_id -g -u -d /dev/$parent",RESULT=="1ATA_VBOX_HARDDISK_VBc9bd6bdf-a347ac26",OWNER="grid", GROUP="asmadmin", MODE="0660"KERNEL=="sd?1", SUBSYSTEM=="block", PROGRAM=="/lib/udev/scsi_id -g -u -d /dev/$parent",RESULT=="1ATA_VBOX_HARDDISK_VB8aeda10c-71ca412a",OWNER="grid", GROUP="asmadmin", MODE="0660"[root@rhel7-ora12c-ip21 ~]# systemctl restart systemd-udev-trigger.service[root@rhel7-ora12c-ip21 ~]# ls -Ll /dev/sd?1
##节点二使用partprobe去发现分区
##设置用户参数文件su - gridexport ORACLE_BASE=/u01/app/gridexport ORACLE_HOME=/u01/app/gridhomeexport ORACLE_SID=+ASM1PATH=$ORACLE_HOME/bin:$PATHexport LD_LIBRARY_PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/binexport CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export ORACLE_BASE=/u01/app/gridexport ORACLE_HOME=/u01/app/gridhomeexport ORACLE_SID=+ASM2PATH=$ORACLE_HOME/bin:$PATHexport LD_LIBRARY_PATH=$ORACLE_HOME/bin:/bin:/usr/bin:/usr/local/binexport CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
su - oracleORACLE_BASE=/u01/app/oracleORACLE_HOME=/u01/app/oracle/product/12.2.0/db_1ORACLE_SID=orcl2export ORACLE_BASE ORACLE_HOME ORACLE_SIDexport PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin:/usr/bin:/sbinexport LD_LIBRARY_PATH=$ORACLE_HOME/lib
ORACLE_BASE=/u01/app/oracleORACLE_HOME=/u01/app/oracle/product/12.2.0/db_1ORACLE_SID=orcl2export ORACLE_BASE ORACLE_HOME ORACLE_SIDexport PATH=$ORACLE_HOME/bin:$PATH:$HOME/bin:/usr/bin:/sbinexport LD_LIBRARY_PATH=$ORACLE_HOME/lib
##建立互信关系oracle:cd /home/oraclemkdir ~/.sshchmod 700 ~/.sshssh-keygen -t rsassh-keygen -t dsa
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keyscat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keysssh rhel7-ora12c-ip22cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keysssh rhel7-ora12c-ip22cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys rhel7-ora12c-ip22:~/.ssh/authorized_keys
ssh rhel7-ora12c-ip21date;ssh rhel7-ora12c-ip22date;ssh rhel7-ora12c-ip21-priv date;ssh rhel7-ora12c-ip22-priv date
grid:cd /home/gridmkdir ~/.sshchmod 700 ~/.sshssh-keygen -t rsassh-keygen -t dsa
cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keyscat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keysssh rhel7-ora12c-ip22cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keysssh rhel7-ora12c-ip22cat ~/.ssh/id_dsa.pub >>~/.ssh/authorized_keys
scp ~/.ssh/authorized_keys rhel7-ora12c-ip22:~/.ssh/authorized_keys
ssh rhel7-ora12c-ip21date;ssh rhel7-ora12c-ip22date;ssh rhel7-ora12c-ip21-priv date;ssh rhel7-ora12c-ip22-priv date
##安装cvuqdisk[root@rhel7-ora12c-ip21 gridhome]# rpm -ivh ./cv/rpm/cvuqdisk-1.0.10-1.rpm
##编辑ohas文件,在执行root.sh脚本以后一直监控/etc/init.d/init.ohasd文件,文件存在马上启动ohas服务[root@rhel7-ora12c-ip21 ~]# vi /usr/lib/systemd/system/ohas.service[Unit]Description=Oracle High Availability ServicesAfter=syslog.target
[Service]ExecStart=/etc/init.d/init.ohasd run >/dev/null 2>&1 Type=simpleRestart=always
[Install]WantedBy=multi-user.target

[root@rhel7-ora12c-ip21 ~]# chmod 777 /usr/lib/systemd/system/ohas.service
systemctl daemon-reloadsystemctl enable ohas.servicesystemctl start ohas.servicesystemctl status ohas.service
##执行root脚本以后,一直检查下面的文件是否存在,当文件存在马上手动启动oha,推介[root@rhel7-ora12c-ip21 ~]# ls /etc/init.d/init.ohasd/etc/init.d/init.ohasd[root@rhel7-ora12c-ip21 ~]# systemctl start ohas.service[root@rhel7-ora12c-ip21 ~]# systemctl status ohas.service● ohas.service - Oracle High Availability ServicesLoaded: loaded (/usr/lib/systemd/system/ohas.service; disabled; vendor preset: disabled)Active: active (running) since Fri 2017-09-15 03:40:12 EDT; 5s agoMain PID: 11434 (init.ohasd)CGroup: /system.slice/ohas.service└─11434 /bin/sh /etc/init.d/init.ohasd run >/dev/null 2>&1 Type=simple
Sep 15 03:40:12 rhel7-ora12c-ip21 systemd[1]: Started Oracle High Availability Services.Sep 15 03:40:12 rhel7-ora12c-ip21systemd[1]: Starting Oracle High Availability Services...Sep 15 03:40:12 rhel7-ora12c-ip21su[11461]: (to grid) root on none
[root@rhel7-ora12c-ip21 ~]# /u01/app/grid/oraInventory/orainstRoot.shChanging permissions of /u01/app/grid/oraInventory.Adding read,write permissions for group.Removing read,write,execute permissions for world.
Changing groupname of /u01/app/grid/oraInventory to oinstall.The execution of the script is complete.
[root@rhel7-ora12c-ip21 ~]# /u01/app/gridhome/root.shPerforming root user operation.
The following environment variables are set as:ORACLE_OWNER= gridORACLE_HOME=/u01/app/gridhome
Enter the full pathname of the local bin directory: [/usr/local/bin]:The contents of "dbhome" have not changed. No need to overwrite.The contents of "oraenv" have not changed. No need to overwrite.The contents of "coraenv" have not changed. No need to overwrite.
Entries will be added to the /etc/oratab file as needed byDatabase Configuration Assistant when a database is createdFinished running generic part of root script.Now product-specific root actions will be performed.Using configuration parameter file: /u01/app/gridhome/crs/install/crsconfig_paramsThe log of current session can be found at:/u01/app/grid/crsdata/rhel7-ora12c-ip21/crsconfig/roothas_2017-09-15_03-40-36AM.log2017/09/15 03:40:36 CLSRSC-363: User ignored prerequisites during installation2017/09/15 03:40:40 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'rhel7-ora12c-ip21'CRS-2673: Attempting to stop 'ora.evmd' on 'rhel7-ora12c-ip21'CRS-2677: Stop of 'ora.evmd' on 'rhel7-ora12c-ip21' succeededCRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'rhel7-ora12c-ip21' has completedCRS-4133: Oracle High Availability Services has been stopped.CRS-4123: Oracle High Availability Services has been started.
rhel7-ora12c-ip1562017/09/15 03:41:35/u01/app/gridhome/cdata/rhel7-ora12c-ip21/backup_20170915_034135.olr0
##报错:2017/09/16 03:35:51 CLSRSC-330: Adding Clusterware entries to file 'oracle-ohasd.service'2017/09/16 03:36:34 CLSRSC-400: A system reboot is required to continue installing.The command '/u01/app/gridhome/perl/bin/perl -I/u01/app/gridhome/perl/lib -I/u01/app/gridhome/crs/install /u01/app/gridhome/crs/install/roothas.pl ' execution failed解决:[grid@rhel7-ora12c-ip21 ~]$ acfsdriverstate -orahome $ORACLE_HOME supportedACFS-9459: ADVM/ACFS is not supported on this OS version: '3.10.0-514.el7.x86_64'ACFS-9201: Not Supported
##安装前检查脚本./runcluvfy.sh stage -pre crsinst -n rhel7-ora12c-ip21,rhel7-ora12c-ip22-fixup -verbose >> check.txt
##安装数据库软件和实例./gridSetup.sh


注意:12c R2强制安装GIMR,要求空间最低37G注:这里没有设置DNS,我把对DNS提示的错误全部忽略,物理内存要求大于8G,我忽略
##安装rdbms和instance和11G区别不大,正常安装即可