从Oracle 10g开始,Oracle 开始推行ASM的使用,到了11g,RAC 集群已必须使用ASM,所以对ASM的掌握程度也决定RAC的运维水平,这篇Blog 演示 Oracle12c 基于ASM 的单实例的的环境搭建。
这样便可以玩12c 的ASM,又不需要起2个集群,从而方便学习。具体环境搭建步骤以下。
binutils⑵.20.51.0.2⑸.11.el6 (x86_64)
glibc⑵.12⑴.7.el6 (x86_64)
libgcc⑷.4.4⑴3.el6 (x86_64)
libstdc++⑷.4.4⑴3.el6 (x86_64)
libaio-0.3.107⑴0.el6 (x86_64)
libXext⑴.1 (x86_64)
libXtst⑴.0.99.2 (x86_64)
libX11⑴.3 (x86_64)
libXau⑴.0.5 (x86_64)
libxcb⑴.5 (x86_64)
libXi⑴.3 (x86_64)
make⑶.81⑴9.el6
sysstat⑼.0.4⑴1.el6 (x86_64)
compat-libcap1⑴.10⑴ (x86_64)
compat-libstdc++⑶3⑶.2.3⑹9.el6 (x86_64)
gcc⑷.4.4⑴3.el6 (x86_64)
gcc-c++⑷.4.4⑴3.el6 (x86_64)
glibc-devel⑵.12⑴.7.el6 (x86_64)
ksh <== 任何版本的 ksh 都可以。
libstdc++-devel⑷.4.4⑴3.el6 (x86_64)
libaio-devel-0.3.107⑴0.el6 (x86_64)
compat-libstdc++⑶3⑶.2.3⑹9.el6 (i686)
glibc⑵.12⑴.7.el6 (i686)
glibc-devel⑵.12⑴.7.el6 (i686)
libgcc⑷.4.4⑴3.el6 (i686)
libstdc++⑷.4.4⑴3.el6 (i686)
libstdc++-devel⑷.4.4⑴3.el6 (i686)
libaio-0.3.107⑴0.el6 (i686)
libaio-devel-0.3.107⑴0.el6 (i686)
libXext⑴.1 (i686)
libXtst⑴.0.99.2 (i686)
libX11⑴.3 (i686)
libXau⑴.0.5 (i686)
libxcb⑴.5 (i686)
libXi⑴.3 (i686)
创建6个3G 的disk,这个直接使用VirtualBox命令来创建。 创建之前需要先关闭虚拟机。
用以下脚本获得绑定脚本:
for i in b c d e f g;
do
echo"KERNEL=="sd*", BUS=="scsi",PROGRAM=="/sbin/scsi_id -g -u /dev/$name", RESULT=="`/sbin/scsi_id -g -u/dev/sd$i`", NAME="12casm-disk$i", OWNER="grid",GROUP="asmadmin", MODE="0660""
done
KERNEL=="sd*",BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/$name",RESULT=="1ATA_VBOX_HARDDISK_VB626d9087⑻bf68e7e",NAME="12casm-diskb", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*",BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/$name",RESULT=="1ATA_VBOX_HARDDISK_VBf5a8c435⑴9b9adf9",NAME="12casm-diskc", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*",BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/$name",RESULT=="1ATA_VBOX_HARDDISK_VB13895f62⑶18c2cb4",NAME="12casm-diskd", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*",BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/$name",RESULT=="1ATA_VBOX_HARDDISK_VB5049991a⑺41b6a85",NAME="12casm-diske", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*",BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/$name",RESULT=="1ATA_VBOX_HARDDISK_VB6ad43135-cac8a708",NAME="12casm-diskf", OWNER="grid",GROUP="asmadmin", MODE="0660"
KERNEL=="sd*",BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/$name",RESULT=="1ATA_VBOX_HARDDISK_VBe6fb6130⑵a921dde",NAME="12casm-diskg", OWNER="grid",GROUP="asmadmin", MODE="0660"
将产生的结果添加到/etc/udev/rules.d/99-oracle-asmdevices.rules文件。
--重启udev:
[root@12cAsm dave]# start_udev
Starting udev: [ OK ]
[root@12cAsm dave]#
--查看装备:
[root@12cAsm dave]# ll /dev/12casm*
brw-rw----. 1 grid asmadmin 8, 16 Nov 2900:35 /dev/12casm-diskb
brw-rw----. 1 grid asmadmin 8, 32 Nov 2900:35 /dev/12casm-diskc
brw-rw----. 1 grid asmadmin 8, 48 Nov 2900:35 /dev/12casm-diskd
brw-rw----. 1 grid asmadmin 8, 64 Nov 2900:35 /dev/12casm-diske
brw-rw----. 1 grid asmadmin 8, 80 Nov 2900:35 /dev/12casm-diskf
brw-rw----. 1 grid asmadmin 8, 96 Nov 2900:35 /dev/12casm-diskg
[root@12cAsm dave]#
至此配置结束,在ASM的配置中,ASM_DISKSTRING参数指向'/dev/asm-disk*'就能够了。
关闭防火墙:
service iptables status
service iptables stop
chkconfig iptables off
chkconfig iptables --list
设置/etc/selinux/config 文件,将SELINUX设置为disabled。
mkdir -p /u01/grid
mkdir -p /u01/app/grid/12.1.0
chown -R grid:oinstall /u01
mkdir -p /u01/app/oracle/12.1.0/db_1
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01
groupadd -g 1000 oinstall
groupadd -g 1200 asmadmin
groupadd -g 1201 asmdba
groupadd -g 1202 asmoper
groupadd -g 1300 dba
groupadd -g 1301 oper
useradd -m -u 1100 -g oinstall -Gasmadmin,asmdba,asmoper,dba -d /home/grid -s /bin/bash grid
useradd -m -u 1101 -g oinstall -Gdba,oper,asmdba -d /home/oracle -s /bin/bash oracle
确认用户信息:
[root@rac1 ~]# id oracle
uid=502(oracle) gid=507(oinstall)groups=507(oinstall),502(dba),503(oper),506(asmdba)
[root@rac1 ~]# id grid
uid=1100(grid) gid=507(oinstall)groups=507(oinstall),504(asmadmin),506(asmdba),505(asmoper)
修改密码:
passwd oracle
passwd grid
配置环境变量
--Grid用户
修改grid用户的.bash_profile.注意每一个节点的不同内容:
export ORACLE_SID=+ASM
export ORACLE_BASE=/u01/grid
export ORACLE_HOME=/u01/app/grid/12.1.0
exportPATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin/:.
export TEMP=/tmp
export TMP=/tmp
export TMPDIR=/tmp
umask 022
--Oracle 用户
修改oracle 用户的.bash_profile,注意每一个节点的不同内容:
ORACLE_SID=dave;export ORACLE_SID
ORACLE_UNQNAME=dave;export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/12.1.0/db_1; exportORACLE_HOME
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT="YYYY:MM:DD HH24:MI:SS";export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK; exportNLS_LANG
TNS_ADMIN=$ORACLE_HOME/network/admin; exportTNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11
PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$ORA_CRS_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
export PATH
LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH
CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH
THREADS_FLAG=native; export THREADS_FLAG
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
以 root 用户身份,在节点上,在 /etc/security/limits.conf 文件中添加以下内容,或履行履行以下命令:
[root@12cAsm dave]# cat >>/etc/security/limits.conf <<EOF
> grid soft nproc 2047
> grid hard nproc 16384
> grid soft nofile 1024
> grid hard nofile 65536
> oracle soft nproc 2047
> oracle hard nproc 16384
> oracle soft nofile 1024
> oracle hard nofile 65536
> EOF
[root@12cAsm dave]#
[root@12cAsmdave]# cat >> /etc/pam.d/login <<EOF
>session required pam_limits.so
> EOF
[root@12cAsmdave]#
对默许的 shell 启动文件进行以下更改,以便更改所有 Oracle 安装所有者的 ulimit 设置:
[root@12cAsm dave]# cat >>/etc/profile <<EOF
> if [ /$USER = "oracle" ] ||[ /$USER = "grid" ]; then
> if [ /$SHELL = "/bin/ksh" ]; then
> ulimit -p 16384
> ulimit -n 65536
> else
> ulimit -u 16384 -n 65536
> fi
> umask 022
> fi
> EOF
[root@12cAsm dave]#
在sysctl.conf 中加入以下内容:
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
fs.aio-max-nr = 1048576
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 = 1048576
kernel.panic_on_oops = 30
安装之前要确认/etc/hosts 配置:
[root@12cAsm dave]# cat /etc/hosts
127.0.0.1 localhost 12cAsm
不然会报错。
已grid 用户运行安装程序: runInstaller
…
其他都是下1步的操作。 这里不截图了。
履行最后会让我们运行1个root.sh 脚本。
[root@12cAsm /]#/u01/oraInventory/orainstRoot.sh
Changing permissions of /u01/oraInventory.
Adding read,write permissions for group.
Removing read,write,execute permissions forworld.
Changing groupname of /u01/oraInventory tooinstall.
The execution of the script is complete.
[root@12cAsm /]#
[root@12cAsm /]#/u01/app/grid/12.0.1/root.sh
Performing root user operation.
The following environment variables are setas:
ORACLE_OWNER= grid
ORACLE_HOME= /u01/app/grid/12.0.1
Enter the full pathname of the local bindirectory: [/usr/local/bin]:
Copying dbhome to /usr/local/bin ...
Copying oraenv to /usr/local/bin ...
Copying coraenv to /usr/local/bin ...
Creating /etc/oratab file...
Entries will be added to the /etc/oratabfile as needed by
Database Configuration Assistant when adatabase is created
Finished running generic part of rootscript.
Now product-specific root actions will beperformed.
To configure GridInfrastructure for a Stand-Alone Server run the following command as the rootuser:
/u01/app/grid/12.0.1/perl/bin/perl-I/u01/app/grid/12.0.1/perl/lib -I/u01/app/grid/12.0.1/crs/install/u01/app/grid/12.0.1/crs/install/roothas.pl
To configure GridInfrastructure for a Cluster execute the following command as grid user:
/u01/app/grid/12.0.1/crs/config/config.sh
This command launches the GridInfrastructure Configuration Wizard. The wizard also supports silent operation,and the parameters can be passed through the response file that is available inthe installation media.
[root@12cAsm /]#
我们这里是单节点的ASM,所以履行以下SQL:
/u01/app/grid/12.0.1/perl/bin/perl-I/u01/app/grid/12.0.1/perl/lib -I/u01/app/grid/12.0.1/crs/install/u01/app/grid/12.0.1/crs/install/roothas.pl
[root@12cAsm /]#/u01/app/grid/12.0.1/perl/bin/perl -I/u01/app/grid/12.0.1/perl/lib-I/u01/app/grid/12.0.1/crs/install /u01/app/grid/12.0.1/crs/install/roothas.pl
Using configuration parameter file:/u01/app/grid/12.0.1/crs/install/crsconfig_params
LOCAL ADD MODE
Creating OCR keys for user 'grid', privgrp'oinstall'..
Operation successful.
LOCAL ONLY MODE
Successfully accumulated necessary OCRkeys.
Creating OCR keys for user 'root', privgrp'root'..
Operation successful.
CRS⑷664: Node 12casm successfully pinned.
2014/11/29 02:16:15 CLSRSC⑶30: AddingClusterware entries to file 'oracle-ohasd.conf'
12casm 2014/11/29 02:17:09 /u01/app/grid/12.0.1/cdata/12casm/backup_20141129_021709.olr 0
CRS⑵791: Starting shutdown of Oracle HighAvailability Services-managed resources on '12casm'
CRS⑵673: Attempting to stop 'ora.evmd' on'12casm'
CRS⑵677: Stop of 'ora.evmd' on '12casm'succeeded
CRS⑵793: Shutdown of Oracle HighAvailability Services-managed resources on '12casm' has completed
CRS⑷133: Oracle High Availability Serviceshas been stopped.
CRS⑷123: Oracle High Availability Serviceshas been started.
2014/11/29 02:19:52CLSRSC⑶27: Successfully configured Oracle Restart for a standalone server
[root@12cAsm /]#
--检查:
[root@12cAsm /]# ocrcheck
Status of Oracle Cluster Registry is asfollows :
Version : 4
Total space (kbytes) : 409568
Used space (kbytes) : 200
Available space (kbytes) : 409368
ID : 1150490114
Device/File Name : /u01/app/grid/12.0.1/cdata/localhost/local.ocr
Device/Fileintegrity check succeeded
Device/Filenot configured
Device/Filenot configured
Device/File not configured
Device/Filenot configured
Cluster registry integrity check succeeded
Logical corruption check succeeded
[root@12cAsm /]#
[root@12cAsm /]# crsctl status res -t
--------------------------------------------------------------------------------
Name Target State Server Statedetails
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.ons
OFFLINE OFFLINE 12casm STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 OFFLINE OFFLINE STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE 12casm STABLE
--------------------------------------------------------------------------------
[root@12cAsm /]#
以Oracle 用户履行安装程序。
注意,选择只安装数据库软件。
然后都是下1步的操作。
履行脚本:
[root@12cAsm /]#/u01/app/oracle/12.0.1/db_1/root.sh
Performing root user operation.
The following environment variables are setas:
ORACLE_OWNER= oracle
ORACLE_HOME= /u01/app/oracle/12.0.1/db_1
Enter the full pathname of the local bindirectory: [/usr/local/bin]:
The contents of "dbhome" have notchanged. No need to overwrite.
The contents of "oraenv" have notchanged. No need to overwrite.
The contents of "coraenv" havenot changed. No need to overwrite.
Entries will be added to the /etc/oratabfile as needed by
Database Configuration Assistant when adatabase is created
Finished running generic part of rootscript.
Now product-specific root actions will beperformed.
[root@12cAsm /]#
使用grid用户履行asmca,创建磁盘组Data。
ASM disk group 弄定。
检查ASM DISK GROUPS的情况:
[grid@12cAsm bin]$ crsctl status res -t
--------------------------------------------------------------------------------
Name Target State Server Statedetails
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE 12casm STABLE
ora.asm
ONLINE ONLINE 12casm Started,STABLE
ora.ons
OFFLINE OFFLINE 12casm STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE 12casm STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE 12casm STABLE
--------------------------------------------------------------------------------
[grid@12cAsm bin]$
已oracle 用户运行dbca,创建实例。
[grid@12cAsm bin]$ crsctl status res -t
--------------------------------------------------------------------------------
Name Target State Server Statedetails
--------------------------------------------------------------------------------
Local Resources
--------------------------------------------------------------------------------
ora.DATA.dg
ONLINE ONLINE 12casm STABLE
ora.asm
ONLINE ONLINE 12casm Started,STABLE
ora.ons
OFFLINE OFFLINE 12casm STABLE
--------------------------------------------------------------------------------
Cluster Resources
--------------------------------------------------------------------------------
ora.cssd
1 ONLINE ONLINE 12casm STABLE
ora.dave.db
1 ONLINE ONLINE 12casm Open,STABLE
ora.diskmon
1 OFFLINE OFFLINE STABLE
ora.evmd
1 ONLINE ONLINE 12casm STABLE
--------------------------------------------------------------------------------
[grid@12cAsm bin]$
[oracle@12cAsm ~]$ sqlplus / as sysdba
SQL*Plus: Release 12.1.0.2.0 Production onSat Nov 29 15:09:37 2014
Copyright (c) 1982, 2014, Oracle. All rights reserved.
Connected to:
Oracle Database 12c Enterprise EditionRelease 12.1.0.2.0 - 64bit Production
With the Partitioning, Automatic StorageManagement, OLAP, Advanced Analytics
and Real Application Testing options
SQL> set lin 140
SQL> select * from v$version;
BANNER CON_ID
------------------------------------------------------------------------------------------
OracleDatabase 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production 0
PL/SQLRelease 12.1.0.2.0 - Production 0
CORE 12.1.0.2.0 Production 0
TNSfor Linux: Version 12.1.0.2.0 - Production 0
NLSRTLVersion 12.1.0.2.0 - Production 0
SQL> show con_name
CON_NAME
------------------------------
CDB$ROOT
SQL> col pdb_name for a20
SQL> select PDB_NAME,CON_UID,pdb_id,status from dba_pdbs;
PDB_NAME CON_UID PDB_ID STATUS
-------------------- ---------- -------------------
PDAVE 1778789142 3 NORMAL
PDB$SEED 1845119286 2 NORMAL
SQL> select con_id,dbid,NAME,OPEN_MODEfrom v$pdbs;
CON_ID DBID NAME OPEN_MODE
---------- ---------------------------------------- ----------
2 1845119286 PDB$SEED READ ONLY
3 1778789142 PDAVE READ WRITE
SQL>
--------------------------------------------------------------------------------------------
版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!
AboutDave:
--------------------------------------------------------------------------------------------
QQ: 251097186
Email: tianlesoftware@gmail.com
Blog: http://blog.csdn.net/tianlesoftware
Weibo: http://weibo.com/tianlesoftware
Twitter: http://twitter.com/tianlesoftware
Facebook: http://www.facebook.com/tianlesoftware
Linkedin: http://cn.linkedin.com/in/tianlesoftware
Dave 的QQ群:
--------------------------------------------------------------------------------------------
注意:加群必须注明表空间和数据文件关系 | 不要重复加群
CNDBA_1: 104207940 (满) CNDBA_2: 62697716 (满) CNDBA_3: 283816689
CNDBA_4: 391125754 CNDBA_5: 62697850 CNDBA_6: 62697977 CNDBA_7: 142216823(满)