
image.png

image.png

image.png
Oracle 11g 采用asm方式安裝數(shù)據(jù)庫:
一、database軟件安裝:
1、環(huán)境準備:關閉selinux iptables ip6tables NetworkManager yum源配置
1.1、關閉防火墻并不開機自啟
[root@oracle ~]# service iptables stop
[root@oracle ~]# chkconfig iptables off
[root@oracle ~]# service ip6tables stop
[root@oracle ~]# chkconfig ip6tables off
1.2、永久關閉selinux
[root@oracle ~]# cat /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these two values:
# targeted - Targeted processes are protected,
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
1.3、永久關閉NetworkManager
service NetworkManager stop
1.4、配置yum源:
[root@oracle ~]# vim /etc/yum.repos.d/rhel-source.repo
[aaa]
name=123123
enabled=1
gpgcheck=0
baseurl=file:///mnt
[root@oracle ~]# mount /dev/sr0 /mnt
mount: block device /dev/sr0 is write-protected, mounting read-only
[root@oracle ~]# yum repolist
Loaded plugins: product-id, refresh-packagekit, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
repo id repo name status
aaa 123123 3,690
repolist: 3,690
2、設置主機名、修改/etc/hosts,設置主機名和Ip的對應關系:
[root@oracle ~]# hostname oracle
[root@oracle ~]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
10.0.0.5 oracle
[root@oracle ~]# cat /etc/sysconfig/network
NETWORKING=yes
HOSTNAME=oracle
3、安裝oracle依賴的軟件包:
yum -y install binutils-* compat-libstdc++-* compat-libstdc++-*.i686 elfutils-libelf* elfutils-libelf-devel* gcc-* gcc-c++-* glibc-* glibc-*.i686 glibc-common* glibc-devel* glibc-devel*.i686 glibc-headers* ksh* libaio* libaio*.i686 libaio* libaio*.i686 libgcc* libgcc*.i686 libstdc++* libstdc++*.i686 libstdc++-devel* make* sysstat* unixODBC* unixODBC*.i686 unixODBC-devel* unixODBC-devel*
4、建立用戶和組:
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 504 asmadmin
groupadd -g 506 asmdba
groupadd -g 507 asmoper
useradd -u 501 -g oinstall -G asmadmin,asmdba,asmoper,dba grid
useradd -u 502 -g oinstall -G dba,asmdba,asmadmin oracle
passwd grid
passwd oracle
5、創(chuàng)建基本目錄:

image.png
5.1、創(chuàng)建grid目錄結構 grid 軟件相關路徑 grid用戶:
mkdir -p /u01/app/oraInventory
chown -R oracle:oinstall /u01/app/oraInventory
chmod -R 775 /u01/app/oraInventory
mkdir -p /u01/app/grid
chmod -R 775 /u01/app/grid
chown -R grid:oinstall /u01/app/grid
mkdir -p /u01/app/11.2.0/grid
chown -R grid:oinstall /u01/app/11.2.0/grid
chmod -R 775 /u01/app/11.2.0/grid
5.2、創(chuàng)建oracle目錄結構(創(chuàng)建的是database軟件相關的路徑):
mkdir -p /u01/app/oracle
mkdir -p /u01/app/oracle/cfgtoollogs
chown -R oracle:oinstall /u01/app/oracle
chmod -R 775 /u01/app/oracle
5.3、編寫oracle用戶的.bash_profile
oracle用戶操作:
vim ~/.bash_profile
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=$ORACLE_BASE/product/11.2/db_1
export PATH=$PATH:$ORACLE_HOME/bin
[oracle@oracle ~]$ source .bash_profile
5.4、grid用戶操作:
vim ~/.bash_profile
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=$PATH:$ORACLE_HOME/bin
[grid@oracle ~]$ source .bash_profile
6、修改內核參數(shù)和limit:(但是在11g中數(shù)據(jù)庫安裝時可以自動修改,在這里我們先不手動修改)
7、上傳軟件并解壓database軟件包:
[oracle@oracle tmp]$ ll
-rw-r--r--. 1 oracle oinstall 1358454646 Apr 7 08:41 p10404530_112030_Linux-x86-64_1of7.zip
-rw-r--r--. 1 oracle oinstall 1142195302 Apr 7 08:42 p10404530_112030_Linux-x86-64_2of7.zip
-rw-r--r--. 1 oracle oinstall 979195792 Apr 7 08:43 p10404530_112030_Linux-x86-64_3of7.zip
[oracle@oracle tmp]$ unzip p10404530_112030_Linux-x86-64_1of7.zip
[oracle@oracle tmp]$ unzip p10404530_112030_Linux-x86-64_2of7.zip
8、用oracle用戶安裝database軟件:
[oracle@oracle tmp]$ cd database/
[oracle@oracle database]$
[oracle@oracle database]$ ls
doc readme.html rpm sshsetup welcome.html
install response runInstaller stage
[oracle@oracle database]$ ./runInstaller

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png
[root@oracle ~]# /tmp/CVU_11.2.0.3.0_oracle/runfixup.sh
Response file being used is :/tmp/CVU_11.2.0.3.0_oracle/fixup.response
Enable file being used is :/tmp/CVU_11.2.0.3.0_oracle/fixup.enable
Log file location: /tmp/CVU_11.2.0.3.0_oracle/orarun.log
Setting Kernel Parameters...
The value for shmmni in response file is not greater than value of shmmni for current session. Hence not changing it.
The value for semmsl in response file is not greater than value of semmsl for current session. Hence not changing it.
The value for semmns in response file is not greater than value of semmns for current session. Hence not changing it.
The value for semmni in response file is not greater than value of semmni for current session. Hence not changing it.
kernel.sem = 250 32000 100 128
fs.file-max = 6815744
net.ipv4.ip_local_port_range = 9000 65500
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 4194304
net.core.wmem_max = 1048576
fs.aio-max-nr = 1048576
uid=502(oracle) gid=501(oinstall) groups=501(oinstall),502(dba),506(asmdba)

