從Oracle 10g開(kāi)始,Oracle 開(kāi)始推行ASM的使用,到了11g,RAC 集群已必須使用ASM,所以對(duì)ASM的掌握程度也決定RAC的運(yùn)維水平,這篇Blog 演示 Oracle12c 基于ASM 的單實(shí)例的的環(huán)境搭建。
這樣便可以玩12c 的ASM,又不需要起2個(gè)集群,從而方便學(xué)習(xí)。具體環(huán)境搭建步驟以下。
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)
創(chuàng)建6個(gè)3G 的disk,這個(gè)直接使用VirtualBox命令來(lái)創(chuàng)建。 創(chuàng)建之前需要先關(guān)閉虛擬機(jī)。
用以下腳本獲得綁定腳本:
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"
將產(chǎn)生的結(jié)果添加到/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]#
至此配置結(jié)束,在ASM的配置中,ASM_DISKSTRING參數(shù)指向'/dev/asm-disk*'就能夠了。
關(guān)閉防火墻:
service iptables status
service iptables stop
chkconfig iptables off
chkconfig iptables --list
設(shè)置/etc/selinux/config 文件,將SELINUX設(shè)置為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
確認(rèn)用戶(hù)信息:
[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
配置環(huán)境變量
--Grid用戶(hù)
修改grid用戶(hù)的.bash_profile.注意每一個(gè)節(jié)點(diǎn)的不同內(nèi)容:
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 用戶(hù)
修改oracle 用戶(hù)的.bash_profile,注意每一個(gè)節(jié)點(diǎn)的不同內(nèi)容:
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 用戶(hù)身份,在節(jié)點(diǎn)上,在 /etc/security/limits.conf 文件中添加以下內(nèi)容,或履行履行以下命令:
[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]#
對(duì)默許的 shell 啟動(dòng)文件進(jìn)行以下更改,以便更改所有 Oracle 安裝所有者的 ulimit 設(shè)置:
[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 中加入以下內(nèi)容:
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
安裝之前要確認(rèn)/etc/hosts 配置:
[root@12cAsm dave]# cat /etc/hosts
127.0.0.1 localhost 12cAsm
不然會(huì)報(bào)錯(cuò)。
已grid 用戶(hù)運(yùn)行安裝程序: runInstaller
…
其他都是下1步的操作。 這里不截圖了。
履行最后會(huì)讓我們運(yùn)行1個(gè)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 /]#
我們這里是單節(jié)點(diǎn)的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 用戶(hù)履行安裝程序。
注意,選擇只安裝數(shù)據(jù)庫(kù)軟件。
然后都是下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用戶(hù)履行asmca,創(chuàng)建磁盤(pán)組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 用戶(hù)運(yùn)行dbca,創(chuàng)建實(shí)例。
[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>
--------------------------------------------------------------------------------------------
版權(quán)所有,文章允許轉(zhuǎn)載,但必須以鏈接方式注明源地址,否則追究法律責(zé)任!
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群:
--------------------------------------------------------------------------------------------
注意:加群必須注明表空間和數(shù)據(jù)文件關(guān)系 | 不要重復(fù)加群
CNDBA_1: 104207940 (滿(mǎn)) CNDBA_2: 62697716 (滿(mǎn)) CNDBA_3: 283816689
CNDBA_4: 391125754 CNDBA_5: 62697850 CNDBA_6: 62697977 CNDBA_7: 142216823(滿(mǎn))