3.Oracle集群安装—配置文件

服务器

  根据用户的实际需求,对Linux系统中的文件进行配置。配置如下:一.配置hostsvim /etc/hosts192.168.1.81 desitestdb81192.168.1.82 desitestdb82192.168.1.83 desitestdb8310.10.100.81 desitestdb81prv10.10.100.82 desitestdb82prv10.10.100.83 desitestdb83prv192.168.1.84 desitestdb81vip192.168.1.85 desitestdb82vip192.168.1.86 desitestdb83vip192.168.1.80 desitestdbscancat /etc/hosts二 .配置环境变量echo "export LANG=en_US" >> ~/.bash_profilecat ~/.bash_profile三。创建用户,组,目录/usr/sbin/groupadd -g 50001 oinstall/usr/sbin/groupadd -g 50002 dba/usr/sbin/groupadd -g 50003 oper/usr/sbin/groupadd -g 50004 asmadmin/usr/sbin/groupadd -g 50005 asmoper/usr/sbin/groupadd -g 50006 asmdba/usr/sbin/useradd -u 60001 -g oinstall -G dba,asmdba,oper oracle/usr/sbin/useradd -u 60002 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba gridpasswd grid ----密码全都设置为oraclepasswd oracle ----密码全都设置为oraclemkdir -p /oracle/app/gridmkdir -p /oracle/app/11.2.0/gridchown -R grid:oinstall /oraclemkdir -p /oracle/app/oraInventorychown -R grid:oinstall /oracle/app/oraInventorymkdir -p /oracle/app/oraclechown -R oracle:oinstall /oracle/app/oraclechmod -R 755 /oracle四。配置yum软件安装环境及软件包安装mount /dev/cdrom /mnt --挂载光驱 可以通过 df -hl 查看 是否 存在路径 /mntcd /etc/yum.repos.dmkdir bkmv *.repo bk/echo "[EL]" >> /etc/yum.repos.d/itpux.repoecho "name=Linux 6.x DVD" >> /etc/yum.repos.d/itpux.repoecho "baseurl=file:///mnt" >> /etc/yum.repos.d/itpux.repoecho "gpgcheck=0" >> /etc/yum.repos.d/itpux.repoecho "enabled=1" >> /etc/yum.repos.d/itpux.repocat /etc/yum.repos.d/itpux.repo需要安装的软件系列: ----必须先挂载 mount /dev/cdrom /mnt yum install binutils* -yyum install compat* -yyum install elfutils* -yyum install gcc* -yyum install glibc* -yyum install kernel* -yyum install ksh* -yyum install libaio* -yyum install libgcc* -yyum install libgomp* -yyum install libstdc* -yyum install make* -yyum install sysstat* -yyum install unixODBC* -yyum install libcap* -yyum install -y compat-libcap1*yum install -y compat-libstdc*yum install binutils* -yyum install compat* -yyum install elfutils* -yyum install gcc* -yyum install glibc* -yyum install kernel* -yyum install ksh* -yyum install libaio* -yyum install libgcc* -yyum install libgomp* -yyum install libstdc* -yyum install make* -yyum install sysstat* -yyum install unixODBC* -yyum install libcap* -yyum install -y compat-libcap1*yum install -y compat-libstdc*五。修改资源限制参数vim /etc/security/limits.conf#ORACLE SETTINGgrid soft nproc 16384 -----nproc 代表最大用户进程数grid hard nproc 16384grid soft nofile 65536grid hard nofile 65536grid soft stack 32768grid hard stack 32768oracle soft nproc 16384oracle hard nproc 16384oracle soft nofile 65536oracle hard nofile 65536oracle soft stack 32768oracle hard stack 32768oracle soft memlock 2000000 --memlock 为定义oracle下的最大内存数,oracle<物理内存,单位是kboracle hard memlock 2000000 ----- 4g: memlock < 物理内存,单位是KB 。即为所对应的用户的最大内存数ulimited -a --检查上面的设置是否生效2.修改nproc参数echo "* - nproc 16384" >/etc/security/limits.d/90-nproc.conf3.控制给用户分配的资源echo "session required pam_limits.so" >>/etc/pam.d/logincat /etc/pam.d/login4.修改内核参数vim /etc/sysctl.conf#ORACLE SETTINGfs.aio-max-nr = 1048576 fs.file-max = 6815744 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 = 1048576 kernel.panic_on_oops=1 kernel.shmmax=1610612736 --共享内存,定义单个共享内存段的最大值,一定要>SGA计算方法 sga+pga<=用户内存的80%kernel.shmall= 393216 --最大页数 即为 1610612736 / 4086kernel.shmmni =4096 --每页 2Mvm.nr_hugepages=868 --大内存页sysctl -p --使内核参数生效cat /proc/meminfo --查看内存是否生效-------kernel.shmmax=1610612736 定义单个共享内存段的最大值,一定要存放下整个SGA,SGA+PGA<物理内存的80%,SGA 是占用物理内存的80%*80%,PGA占用物理内存的80%*20%------kernel.shmall= 393216 控制共享内存的页数 getconf PAGESIZE = 4096k , kernel.shmall = kernel.shmmax/ PAGESIZE-------vm.nr_hugepages=868 大内存页,> 8G 物理内存, sga_max_size/2M +(100—500)5.关闭透明页cat /sys/kernel/mm/transparent_hugepage/defrag[always] madvise nervercat /sys/kernel/mm/transparent_hugepage/enabled[always] madvise nervervi /etc/rc.d/rc.localif test -f /sys/kernel/mm/transparent_hugepage/enabled;thenecho never > /sys/kernel/mm/transparent_hugepage/enabledfiif test -f /sys/kernel/mm/transparent_hugepage/defrag;thenecho never > /sys/kernel/mm/transparent_hugepage/defragfichmod +x /etc/rc.d/rc.local6.关闭numa功能vim /boot/grub/grub.confkernel /boot/vmlinuz-2.6.39-400.294.3.el6uek.i686 ro root=UUID=444df8b1-4cdb-4064-bf2d-89521520d958 rd_NO_LUKS rd_NO_LVM LANG=en_US.UTF-8 rd_NO_MD SYSFONT=latarcyrheb-sun16 KEYBOARDTYPE=pc KEYTABLE=us rd_NO_DM rhgb quiet numa=offnumactl --hardware --查看CUP节点--查看CPU节点所用的内存是否没有超过规定的内存大小。7.图形改启动级别从5至3 改级别从5至3vim /etc/inittab8.共享内存段echo “tmpfs /dev/shm tmpfs defaults,size=3072M 0 0” >> /etc/fstab ---共享内存大小被设置成4Gmount -o remount /dev/shm六.配置安全1.禁用SELINUXecho "SELINUX=disabled" > /etc/selinux/configecho "#SELINUXTYPE=targeted" >>/etc/selinux/configsetenforce 02.关防火墙service iptables stop chkconfig --level 35 iptables off4.禁用NTP服务service ntpd stopchkconfig ntpd offmv /etc/ntp.conf /etc/ntp.conf.origrm /var/run/ntpd.pid5.修改时间,使三台机器时间都一样date -s thu Dec 13 19:47:15 CST 20226.在grid用户下配置环境变量vim .bash_profilePS1="[whoami@hostname:" $PWD]

  export PS1umask 022#alias sqlplus="rlwrap sqlplus"export TMP=/tmpexport LANG=en_USexport TMPDIR=$TMPORACLE_SID=+ASM1; export ORACLE_SID --根据不同的机器,记得修改ASM1,ASM2,ASM3ORACLE_TERM=xterm;export ORACLE_TERMORACLE_BASE=/oracle/app/grid; export ORACLE_BASEORACLE_HOME=/oracle/app/11.2.0/grid;export ORACLE_HOMENLS_DATE_FORMAT=yyyy-mm-dd HH24:MI:SS; export NLS_DATE_FORMATPATH=.:$PATH:$HOME/bin:$ORACLE_HOME/bin; export PATHTHREADS_FLAG=native; export THREADS_FLAGenv

  grep ORACLE 7.在oracle用户下配置环境变量vim .bash_profilePS1="[whoami@hostname:"$PWD]

  #alias sqlplus ="rlwrap sqlplus"#alias rman="rlwrap rman"export PS1export TMP=/tmpexport LANG=en_USexport TMPDIR=$TMPexport ORACLE_UNQNAME=fgyxdbORACLE_BASE=/oracle/app/oracle;export ORACLE_BASEORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1;export ORACLE_HOMEORACLE_SID=fgyxdb1; export ORACLE_SID --根据主机名修改fgyxdb1,fgyxdb2,fgyxdb3ORACLE_TERM=xterm; export ORACLE_TERMNLS_DATE_FORMAT="yyyy-mm-dd HH24:MI:SS";export NLS_DATE_FORMATNLS_LANG=AMERICAN_AMERICA.ZHS16GBK;export NLS_LANGPATH=.:$PATH:$HOME/bin:$ORACLE_BASE/product/11.2.0/db_1/bin:$ORACLE_HOME/bin;export PATHTHREADS_FLAG=native;export THREADS_FLAGif [$USER=oracle]

   [$USER=grid] ;then if [$SHELL="/bin/ksh"]; then ulimit -p 16384 ulimit -n 65536 else ulimit -u 16384 -n 65536 fiumask 022fi七。配置 SSH信任关系先在主机A上使用命令创建密钥ssh-keygen -t rsa --命令提示时,提示输入passphrase时直接输入回车,表示无证书密码ls /root/.ssh --可以看见文件 id_rsa.pub我们把id_rsa.pub 文件复制到主机B上面去scp -r /root/.ssh/id_rsa.pub 192.168.1.82:/root/.ssh/authorized_keys此时可以看见主机A连接到连接主机B不需要输入密码ssh 192.168.1.82 date ;类似是,在主机B上使用命令创建密钥,然后放到主机A的/root/.ssh/authorized_keys 的文件夹下。若是多台主机,则直接把各个文件上的id_rsa.pub 的内容,放入文件 authorized_keys 下。八.Oracle11gR2 RAC共享存储规划与配置dggrid1: 1g*3dggrid2: 1g*3dgsystem:2g*1dgrecovery:2g=2g*1dgdata01:1g=1g*1 备份空间/backup 4T=1T*4配置的步骤:1.关闭三台服务器shutdown -h 建议先备份一下系统,避免失败之后从新开始。在虚拟机下添加四个SCSI磁盘

  每个机器上的盘的挂载顺序要一至,否则后期会出现问题。在虚拟机上的后缀为vmx的机器上,添加下列字段,以免共享磁盘时打开出现问题。disk.locking="FALSE" scsi1:1.SharedBus="Virtual"scsi1:2.SharedBus="Virtual"scsi1:3.SharedBus="Virtual"scsi1:4.SharedBus="Virtual"scsi1:5.SharedBus="Virtual"scsi1:6.SharedBus="Virtual"scsi1:8.SharedBus="Virtual"scsi1:9.SharedBus="Virtual"scsi1:10.SharedBus="Virtual"其中一台机器挂backup,令两台不能加。在虚拟机上的 Oracle_Linux_81.vmx 文件上添加 disk.locking="FALSE"2.查看磁盘fdisk -l

  more提取各个盘,并查看各个系统上的盘是否一致fdisk -l

  grep "1073 MB" 盘的顺序必须一致。加载ASM文件 (这两个文件可以到官网中下载,需要找到Linux系统对应的版本)rpm -ivh oracleasmlib-2.0.4-1.el5.x86_64.rpmrpm -ivh oracleasm-support-2.1.8-1.el5.x86_64.rpm安装完之后,把另两台机器暂时关闭,在一台上配置磁盘: /etc/init.d/oracleasm configure 默认用户为 grid 默认组为 asmadmin创建分区(安装上面设计好的分区,建立分区)---创建分区用语句 /etc/init.d/oracleasm createdisk crs1 /dev/sdf ---查看创建分区的日志 cat /var/log/oracleasm [root@desitestdb81 ~]# fdisk -l

  grep "1073 MB"Disk /dev/sdd: 1073 MB, 1073741824 bytesDisk /dev/sde: 1073 MB, 1073741824 bytesDisk /dev/sdf: 1073 MB, 1073741824 bytesDisk /dev/sdg: 1073 MB, 1073741824 bytesDisk /dev/sdh: 1073 MB, 1073741824 bytesDisk /dev/sdc: 1073 MB, 1073741824 bytes[root@desitestdb81 ~]# fdisk -l

  grep "2147 MB"Disk /dev/sdj: 2147 MB, 2147483648 bytesDisk /dev/sdi: 2147 MB, 2147483648 bytesDisk /dev/sdk: 2147 MB, 2147483648 bytes[root@desitestdb81 ~]# fdisk -l

  grep "1099.5 MB"[root@fxyxdb81 ~]# fdisk -l

  grep "1099.5 GB"Disk /dev/sdm: 1099.5 GB, 1099511627776 bytesDisk /dev/sdn: 1099.5 GB, 1099511627776 bytesDisk /dev/sdo: 1099.5 GB, 1099511627776 bytesDisk /dev/sdl: 1099.5 GB, 1099511627776 bytes从sdc开始分区分到fdisk /dev/sdc

  搞定分区sdc

  其他的磁盘也可以类推进行分区

  /etc/init.d/oracleasm createdisk grid01 /dev/sdc1 --进行分区

  ls -lsa /dev/sd*1

  kpartx -a /dev/sdc

  partprobe /dev/sdc

  vim /etc/sysconfig/oracleasm

  对磁盘进行扫描:/etc/init.d/oracleasm listdisks扫描之后,另两台机器可以开机。查看另两台机器的磁盘分区同时对其进行配置以及扫描fdisk -f/etc/init.d/oracleasm configure /etc/init.d/oracleasm listdiskvi /etc/sysconfig/oracleasm --每次不要扫根盘重新启动创建PVpvcreate /dev/sdl /dev/sdm /dev/sdn /dev/sdovgcreate backvg /dev/sdl /dev/sdm /dev/sdn /dev/sdopvsvgslvcreate -n backuplv -L 4.00t backvg

  vgsmkfs.ext4 /dev/backvg/backuplvmkdir /backupvim /etc/fstabchown -R oracle:oinstall /backupchmod -R 775 /backup

标签: 服务器