Linux平台Oracle 11g單一實例 + ASM儲存 安裝部署 快速參考

來源:互聯網
上載者:User

Linux平台Oracle 11g單一實例 + ASM儲存 安裝部署 快速參考

作業環境:Citrix虛擬化環境中申請一個Linux6.4主機(模板)
目標:建立單機11g + ASM儲存 資料庫

1.主機準備

--------------------------------------------------------------------------------

IP地址:

主機名稱:JY-DB

目錄:/u01

磁碟:從主機本地磁碟資源劃分50G硬碟1個,從磁陣資源劃分10G硬碟3個

1.1 檢查主機名稱和IP地址的映射:hostname -i

hostname

vi /etc/sysconfig/network

vi /etc/hosts

1.2 分配/u01目錄為Oracle軟體安裝目錄,lv_asm1,lv_asm2,lv_asm3為ASM磁碟

/dev/xvdb 50G 格式化後掛載到/u01目錄

/dev/xvdc /dev/xvde /dev/xvdf 各10G,不用格式化,給ASM使用

 

pvcreate /dev/xvdc /dev/xvde /dev/xvdf
vgcreate ora_vg /dev/xvdc /dev/xvde /dev/xvdf
lvcreate -L 10g -n lv_asm1 ora_vg
lvcreate -L 10g -n lv_asm2 ora_vg
vgdisplay ora_vg
lvcreate -l 2557 -n lv_asm3 ora_vg

 

在後面建立grid使用者後,建立ASM前,需要更改lv的磁碟許可權

chown grid:asmadmin /dev/mapper/ora*

1.3 配置YUM,安裝依賴包

yum配置參考:

配置EPEL YUM源

RedHat 本地yum源配置

yum的設定檔說明

RedHat 6.1下安裝yum(圖文)

YUM 安裝及清理

CentOS 6.4上搭建yum本地源

yum install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc- gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh ksh compat-libcap1

若之前安裝系統沒有安裝圖形,需要安裝圖形介面和xterm

yum groupinstall "X Window System"

yum install xterm

1.4 關閉系統防火牆開機啟動

service iptables stop

chkconfig iptables off

2.建立ORACLE 使用者和群組成員

--------------------------------------------------------------------------------

groupadd oinstall
groupadd dba
groupadd oper
groupadd asmadmin
groupadd asmdba
groupadd asmoper

useradd -g oinstall -G dba,asmdba,oper oracle
useradd -g oinstall -G dba,asmadmin,asmdba,asmoper grid

 

分別指定oracle、grid使用者的密碼

passwd oracle
passwd grid

3.建立以下目錄並賦予對應許可權

--------------------------------------------------------------------------------

mkdir -p /u01/app/11.2.0/grid
mkdir -p /u01/app/grid
mkdir -p /u01/app/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /u01/app
chmod -R 775 /u01/app

4.設定oracle、grid使用者的環境變數

--------------------------------------------------------------------------------

4.1 oracle使用者登陸: vi ~/.bash_profile

export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db_1
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=american_america.ZHS16GBK
export ORACLE_SID=jyzhao
export PATH=$PATH:$ORACLE_HOME/bin:.

4.2 grid使用者登入:vi ~/.bash_profile

export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:.
export NLS_LANG=American_america.ZHS16GBK
export PATH=$PATH:$ORACLE_HOME/bin:.
export ORACLE_SID=+ASM

5.root使用者更改系統參數

--------------------------------------------------------------------------------

5.1 vi /etc/sysctl.conf

fs.aio-max-nr = 1048576
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4398046511104 //一般設定為系統記憶體75%單位是位元組
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

使設定立即生效: /sbin/sysctl -p

5.2 vi /etc/security/limits.conf

oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 1024

5.3 vi /etc/pam.d/login

#oracle

session required /lib64/security/pam_limits.so

session required pam_limits.so

6.上傳Oracle安裝介質到/u01/tmp目錄下

--------------------------------------------------------------------------------

mkdir -p /u01/tmp

