Linux 6.5(oracle 11.2.0.4) 1、解析主機、配置網路等 /etc/hosts /etc/sysconfig/network /etc/init.d/NetworkManager stop chkconfig NetworkManager off iptables F serv ...
Linux 6.5(oracle 11.2.0.4)
1、解析主機、配置網路等
/etc/hosts
/etc/sysconfig/network
/etc/init.d/NetworkManager stop
chkconfig NetworkManager off
iptables -F
service iptables save
sed -ri 's/^SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux
2、配置yum
cd /etc/yum.repos.d/
touch yum_oel5.repo
vi yum_oel5.repo
添加以下內容:
[oel6]
name=oel6
baseurl=file:///mnt/Server
gpgcheck=0
enabled=1
yum clean all
yum repolist
yum list
yum install binutils compat-libstdc++-33 elfutils-libelf elfutils-libelf-devel glibc glibc-common glibc-devel gcc- gcc-c++ libaio-devel libaio libgcc libstdc++ libstdc++-devel make sysstat unixODBC unixODBC-devel pdksh ksh compat-libcap1
Pdksh 一定要先裝,不然後面會報錯的
3、修改系統參數
調整內核參數,並使其生效
vi /etc/sysctl.conf
fs.file-max = 6815744
kernel.shmall = 2097152
kernel.shmmax = 4294967295
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
fs.aio-max-nr = 1048576
sysctl -p
修改limits.conf
vi /etc/security/limits.conf
oracle settings
oracle soft nproc 2047
oracle hard nproc 16384
oracle soft nofile 1024
oracle hard nofile 65536
oracle soft stack 10240
grid soft nproc 2047
grid hard nproc 16384
grid soft nofile 1024
grid hard nofile 65536
grid soft stack 1024
修改/etc/pam.d/login
vi /etc/pam.d/login
session required /lib/security/pam_limits.so
session required 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
fi
修改/etc/csh.login
if ( $USER == "oracle" ) then
limit maxproc 16384
limit deors 65536
endif
4、
--添加用戶和組(非Oracle Linux環境配置)
groupadd -g 501 oinstall
groupadd -g 502 dba
groupadd -g 503 oper
groupadd -g 504 asmadmin
groupadd -g 505 asmdba
groupadd -g 506 asmoper
useradd -u 500 -g oinstall -G dba,asmdba,asmadmin,oper oracle
useradd -u 507 -g oinstall -G asmadmin,asmdba,asmoper,oper,dba grid
註意,oper組不是必須的,dba,asmdba,asmadmin必須有
--修改grid和oracle用戶密碼
passwd oracle
passwd grid
--配置環境變數
grid:
export ORACLE_SID=+ASM
export ORACLE_BASE=/home/u01/grid
export ORACLE_HOME=$ORACLE_BASE/11.2.0
export PATH=$ORACLE_HOME/bin:$PATH:/usr/local/bin/:
export NLS_LANG=American_america.ZHS16GBK
export TEMP=/tmp
export TMP=/tmp
export TMPDIR=/tmp
umask 022
oracle:
ORACLE_SID=ydasm; export ORACLE_SID
ORACLE_BASE=/home/u01/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/11.2.0/db_1; export ORACLE_HOME
GRID_HOME=/home/u01/grid/11.2.0; export GRID_HOME
NLS_DATE_FORMAT="YYYY:MM:DD HH24:MI:SS"; export NLS_DATE_FORMAT
NLS_LANG=american_america.ZHS16GBK; export NLS_LANG
PATH=.:${PATH}:$HOME/bin:$ORACLE_HOME/bin:$GRID_HOME/bin export PATH
export NLS_LANG=American_america.ZHS16GBK
export TEMP=/tmp
export TMPDIR=/tmp
umask 022
主要是配置幾個環境變數必須
mkdir -p /home/u01/grid/11.2.0
mkdir -p /home/u01/grid
mkdir -p /home/u01/oracle/product/11.2.0/db_1
chown -R oracle:oinstall /home/u01
chmod -R 775 /home/u01
5、上傳Oracle安裝介質到/u01/tmp目錄下
mkdir -p /u01/tmp
p13390677_112040_Linux-x86-64_1of7.zip
p13390677_112040_Linux-x86-64_2of7.zip
p13390677_112040_Linux-x86-64_3of7.zip
6、vi /etc/redhat-release
Red Hat Enterprise Linux Server release 4.0 (Santiago)
7、安裝grid組件
--利用udev綁定磁碟
for Linux 6.x
for i in b c d;
do
echo "KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u /dev/\$name",
RESULT=="/sbin/scsi_id -g -u /dev/sd$i
", NAME="asm-disk$i", OWNER="grid",
GROUP="asmadmin", MODE="0660""
done
for Linux 5.x
for i in b c d;
do
echo "KERNEL=="sd*", BUS=="scsi", PROGRAM=="/sbin/scsi_id -g -u -s %p", RESULT=="scsi_id -g -u -s /block/sd$i
", NAME="asm-disk$i", OWNER="grid", GROUP="asmadmin", MODE="0660""
done
使用的時候要註意在不同版本上腳本的區別,否則獲取不到磁碟的scsi_id
[root@rac1 ]# /sbin/service ntpd stop
關閉 ntpd: [失敗][root@rac1 ]# chkconfig ntpd off
[root@rac1 ]# mv /etc/ntp.conf /etc/ntp.conf.original
直接使用裸設備的方法:
1.在RHEL6以前的可以直接通過rawdevices的管理方法,系統安裝後預設已存在/etc/init.d/rawdevices和/etc/sysconfig/rawdevices這兩個文件。
- 在RHEL6中,系統裡面雖然已經不存在/etc/sysconfig/rawdevices和/etc/init.d/rawdevices文件了,但是依然支持rawdevices的方式,可以通過如下方法來管理raw文件。
a.手動創建/etc/sysconfig/rawdevices和/etc/init.d/rawdevices文件,然後依然以rawdevices的方式
b.通過udev來管理raw,同樣也可以通過udev固定磁碟對應的設備名
採用新建的方法
vi /etc/init.d/rawdevices
!/bin/bash
rawdevices This shell script assignes rawdevices to block devices
chkconfig: 345 56 44
description: This scripts assignes raw devices to block devices \
(such as hard drive partitions). This is for the use \
of applications such as Oracle. You can set up the \
raw device to block device mapping by editing \
the file /etc/sysconfig/rawdevices.
config: /etc/sysconfig/rawdevices
[ -f /bin/raw ] || exit 0
[ -f /etc/sysconfig/rawdevices ] || exit 0
Exit if the file just has the default comments.
LC_ALL=C /bin/egrep -q -v "^ #" /etc/sysconfig/rawdevices 2>/dev/null || exit 0
. /etc/init.d/functions
function assign_raw()
{
LC_ALL=C egrep -v '^ #' /etc/sysconfig/rawdevices |
while read RAW BLOCK; do
if [ -n "$RAW" -a -n "$BLOCK" ]; then
rawdirname=${RAW%/*}
if [ "$rawdirname" = "/dev" -a -d /dev/raw ]; then
echo $" Please correct your /etc/sysconfig/rawdevices:"
echo $" rawdevices are now located in the directory /dev/raw/ "
echo $" If the command 'raw' still refers to /dev/raw as a file."
echo $" you'll have to upgrade your util-linux package"
exit 0
fi
if [ "$rawdirname" = "/dev/raw" -a -f /dev/raw ]; then
echo $" Please correct your /etc/sysconfig/rawdevices:"
echo $" rawdevices are now located in the directory /dev/raw/ "
echo $" If the command 'raw' still refers to /dev/raw as a file."
echo $" you'll have to upgrade your util-linux package"
exit 0
fi
echo " $RAW --> $BLOCK";
raw $RAW $BLOCK
fi
done
}
See how we were called.
case "$1" in
start)
# Assign devices
echo $"Assigning devices: "
assign_raw
添加以下兩行(預設不存在),即預設情況下生成的裸設備為root所有,
所以必須修改屬主,否則oracle用戶無法使用裸設備
sleep 5
chown -R grid:asmadmin /dev/raw/
echo $"done"
;;
stop)
# No action to be taken here
;;
status)
ID=id -u
if [ $ID -eq 0 ]; then
raw -qa
else
echo $"You need to be root to use this command ! "
fi
;;
restart|reload)
$0 start
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
exit 1
esac
exit 0
vi /etc/sysconfig/rawdevices //映射將要綁定的裸設備
/dev/raw/raw5 /dev/sdb
/dev/raw/raw6 /dev/sdc
/dev/raw/raw7 /dev/sdd
/dev/raw/raw8 /dev/sde
[root@rac1]# chkconfig rawdevices on
[root@rac1]# service rawdevices start
1.4 綁定裸設備(用於創建ASM磁碟組,更詳細的內容請參考:http://www.linuxidc.com/Linux/2013-06/85973.htm)
[root@ydtest host2]# pwd
/sys/class/scsi_host/host2
[root@ydtest host2]# echo '- - -' > scan
[root@ydtest host2]#
[root@ydtest host2]# cd ../host0
[root@ydtest host0]# echo '- - -' > scan
虛擬機加盤後 掃描盤
[root@rac1]# fdisk -l
Disk /dev/sda: 32.2 GB, 32212254720 bytes
255 heads, 63 sectors/track, 3916 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 5 40131 83 Linux
/dev/sda2 6 2172 17406427+ 8e Linux LVM
/dev/sda3 2173 2237 522112+ 82 Linux swap / Solaris
/dev/sda4 2238 3916 13486567+ 5 Extended
/dev/sda5 2238 2542 2449881 83 Linux
/dev/sda6 2543 2847 2449881 83 Linux
/dev/sda7 2848 3152 2449881 83 Linux
/dev/sda8 3153 3457 2449881 83 Linux
/dev/sda9 3458 3916 3686886 83 Linux
[root@rac1 rules.d]# cd /etc/udev/rules.d/
[root@rac1 rules.d]# vi 99-oracle.rules
ACTION=="add",KERNEL=="sdb",RUN+="/bin/raw /dev/raw/raw5 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
ACTION=="add",KERNEL=="sdc",RUN+="/bin/raw /dev/raw/raw6 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
ACTION=="add",KERNEL=="sdd",RUN+="/bin/raw /dev/raw/raw7 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
ACTION=="add",KERNEL=="sde",RUN+="/bin/raw /dev/raw/raw8 %N",OWNER="grid", GROUP="asmadmin", MODE="660"
--重啟udev,使配置生效
/sbin/start_udev
[root@rac1]# vi /etc/sysconfig/rawdevices
/dev/raw/raw5 /dev/sdb
/dev/raw/raw6 /dev/sdc
/dev/raw/raw7 /dev/sdd
/dev/raw/raw8 /dev/sde
[root@rac1]# chmod +x /etc/rc.d/init.d/rawdevices
[root@rac1]# chkconfig --add rawdevices
[root@rac1]# chkconfig rawdevices on
[root@rac1]# service rawdevices start
Assigning devices:
/dev/raw/raw5 --> /dev/sdb
/dev/raw/raw5: bound to major 8, minor 5
/dev/raw/raw6 --> /dev/sdc
/dev/raw/raw6: bound to major 8, minor 6
/dev/raw/raw7 --> /dev/sdd
/dev/raw/raw7: bound to major 8, minor 7
/dev/raw/raw8 --> /dev/sde
/dev/raw/raw8: bound to major 8, minor 8
done
[root@rac1]# raw -qa
/dev/raw/raw5: bound to major 8, minor 5
/dev/raw/raw6: bound to major 8, minor 6
/dev/raw/raw7: bound to major 8, minor 7
/dev/raw/raw8: bound to major 8, minor 8
如果執行腳本的時候停在Adding daemon to inittab,這是 11.2.0.1和11.2.0.2 在RHEL6上的bug,可以以root身份執行以下命令:
[root@rac1]# dd if=/var/tmp/.oracle/npohasdof=/dev/null bs=1024 count=1
ydasm 2016/11/22 11:21:57 /home/u01/grid/11.2.0/cdata/ydasm/backup_20161122_112157.olr
Successfully configured Oracle Grid Infrastructure for a Standalone Server
Asmca
Dbca
2.3 安裝後的檢查、配置
檢查是否正確安裝:
$ oraenv
ORACLE_SID=+ASM
The Oracle base for ORACLE_HOME=/u01/app/oracle/product/11.2.0/grid is /u01/app/oracle
$ echo $ORACLE_SID
+ASM
$ crsctl check has
CRS-4638: Oracle High Availability Services is online
$ crs_stat -t
Name Type Target State Host
------------------------------------------------------------
ora.DATA.dg ora....up.type ONLINE ONLINE ydasm
ora....ER.lsnr ora....er.type ONLINE ONLINE ydasm
ora.VOTE.dg ora....up.type ONLINE ONLINE ydasm
ora.asm ora.asm.type ONLINE ONLINE ydasm
ora.cssd ora.cssd.type ONLINE ONLINE ydasm
ora.diskmon ora....on.type OFFLINE OFFLINE
ora.evmd ora.evm.type ONLINE ONLINE ydasm
ora.ons ora.ons.type OFFLINE OFFLINE
從11.2.0.3以後,在非Exadata上, ora.diskmon的預設狀態為offline
ora.ons主要用於中間件和資料庫的相連
設置開機自動啟動crs:
[root@rac1]# tail -n 1 /etc/inittab //安裝完成預設會向inittab文件添加該記錄
h1:35:respawn:/etc/init.d/init.ohasd run >/dev/null 2>&1 > /etc/rc.local <
[root@rac1]#rm -rf /u01/app/oracle/product/11.2.0/grid/ //刪除grid的安裝文件
[root@rac1]# for i in {5..8} ;do dd if=/dev/zero of=/dev/raw/raw$i bs=1024 count=10 ;done //低格裸設備(清除ASM磁碟組信息)