再做 Oracle 11gR2 RAC部署3

第2部分DNS正反向解析已配置好,接着我们要为oracle 集群软件,oracle数据库 创建用户,用户组,目录,环境变量,修改内核,资源限制等等。然后创建共享磁盘并格式化,使linux识别。

建用户,改口令,修改用户配置文件

为node1和node2创建grid和oracle用户环境变量 ,SID , 如下:

node1:

groupadd -g 1000 oinstall

groupadd -g 1200 asmadmin

groupadd -g 1201 asmdba

groupadd -g 1202 asmoper

useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c “grid Infrastructure Owner” grid

grid | passwd –stdin grid

echo “export TMP=/tmp” >> /home/grid/.bash_profile

echo ‘export TMPDIR=$TMP’ >> /home/grid/.bash_profile

echo “export ORACLE_SID=+ASM1” >> /home/grid/.bash_profile

echo “export ORACLE_BASE=/u01/app/grid” >> /home/grid/.bash_profile

echo “export ORACLE_HOME=/u01/app/11.2.0/grid” >> /home/grid/.bash_profile

echo “export ORACLE_TERM=xterm” >> /home/grid/.bash_profile

echo “export NLS_DATE_FORMAT=’yyyy/mm/dd hh24:mi:ss'” >> /home/grid/.bash_profile

echo ‘export TNS_ADMIN=$ORACLE_HOME/network/admin’ >> /home/grid/.bash_profile

echo ‘export PATH=/usr/sbin:$PATH’ >> /home/grid/.bash_profile

echo ‘export PATH=$ORACLE_HOME/bin:$PATH’ >> /home/grid/.bash_profile

echo ‘export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib’ >> /home/grid/.bash_profile

echo ‘export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib’ >> /home/grid/.bash_profile

echo “export EDITOR=vi” >> /home/grid/.bash_profile

echo “export LANG=en_US” >> /home/grid/.bash_profile

echo “export NLS_LANG=american_america.AL32UTF8” >> /home/grid/.bash_profile

echo “umask 022” >> /home/grid/.bash_profile

echo ‘export PS1=”`/bin/hostname -s` -> “‘ >> /home/oracle/.bash_profile

echo “export TMP=/tmp” >> /home/oracle/.bash_profile

echo ‘export TMPDIR=$TMP’ >> /home/oracle/.bash_profile

echo “export ORACLE_HOSTNAME=node1.localdomain” >> /home/oracle/.bash_profile

echo “export ORACLE_SID=devdb1” >> /home/oracle/.bash_profile

echo “export ORACLE_BASE=/u01/app/oracle” >> /home/oracle/.bash_profile

echo ‘export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1’ >> /home/oracle/.bash_profile

echo “export ORACLE_UNQNAME=devdb” >> /home/oracle/.bash_profile

echo ‘export TNS_ADMIN=$ORACLE_HOME/network/admin’ >> /home/oracle/.bash_profile

echo “export ORACLE_TERM=xterm” >> /home/oracle/.bash_profile

echo ‘export PATH=/usr/sbin:$PATH’ >> /home/oracle/.bash_profile

echo ‘export PATH=$ORACLE_HOME/bin:$PATH’ >> /home/oracle/.bash_profile

echo ‘export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib’ >> /home/oracle/.bash_profile

echo ‘export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib’ >> /home/oracle/.bash_profile

echo “export LANG=en_US” >> /home/oracle/.bash_profile

echo “export NLS_LANG=american_america.AL32UTF8” >> /home/oracle/.bash_profile

echo “export NLS_DATE_FORMAT=’yyyy/mm/dd hh24:mi:ss'” >> /home/oracle/.bash_profile

echo “umask 022” >> /home/oracle/.bash_profile

 

node2:

groupadd -g 1000 oinstall

groupadd -g 1200 asmadmin

groupadd -g 1201 asmdba

groupadd -g 1202 asmoper

useradd -u 1100 -g oinstall -G asmadmin,asmdba,asmoper -d /home/grid -s /bin/bash -c “grid Infrastructure Owner” grid

echo “grid” | passwd –stdin grid