image.png

image.png

image.png

image.png
二、grid軟件安裝:

image.png
備注:軟件安裝過程中就涉及到asmdb配置--->+ASM實例
1、環(huán)境準備:
1.1、停機給這個虛擬機添加3塊盤(只用2塊):

image.png
1.2、fdisk查看一下:
[root@oracle ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b1a5d
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdd: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
2、grid軟件安裝:
2.1、補一個包:
yum install -y compat*
2.2、修改grid環(huán)境變量:
[grid@oracle ~]$ vim .bash_profile
export ORACLE_BASE=/u01/app/grid
export ORACLE_HOME=/u01/app/11.2.0/grid
export PATH=$ORACLE_HOME/bin:$PATH
export ORACLE_SID=+ASM
[grid@oracle ~]$ source .bash_profile
2.3、準備兩個字符設備,創(chuàng)建兩個dg:
備注:需要兩個dg:
griddg:存放asm信息
datadg:存放asmdb數(shù)據(jù)庫文件
2.3.1、分區(qū):
/dev/sdc 分兩個分區(qū)
/dev/sdc1 --> raw1 --> griddg --> 存放asm管理信息
/dev/sdc2 --> raw2 --> datadg --> 具體數(shù)據(jù)庫(asmdb)的數(shù)據(jù)庫文件
[root@oracle ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xa79114f8.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
WARNING: DOS-compatible mode is deprecated. It's strongly recommended to
switch off the mode (command 'c') and change display units to
sectors (command 'u').
Command (m for help): p
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa79114f8
Device Boot Start End Blocks Id System
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-652, default 1):
Using default value 1
Last cylinder, +cylinders or +size{K,M,G} (1-652, default 652): +1G
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 2
First cylinder (133-652, default 133):
Using default value 133
Last cylinder, +cylinders or +size{K,M,G} (133-652, default 652):
Using default value 652
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
查看sdc分區(qū)情況:
[root@oracle ~]# fdisk -l
Disk /dev/sda: 42.9 GB, 42949672960 bytes
255 heads, 63 sectors/track, 5221 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000b1a5d
Device Boot Start End Blocks Id System
/dev/sda1 * 1 64 512000 83 Linux
Partition 1 does not end on cylinder boundary.
/dev/sda2 64 5222 41430016 8e Linux LVM
Disk /dev/sdb: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc: 5368 MB, 5368709120 bytes
255 heads, 63 sectors/track, 652 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xa79114f8
Device Boot Start End Blocks Id System
/dev/sdc1 1 132 1060258+ 83 Linux
/dev/sdc2 133 652 4176900 83 Linux
2.3.2、root 用戶映射設備:
[root@oracle ~]# vim /etc/udev/rules.d/60-raw.ru
ACTION=="add", KERNEL=="sdc1", RUN+="/bin/raw /dev/raw/raw1 %N"
ACTION=="add", KERNEL=="sdc2", RUN+="/bin/raw /dev/raw/raw2 %N"
KERNEL=="raw*",OWNER="grid",GROUP="asmadmin",MODE="0660"
[root@oracle ~]# start_udev
Starting udev: [ OK ]
查看是否映射成功:
[root@oracle ~]# cd /dev/raw
[root@oracle raw]# ll
total 0
crw-rw---- 1 grid asmadmin 162, 1 Apr 7 11:18 raw1
crw-rw---- 1 grid asmadmin 162, 2 Apr 7 11:18 raw2
crw-rw---- 1 grid asmadmin 162, 0 Apr 7 11:18 rawctl
2.4、使用grid用戶安裝grid 軟件(安裝完成grid后就有了griddg)
2.4.1、上傳軟件并解壓縮:
[grid@oracle tmp]$ unzip p10404530_112030_Linux-x86-64_3of7.zip
[grid@oracle tmp]$ ll
drwxr-xr-x. 8 oracle oinstall 4096 Sep 22 2011 database
drwxr-xr-x 8 grid oinstall 4096 Sep 22 2011 grid
-rw-r--r--. 1 oracle oinstall 979195792 Apr 7 08:43 p10404530_112030_Linux-x86-64_3of7.zip
2.4.2、安裝grid軟件:
[grid@oracle tmp]$ cd grid
[grid@oracle grid]$ ll
total 72
drwxr-xr-x 9 grid oinstall 4096 Sep 22 2011 doc
drwxr-xr-x 4 grid oinstall 4096 Sep 22 2011 install
-rwxr-xr-x 1 grid oinstall 28122 Sep 22 2011 readme.html
drwxr-xr-x 2 grid oinstall 4096 Sep 22 2011 response
drwxr-xr-x 2 grid oinstall 4096 Sep 22 2011 rpm
-rwxr-xr-x 1 grid oinstall 4878 Sep 22 2011 runcluvfy.sh
-rwxr-xr-x 1 grid oinstall 3227 Sep 22 2011 runInstaller
drwxr-xr-x 2 grid oinstall 4096 Sep 22 2011 sshsetup
drwxr-xr-x 14 grid oinstall 4096 Sep 22 2011 stage
-rwxr-xr-x 1 grid oinstall 4326 Sep 2 2011 welcome.html
[grid@oracle grid]$ ./runInstaller

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png
[root@oracle ~]# /tmp/CVU_11.2.0.3.0_grid/runfixup.sh
Response file being used is :/tmp/CVU_11.2.0.3.0_grid/fixup.response
Enable file being used is :/tmp/CVU_11.2.0.3.0_grid/fixup.enable
Log file location: /tmp/CVU_11.2.0.3.0_grid/orarun.log
uid=501(grid) gid=501(oinstall) groups=501(oinstall),502(dba),504(asmadmin),506(asmdba),507(asmoper)

image.png

image.png

image.png

image.png

image.png
查看asm實例進程(證明asm實例安裝完成):
[grid@oracle grid]$ ps -ef |grep asm
grid 8944 1 0 11:47 ? 00:00:00 asm_pmon_+ASM
grid 8946 1 0 11:47 ? 00:00:00 asm_psp0_+ASM
grid 8948 1 0 11:47 ? 00:00:00 asm_vktm_+ASM
grid 8952 1 0 11:47 ? 00:00:00 asm_gen0_+ASM
grid 8954 1 0 11:47 ? 00:00:00 asm_diag_+ASM
grid 8956 1 0 11:47 ? 00:00:00 asm_dia0_+ASM
grid 8958 1 0 11:47 ? 00:00:00 asm_mman_+ASM
grid 8960 1 0 11:47 ? 00:00:00 asm_dbw0_+ASM
grid 8962 1 0 11:47 ? 00:00:00 asm_lgwr_+ASM
grid 8964 1 0 11:47 ? 00:00:00 asm_ckpt_+ASM
grid 8966 1 0 11:47 ? 00:00:00 asm_smon_+ASM
grid 8968 1 0 11:47 ? 00:00:00 asm_rbal_+ASM
grid 8970 1 0 11:47 ? 00:00:00 asm_gmon_+ASM
grid 8972 1 0 11:47 ? 00:00:00 asm_mmon_+ASM
grid 8974 1 0 11:47 ? 00:00:00 asm_mmnl_+ASM
grid 9007 2756 0 11:48 pts/4 00:00:00 grep asm
2.5、dbca建庫(需要使用dg存放數(shù)據(jù)庫文件--->datadg)
2.5.1、準備datadg:
[grid@oracle ~]$ asmca

image.png

image.png

image.png
2.5.2、oracle用戶dbca建庫:

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png
一、文件系統(tǒng)建庫:
1、創(chuàng)建數(shù)據(jù)目錄以及格式化磁盤、掛載磁盤、給目錄授權:
[root@oracle ~]# mkdir /oradata
[root@oracle ~]# mkfs.ext4 /dev/sdb
mke2fs 1.41.12 (17-May-2010)
/dev/sdb is entire device, not just one partition!
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
327680 inodes, 1310720 blocks
65536 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1342177280
40 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 30 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
[root@oracle ~]# mount /dev/sdb /oradata/
[root@oracle ~]# chown -R oracle: /oradata
[root@oracle ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/VolGroup-lv_root 36G 11G 23G 32% /
tmpfs 996M 72K 996M 1% /dev/shm
/dev/sda1 485M 39M 421M 9% /boot
/dev/sdb 5.0G 138M 4.6G 3% /oradata
2、dbca建庫:

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png