p13390677_112040_Linux-x86-64_1of7.zip

p13390677_112040_Linux-x86-64_2of7.zip

p13390677_112040_Linux-x86-64_3of7.zip

7.安裝grid組件

--------------------------------------------------------------------------------

#cd /u01/tmp/

#unzip p10404530_112030_Linux-x86-64_3of7.zip

#chown -R grid:oinstall grid

Xmanager軟體用grid使用者登入

$cd /u01/tmp/grid

$./runInstaller

圖形介面安裝,最後root使用者執行兩個指令碼,執行指令碼的螢幕輸出如下:

 

# /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.

# /u01/app/11.2.0/grid/root.sh

Performing root user operation for Oracle 11g

 

The following environment variables are set as:

    ORACLE_OWNER= grid

    ORACLE_HOME=  /u01/app/11.2.0/grid

 

Enter the full pathname of the local bin directory: [/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/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.

 

To configure Grid Infrastructure for a Stand-Alone Server run the following command as the root user:

/u01/app/11.2.0/grid/perl/bin/perl -I/u01/app/11.2.0/grid/perl/lib -I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl

To configure Grid Infrastructure for a Cluster execute the following command:

/u01/app/11.2.0/grid/crs/config/config.sh

This command launches the Grid Infrastructure Configuration Wizard. The wizard also supports silent operation, and the parameters can be passed through the response file that is available in the installation media.

8.根據上步執行的指令碼輸出提示,確定單節點需要root使用者執行下面的命令

--------------------------------------------------------------------------------

/u01/app/11.2.0/grid/perl/bin/perl -I/u01/app/11.2.0/grid/perl/lib -I/u01/app/11.2.0/grid/crs/install /u01/app/11.2.0/grid/crs/install/roothas.pl

9.使用asmca建立ASM 磁碟組

--------------------------------------------------------------------------------

Xmanager軟體用grid使用者登入

$asmca

10.安裝oralce軟體

--------------------------------------------------------------------------------

#cd /u01/tmp/

#unzip p13390677_112040_Linux-x86-64_1of7.zip;unzip p13390677_112040_Linux-x86-64_2of7.zip

#chown -R oracle:oinstall database

Xmanager軟體用oracle使用者登入

$cd /u01/tmp/database/

$./runInstaller

圖形介面安裝,最後root使用者執行一個指令碼

#/u01/app/oracle/product/11.2.0/db_1/root.sh

11.建立資料庫

--------------------------------------------------------------------------------

Xmanager軟體用oracle使用者登入

$dbca

圖形介面建庫,Storage Type選擇ASM,+DATA1磁碟組,資料庫字元集根據實際情況選擇。

12.使用grid使用者建立監聽

--------------------------------------------------------------------------------

Xmanager軟體用grid使用者登入

$netca

13.用戶端測試資料庫連接

--------------------------------------------------------------------------------

ping IP地址

tnsping IP地址

sqlplus system/oracle@IP地址/jyzhao

14.由於lv的許可權在重啟後會變回root使用者,需要添加開機啟動指令碼

--------------------------------------------------------------------------------

vi /etc/rc.d/rc.local

chown grid:asmadmin /dev/mapper/ora*

建立rc.local的連結檔案

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc1.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc2.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc3.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc4.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc5.d/S999rc.local &&

ln -sf /etc/rc.d/rc.local /etc/rc.d/rc6.d/S999rc.local

15.重啟測試

--------------------------------------------------------------------------------

15.1 關閉資料庫

# su - oracle

$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Thu Mar 12 14:14:38 2015

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, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

 

SQL> shutdown immediate

Database closed.

Database dismounted.

ORACLE instance shut down.

SQL>

15.2 關閉has

$ su - grid

Password:

$ crsctl stop has

CRS-2791: Starting shutdown of Oracle High Availability Services-managed resources on 'jy-db'

CRS-2673: Attempting to stop 'ora.LISTENER.lsnr' on 'jy-db'

CRS-2673: Attempting to stop 'ora.DATA1.dg' on 'jy-db'

CRS-2677: Stop of 'ora.LISTENER.lsnr' on 'jy-db' succeeded

CRS-2677: Stop of 'ora.DATA1.dg' on 'jy-db' succeeded

CRS-2679: Attempting to clean 'ora.DATA1.dg' on 'jy-db'

CRS-2681: Clean of 'ora.DATA1.dg' on 'jy-db' succeeded

CRS-2673: Attempting to stop 'ora.asm' on 'jy-db'

CRS-2677: Stop of 'ora.asm' on 'jy-db' succeeded

CRS-2673: Attempting to stop 'ora.cssd' on 'jy-db'

CRS-2677: Stop of 'ora.cssd' on 'jy-db' succeeded

CRS-2673: Attempting to stop 'ora.evmd' on 'jy-db'

CRS-2677: Stop of 'ora.evmd' on 'jy-db' succeeded

CRS-2793: Shutdown of Oracle High Availability Services-managed resources on 'jy-db' has completed

CRS-4133: Oracle High Availability Services has been stopped.

15.3 重啟主機

# sync

# sync

# sync

# shutdown -Fr now

 

Broadcast message from root@JY-DB

        (/dev/pts/0) at 14:20 ...

 

The system is going down for reboot NOW!

15.4主機啟動後,查看crs狀態

# /u01/app/11.2.0/grid/bin/crsctl stat res -t

--------------------------------------------------------------------------------

NAME          TARGET  STATE        SERVER                  STATE_DETAILS     

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.DATA1.dg

              ONLINE  ONLINE      jy-db                                     

ora.LISTENER.lsnr

              ONLINE  ONLINE      jy-db                                     

ora.asm

              ONLINE  ONLINE      jy-db                    Started           

ora.ons

              OFFLINE OFFLINE      jy-db                                       

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.cssd

      1        ONLINE  ONLINE      jy-db                                       

ora.diskmon

      1        OFFLINE OFFLINE                                                 

ora.evmd

      1        ONLINE  ONLINE      jy-db                                     

ora.jyzhao.db

      1        OFFLINE OFFLINE                              Instance Shutdown 

15.5 啟動資料庫

# /u01/app/11.2.0/grid/bin/srvctl start database -d jyzhao

# /u01/app/11.2.0/grid/bin/crsctl stat res -t

--------------------------------------------------------------------------------

NAME          TARGET  STATE        SERVER                  STATE_DETAILS     

--------------------------------------------------------------------------------

Local Resources

--------------------------------------------------------------------------------

ora.DATA1.dg

              ONLINE  ONLINE      jy-db                                     

ora.LISTENER.lsnr

              ONLINE  ONLINE      jy-db                                     

ora.asm

              ONLINE  ONLINE      jy-db                    Started           

ora.ons

              OFFLINE OFFLINE      jy-db                                     

--------------------------------------------------------------------------------

Cluster Resources

--------------------------------------------------------------------------------

ora.cssd

      1        ONLINE  ONLINE      jy-db                                     

ora.diskmon

      1        OFFLINE OFFLINE                                                 

ora.evmd

      1        ONLINE  ONLINE      jy-db                                     

ora.jyzhao.db

      1        ONLINE  ONLINE      jy-db                    Open           

   

15.6 用戶端測試

C:\Users\Alfred>sqlplus system/oracle@IP地址/jyzhao

SQL*Plus: Release 11.2.0.1.0 Production on 星期四 3月 12 14:27:12 2015

Copyright (c) 1982, 2010, Oracle.  All rights reserved.

串連到:

Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production

With the Partitioning, Automatic Storage Management, OLAP, Data Mining

and Real Application Testing options

SQL> 

至此,Linux平台oracle 11g單一實例 + ASM儲存 安裝部署全部完成。

Oracle ASM 如何添加新磁碟到磁碟 

Oracle 10g 手工建立ASM資料庫

Ubuntu 12.04(amd64)安裝完Oracle 11gR2後各種問題解決方案

如何修改Oracle 10g ASM的sys密碼

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.