echo ‘export PS1=”`/bin/hostname -s` -> “‘ >> /home/grid/.bash_profile

echo “export TMP=/tmp” >> /home/grid/.bash_profile

echo ‘export TMPDIR=$TMP’ >> /home/grid/.bash_profile

echo “export ORACLE_SID=+ASM2” >> /home/grid/.bash_profile

echo “export ORACLE_BASE=/u01/app/grid” >> /home/grid/.bash_profile

echo “export ORACLE_HOME=/u01/app/11.2.0/grid” >> /home/grid/.bash_profile

echo “export ORACLE_TERM=xterm” >> /home/grid/.bash_profile

echo “export NLS_DATE_FORMAT=’yyyy/mm/dd hh24:mi:ss'” >> /home/grid/.bash_profile

echo ‘export TNS_ADMIN=$ORACLE_HOME/network/admin’ >> /home/grid/.bash_profile

echo ‘export PATH=/usr/sbin:$PATH’ >> /home/grid/.bash_profile

echo ‘export PATH=$ORACLE_HOME/bin:$PATH’ >> /home/grid/.bash_profile

echo ‘export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib’ >> /home/grid/.bash_profile

echo ‘export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib’ >> /home/grid/.bash_profile

echo “export EDITOR=vi” >> /home/grid/.bash_profile

echo “export LANG=en_US” >> /home/grid/.bash_profile

echo “export NLS_LANG=american_america.AL32UTF8” >> /home/grid/.bash_profile

echo “umask 022” >> /home/grid/.bash_profile

groupadd -g 1300 dba

groupadd -g 1301 oper

useradd -u 1101 -g oinstall -G dba,oper,asmdba -d /home/oracle/ -s /bin/bash -c “Oracle Software Owner” oracle

echo “oracle” | passwd –stdin oracle

echo ‘export PS1=”`/bin/hostname -s` -> “‘ >> /home/oracle/.bash_profile

echo ‘export TMPDIR=$TMP’ >> /home/oracle/.bash_profile

echo “export ORACLE_HOSTNAME=node2.localdomain” >> /home/oracle/.bash_profile

echo “export ORACLE_SID=devdb2” >> /home/oracle/.bash_profile

echo “export ORACLE_BASE=/u01/app/oracle” >> /home/oracle/.bash_profile

echo ‘export ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1’ >> /home/oracle/.bash_profile

echo “export ORACLE_UNQNAME=devdb” >> /home/oracle/.bash_profile

echo ‘export TNS_ADMIN=$ORACLE_HOME/network/admin’ >> /home/oracle/.bash_profile

echo “export ORACLE_TERM=xterm” >> /home/oracle/.bash_profile

echo ‘export PATH=/usr/sbin:$PATH’ >> /home/oracle/.bash_profile

echo ‘export PATH=$ORACLE_HOME/bin:$PATH’ >> /home/oracle/.bash_profile

echo ‘export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib:/usr/lib’ >> /home/oracle/.bash_profile

echo ‘export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib’ >> /home/oracle/.bash_profile

echo “export NLS_LANG=american_america.AL32UTF8” >> /home/oracle/.bash_profile

echo “export NLS_DATE_FORMAT=’yyyy/mm/dd hh24:mi:ss'” >> /home/oracle/.bash_profile

echo “umask 022” >> /home/oracle/.bash_profile

现在node1和node2的用户和用户组已创建完成.

node1和node2为grid和oracle用户创建相关路径,并赋予权限。

mkdir -p /u01/app/grid

mkdir -p /u01/app/11.2.0/grid

mkdir -p /u01/app/oracle

chown -R oracle:oinstall /u01

chown -R grid:oinstall /u01/app/grid

chown -R grid:oinstall /u01/app/11.2.0

chmod -R 775 /u01

编辑/etc/security/limits.conf,配置oracle , grid用户的shell限制

echo “oracle soft nproc 2047” >> /etc/security/limits.conf

echo “oracle hard nproc 16384” >> /etc/security/limits.conf

echo “oracle soft nofile 1024” >> /etc/security/limits.conf

echo “oracle hard nofile 65536” >> /etc/security/limits.conf

