分类: Oracle
2013-01-25 16:54:55
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包:
每个Linux版本都有它自己的ASMLib2.0包,每个版本都有相应的内核版本。下面的段落,讲述怎么检查自己需要的内核版本。
首先,用root登录运行下面的命令:
uname -rm
Ex:
# uname -rm
2.6.9-34.EL i686
这个例子显示内核是2.6.9-34 kernel,为多处理系统,使用Intel i686 CPU。
使用这些信息在OTN上寻找正确的ASMLib包:
接着,用root安装包,运行下面的命令:
# rpm -Uvh \
> \
> \
>
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
answer will keep that current value. Ctrl-C will abort.
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
----#
在每个节点用root运行下面的命令标记用于ASMLib的磁盘:
/etc/init.d/oracleasm createdisk DISK_NAME device_name
Tip: Enter the DISK_NAME in UPPERCASE letters.
Ex:
# /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
On all other cluster nodes, run the following
command as root to scan for configured ASMLib disks:
/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 实例的初始化脚本,脚本内容如下所示:
# ****** init script for asm instance******
*.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'
# ******Above is init script for asm instance******
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
執行:$ORACLE_HOME/bin/localconfig add 生成/etc/init.d/init.cssd
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 MOUNTED
DGTEST2 MOUNTED
SQL> show parameter asm
NAME TYPE VALUE
------------------------------------ ---------------------- --------------------
asm_diskgroups string DGTEST, DGTEST2
asm_diskstring string ORCL:VOL*, /dev/raw/
asm_power_limit integer 1
移除Oracle 10G
#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
然后再午置上面安装时时修改的文件。