分类: Oracle
2013-01-26 08:04:28
ORACLE 10G 10.2.0.1
OS: REDHAT AS4 U3 检验内核的命令:
#Uname –R 2.6.9-34.EL
检查安装包:
#rpm -q gcc gcc-c++ glibc libaio libaio-devel make openmotif-libs
Linux部分
Oracle用户和用户组
#/usr/sbin/groupadd -g 501 oinstall
#/usr/sbin/groupadd -g 502 dba
#/usr/sbin/useradd -m -u 501 -g oinstall -G dba oracle
设置oracle账户的密码:
# passwd oracle
Changing password for user oracle.
New password:
Retype new password:
passwd: all authentication tokens updated successfully.
创建挂载点 现在我们来创建安装Oracle10g软件的挂载点。确保用root用户来运行下面的命令:
#mkdir -p /opt/oracle
#chown -R oracle:oinstall /opt/oracle
#chmod -R 775 /opt/oracle
配置Linux核心参数。/etc/sysctl.conf
kernel.shmall = 2097152
kernel.shmmax = 536870912
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 658576
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 1048536
net.core.wmem_max = 1048536
#/sbin/sysctl -p
注意:shmmax和shmall(8G限制). 如果内存大于8G,则要调整shmall.(kernel.shmall*kernel.shmmni)
Oracle建议设置进程的限制数和每个Linux账户的open files 数。用root用户运行下面的命令。
编辑/etc/security/limits.conf
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
编辑/etc/pam.d/login
session required /lib/security/pam_limits.so
编辑/etc/profile
if [ $USER = "oracle" ]; then
if
[ $SHELL = "/bin/ksh" ]; then
ulimit
-p 16384
ulimit
-n 65536
else
ulimit
-u 16384 -n 65536
fi
umask
022
fi
编辑/etc/csh.login
if (
$USER == "oracle" ) then
limit
maxproc 16384
limit
descriptors 65536
umask
022
endif
EOF
配置 /etc/hosts
127.0.0.1 localhost.localdomain localhost
192.168.1.10 oms10g
注意127.0.0.1的回环地址设置,有可能安装时网络部分报错或LSNRCTL起不来。
配置/home/oracle/.bash_profile
export ORACLE_BASE=/opt/oracle
export ORACLE_HOME=$ORACLE_BASE/product/10.2/
export ORACLE_SID=test
export ORACLE_OWNER=oracle
export NLS_LANG="AMERICAN_AMERICA.ZHT16MSWIN950"
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/usr/X11R6/lib:$LD_LIBRARY_PATH
export PATH=.:/usr/sbin:$ORACLE_HOME/bin:$ORACLE_HOME/jdk/bin:$PATH
export CLASSPATH=$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib:$CLASSPATH
export LC=en_US
ASM部分
ASM是作为一个独立的实例来运行的,必须使得其它数据库能够访问它。
安装 ASM 在Linux平台,ASM能够使用裸设备或者通过ASMLib接口管理设备。
Oracle建议使用后者,更加易于使用和更优的性能。
选择你需要的ASMLib的版本 ASMLib 2.0包含3个Linux包:
oracleasmlib-2.0 - ASM 类库
oracleasm-support-2.0 – 用于管理
ASMLib oracleasm - ASM 类库的核心模块
每个Linux版本都有它自己的ASMLib2.0包,每个版本都有相应的内核版本。
首先,用root登录运行下面的命令:
#uname -rm
2.6.9-34.EL i686
这个例子显示内核是2.6.9-34 kernel,为多处理系统,使用Intel i686 CPU。使用这些信息在OTN上寻找正确的ASMLib包:
访问
选择你的Linux版本的连接 下载oracleasmlib和oracleasm-support包。
下载你的内核对应的oracleasm包。在这个例子里,使用oracleasm-2.6.9-22.ELsmp-2.0.0-1.i686.rpm。
接着,用root安装包,运行下面的命令:
# rpm -Uvh \ > oracleasm-2.6.9-34.0.1.EL-2.0.3-1.i686.rpm \
> oracleasmlib-2.0.4-1.el4.i386.rpm \
> oracleasm-support-2.1.7-1.el4.i386.rpm
Preparing... ########################################### [100%]
1:oracleasm-support ########################################### [ 33%]
2:oracleasm-2.6.9-34.EL ########################################### [ 67%]
3:oracleasmlib ########################################### [100%]
配置 ASMLib 在使用ASMLib之前,你必须运行一个配置脚本来准备驱动程序。
用root运行下面的命令,将出现以下提示。
# /etc/init.d/oracleasm configure
Configuring the Oracle ASM library driver. This will configure the on-boot properties of the Oracle ASM library driver.
The following questions will determine whether the driver is loaded on boot and what permissions it will have.
The current values
will be shown in brackets ('[]'). Hitting
Default user to own the driver interface []:
oracle Default group to own the driver interface []: dba
Start Oracle ASM library driver on boot (y/n) [n]: y
Fix permissions of Oracle ASM disks on boot (y/n) [y]: y
Writing Oracle ASM library driver configuration: [ OK ]
Creating /dev/oracleasm mount point: [ OK ]
Loading module "oracleasm": [ OK ]
Mounting ASMlib driver filesystem: [ OK ]
Scanning system for ASM disks: [ OK ]
接下来告诉ASM驱动使用哪个磁盘。Oracle建议每个磁盘包含一个单独完整的磁盘分区。
[root@oms10g oracle]# /sbin/fdisk -l /dev/hdb
Disk /dev/hdb: 10.7 GB, 10737418240 bytes 15 heads, 63 sectors/track, 22192
cylinders Units = cylinders of 945 * 512 = 483840 bytes Device Boot Start End Blocks Id System
/dev/hdb1 1 6201 2929941 83 Linux
/dev/hdb2 6202 12402 2929972+ 83 Linux
/dev/hdb3 12403 16537 1953787+ 83 Linux
/dev/hdb4 16538 22192 2671987+ 5 Extended
/dev/hdb5 16538 22192 2671956 83 Linux
#----說明 用asmlib和raw分別來創建asm磁盤組-----------
hdb1 3G vol1 asm
hdb2 3G vol2 asm
hdb3 raw1
hdb5 raw2
------------------------------------------------------------------------#
編輯/etc/sysconfig/rawdevices
/dev/raw/raw1 /dev/hdb3
/dev/raw/raw2 /dev/hdb5
#/etc/rc.d/init.d/rawdevice restart
編輯/etc/rc.local
chown oracle:oinstall /dev/raw/raw1
chown oracle:oinstall /dev/raw/raw2
chmod 600 /dev/raw/raw1
chmod 600 /dev/raw/raw2
以root运行下面的命令标记用于ASMLib的磁盘:
#/etc/init.d/oracleasm createdisk VOL1 /dev/hdb1
Marking disk "/dev/hdb1" as an ASM disk: [ OK ]
#/etc/init.d/oracleasm createdisk VOL1 /dev/hdb2
Marking disk "/dev/hdb2" as an ASM disk: [ OK ]
检验 ASMLib 标记到磁盘:
#/etc/init.d/oracleasm listdisks VOL1 VOL2
#/etc/init.d/oracleasm scandisks
安装oracle
#unzip 10201_database_linux32.zip
然后安装Oracle Software 創建DataBase DBCA創建時,先創建ASM實例並且創建ASM磁盤組,然後再創建DataBase.
手工創建asm磁盤組:
參考:http://www.oracle-base.com/articles/10g/asm-using-asmlib-and-raw-devices.php
创建ASM 实例
#su – oracle
#cd $ORACLE_HOME/dbs
#vi init+ASM.ora 创建asm 实例的初始化脚本,脚本内容如下所示:
*.asm_diskstring='ORCL:VOL*','/dev/raw/raw*'
*.background_dump_dest='/opt/oracle/admin/+ASM/bdump'
*.core_dump_dest='/opt/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/opt/oracle/admin/+ASM/udump'
#mkdir -p /opt/oracle/admin/+ASM/udump
#mkdir -p /opt/oracle/admin/+ASM/bdump
#mkdir -p /opt/oracle/admin/+ASM/cdump
检查/etc/inittab 文件,看看是否有下面这行 h1:35:respawn:/etc/init.d/init.cssd run >/dev/null
2>&1
沒有可能報:ORA-29701: unable to connect to Cluster Manager
如果連生成/etc/init.d/init.cssd 也不存在,執行:$ORACLE_HOME/bin/localconfig add 生成/etc/init.d/init.cssd
不管是RAC or not RAC,如果使用ASM,那么OCSSD 是必须的,因为ASM中使用的Group Services (GS)是OCSSD提供的.
执行$ORACLE_HOME/bin/localconfig add 就是安装ocssd
如果改了hostname,也會報ORA-29701,$ORACLE_HOME/bin/localconfig delete然後$ORACLE_HOME/bin/localconfig add.
SQL>
conn /as sysdba
Connected to an idle instance.
SQL> startup
ASM instance
started
Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ORA-15110: no diskgroups
mounted
SQL>SELECT name, header_status, path FROM V$ASM_DISK;
NAME HEADER_STATUS PATH
---------- ------------------------ ------------------------------------
PROVISIONED ORCL:VOL1
CANDIDATE /dev/raw/raw2
CANDIDATE /dev/raw/raw1
PROVISIONED ORCL:VOL2
SQL> create diskgroup dgtest normal redundancy
failgroup DATA1 disk 'ORCL:VOL1' name DATA1
failgroup DATA2 disk 'ORCL:VOL2' name
DATA2;
SQL>create diskgroup dgtest2 normal redundancy
failgroup raw1 disk
'/dev/raw/raw1' name raw1
failgroup raw2 disk '/dev/raw/raw2' name raw2;
SQL> select name,state from v$asm_diskgroup;
NAME STATE
---------- ----------------------
DGTEST DISMOUNTED
DGTEST2 DISMOUNTED
SQL> SHOW PARAMETER ASM
NAME TYPE VALUE
------------------------------------ ---------------------- --------------------
asm_diskgroups string DGTEST, DGTEST2
asm_diskstring string ORCL:VOL*, /dev/raw/
asm_power_limit integer 1
#vi init+ASM.ora 修改 asm 实例的初始化脚本,脚本内容如下所示:
*.asm_diskgroups='DGTEST','DGTEST2' #加入後startup時自動mount
*.asm_diskstring='ORCL:VOL*','/dev/raw/raw*'
*.background_dump_dest='/opt/oracle/admin/+ASM/bdump'
*.core_dump_dest='/opt/oracle/admin/+ASM/cdump'
*.instance_type='asm'
*.large_pool_size=12M
*.remote_login_passwordfile='SHARED'
*.user_dump_dest='/opt/oracle/admin/+ASM/udump'
創建DB採用DBCA
省略。。。。
當提示“自動存儲管理(ASM)"
選取DGTEST即可。
。。。。
移除Oracle 10G
#/etc/init.d/oracleasm deletedisk VOL1
#/etc/init.d/oracleasm deletedisk VOL2
#rm -rf /dev/oracleasm
#dd if=/dev/zero of=/dev/raw/raw1
#dd if=/dev/zero of=/dev/raw/raw2
#rm -rf /opt/oracle
#rm /etc/oratab
#ls -lah /etc/ora*
#rm /etc/ora*
#ls -lah /tmp/ora*
#rm /tmp/oracle*
#ls -lah /var/tmp/ora*
#rm /var/tmp/ora*
#userdel oracle
#groupdel dba
#groupdel oinstall
#rm -rf /home/oracle
然后再午置上面安装时时修改的文件。
附本 asm_search_disk.sh(查找asm disk和磁盤的對應關系,具體情況具體分析,有地方可能需要調整):
#!/bin/sh
for i in `/etc/init.d/oracleasm listdisks`
do
v_asmdisk=`/etc/init.d/oracleasm querydisk -d $i | awk '{print $2}'`
v_minor=`/etc/init.d/oracleasm querydisk -d $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk -F"," '{print $1}'`
v_major=`/etc/init.d/oracleasm querydisk -d $i | awk -F[ '{print $2}'| awk -F] '{print $1}' | awk -F"," '{print $2}'`
v_device=`ls -la /dev/* |grep hd | grep "${v_minor}" | grep "${v_major}" | awk '{print $10}' `
echo "ASM disk $v_asmdisk based on /dev/$v_device [$v_minor $v_major]"
done
[oracle@oms10g oracle]$ ./asm_disk.sh
ASM disk "VOL1" based on /dev//dev/hdb1 [3 65]
ASM disk "VOL2" based on /dev//dev/hdb2 [3 66]