echo “grid soft nproc 2047” >> /etc/security/limits.conf

echo “grid hard nproc 16384” >> /etc/security/limits.conf

echo “grid soft nofile 1024” >> /etc/security/limits.conf

echo “grid hard nofile 65536” >> /etc/security/limits.conf

echo “Modifing the /etc/security/limits.conf has been succeed.”

node1和node2 编辑/etc/pam.d/login

echo “session required /lib/security/pam_limits.so” >> /etc/pam.d/login

echo “session required pam_limits.so” >> /etc/pam.d/login

node1和node2编辑/etc/profile

echo ‘if [ $USER = “oracle” ] || [ $USER = “grid” ] ; then’ >> /etc/profile

echo ‘if [ $SHELL = “/bin/ksh” ] ; then’ >> /etc/profile

echo ‘ulimit -p 16384’ >> /etc/profile

echo ‘else’ >> /etc/profile

echo ‘ulimit -u 16384 -n 65536’ >> /etc/profile

echo ‘fi’ >> /etc/profile

echo ‘fi’ >> /etc/profile

node1和node2修改内核参数

echo “fs.aio-max-nr = 1048576” >> /etc/sysctl.conf

echo “fs.file-max = 6815744” >> /etc/sysctl.conf

echo “kernel.shmall = 2097152” >> /etc/sysctl.conf

echo “kernel.shmmax = 1054472192” >> /etc/sysctl.conf

echo “kernel.shmmni = 4096” >> /etc/sysctl.conf

echo “net.ipv4.ip_local_port_range = 9000 65500” >> /etc/sysctl.conf

echo “net.core.rmem_max = 4194304” >> /etc/sysctl.conf

echo “net.core.wmem_default = 262144” >> /etc/sysctl.conf

echo “net.core.wmem_max = 1048586” >> /etc/sysctl.conf

echo “net.ipv4.tcp_wmem = 262144 262144 262144” >> /etc/sysctl.conf

echo “net.ipv4.tcp_rmem = 4194304 4194304 4194304” >> /etc/sysctl.conf

sysctl -p

创建node1和node2的共享磁盘

共享磁盘分为OCR , VOTE , DATA , FLASH ;其中OCR和VOTE大小均为500MB,DATA和FLASH大小均为3GB

OCR: 保存node1和node2的共有配置信息, 防止“健忘”发生.

VOTE: 选举盘(也叫仲裁盘),防止“脑裂”发生.

DATA: 放置共享数据,表空间等。

FLASH: 存放闪回区数据。

共享磁盘只在node1上创建即可,node2上添加现有磁盘就OK了。

node1上添加完成后, 请为OC R , VOTE , DATA , FLAH分配总线1.0 1.1 2.o 2.1

node2同样为OC R , VOTE , DATA , FLAH分配总线1.0 1.1 2.o 2.1 ,不能搞错.

如何创建一块磁盘,以OCR为例

VOTE , DATA , FLASH和OCR创建方式一样,就不再演示了 ,以下是创建好的.

node2添加node1的磁盘,注意这里添加指的是使用现有磁盘, 否则就不是共享磁盘咯,

其他步骤基本一样.

最后,node1和node2除系统盘外,使用的都是相同磁盘.

我们还需要设置vmx文件,使node1和node2真正做到磁盘共享

打开OEL 5 64 11gnode1.vmx添加如下内容:

isk.locking = “FALSE”

scsi:1.0.sharing = “multi-writer”

scsi:2.0.sharing = “multi-writer”

这样关闭锁定,开启多路径写入,就可以实现磁盘共享

node2的配置文件添加的内容和 node1相同.

设置完成后,开启node1和node2,然后执行fdisk -l 如下:

要使用这四块硬盘还必须格式化,以/dev/sdb为例

fdisk /dev/sdb

键入n ,建立新分区

键入p,建立主分区

键入1 ,从第一块开始

直接回车,使用全部磁盘

键入w,保存更改.

用同样的方法,格式话其余3个磁盘. 最终效果如下.

node2不用再格式化了,直接查看后 结果和node1一样.

Leave a Reply