Friday, August 21, 2015

RHEL 6- rawdevices service configuration using raw device

I happen to find this note on my PC. I have no idea where I got it from. Looks informative and felt like posting here. Full credit goes to the original document creator.

RHEL 6 rawdevices service configuration using raw device

rhel5.0-5.3 canceled rawdevices service, then rhel5.4 over in support rawdevices service, now rhel6 not support, and many of them are using the Internet to do the bare udev device, rawdevices configure it a lot simpler. To study how to use under the following service on rhel6 rawdevices to create a raw device First Study
1. In rhel5.4:
[Root @ tanyangxf ~] # uname -a
Linux tanyangxf 2.6.18-164.el5 # 1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU / Linux
[Root @ tanyangxf ~] # cat / etc / redhat-release
Red Hat Enterprise Linux Server release 5.4 (Tikanga)
[Root @ tanyangxf ~] #
[Root @ tanyangxf ~] # which raw
/ Bin / raw
[Root @ tanyangxf ~] # rpm -qf / bin / raw
util-linux-2.13-0.52.el5
[Root @ tanyangxf ~] # rpm -qf /etc/init.d/rawdevices
initscripts-8.45.30-2.el5
[Root @ tanyangxf ~] # rpm -qf / etc / sysconfig / rawdevices
initscripts-8.45.30-2.el5
[Root @ tanyangxf ~] #
We found that the raw command from util-linux package, while /etc/init.d/rawdevices and / etc / sysconfig / rawdevices initscripts these two documents from the package, we look at the situation on rhel6
[Root @ node1 ~] # uname -a
Linux node1 2.6.32-279.el6.x86_64 # 1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU / Linux
[Root @ node1 ~] # cat / etc / redhat-release
Red Hat Enterprise Linux Server release 6.3 (Santiago)
[Root @ node1 ~] # rpm -qf / bin / raw
util-linux-ng-2.17.2-12.7.el6.x86_64
Similarly, raw command also belong util-linux package (in fact, nonsense), in accordance with the above reasoning, the rhel6 actually less only two files, verify that:
rhel5.4 on:
[Root @ tanyangxf ~] # uname -a
Linux tanyangxf 2.6.18-164.el5 # 1 SMP Tue Aug 18 15:51:48 EDT 2009 x86_64 x86_64 x86_64 GNU / Linux
[Root @ tanyangxf ~] # rpm -pql /mnt/Server/initscripts-8.45.30-2.el5.x86_64.rpm | grep raw
warning: /mnt/Server/initscripts-8.45.30-2.el5.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID 37017186
/etc/rc.d/init.d/rawdevices
/ Etc / sysconfig / rawdevices
[Root @ tanyangxf ~] #
rhel6 on:
[Root @ node1 ~] # uname -a
Linux node1 2.6.32-279.el6.x86_64 # 1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU / Linux
[Root @ node1 ~] # rpm -pql /mnt/Packages/initscripts-9.03.31-2.el6.x86_64.rpm | grep raw
warning: /mnt/Packages/initscripts-9.03.31-2.el6.x86_64.rpm: Header V3 RSA / SHA256 Signature, key ID fd431d51: NOKEY
[Root @ node1 ~] #
These two documents are not the rhel6
We have to look at these two documents on rhel5.4 what is inside
[Root @ tanyangxf ~] # cat /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
echo $ "done"
;;
Through this startup script we can find that this script is actually to read / etc / sysconfig / rawdevices information in this file is then used to create a raw device since the device can be created by udev naked through the raw command, that prove the core of nude equipment is supported, but this service redhat will rawdevices removed it, we can also verify the kernel supports raw
In rhel5.4:
[Root @ tanyangxf ~] # cat /boot/config-2.6.18-164.el5 | grep CONFIG_RAW
CONFIG_RAW_DRIVER = y
[Root @ tanyangxf ~] # ls / dev / rawctl -l
crw --- 1 root root 162, 0 Feb 24 04:04 / dev / rawctl
In rhel6
[Root @ node1 ~] # cat /boot/config-2.6.32-279.el6.x86_64 | grep CONFIG_RAW
CONFIG_RAW_DRIVER = y
[Root @ node1 ~] # ls / dev / raw / -l
total 0
crw-rw--. 1 root disk 162, 0 Mar 9 19:02 rawctl
The kernel is the support of that have to do now is simple, copy /etc/init.d/rawdevices and / etc / sysconfig / rawdevices these two files from the rhel5.4 to rhel6 system, then you can register at the service a.
[Root @ tanyangxf ~] # scp /etc/init.d/rawdevices 172.2.9.2:/etc/init.d/.
root@172.2.9.2's password:
rawdevices 100% 2245 2.2KB / s 00:00
[Root @ tanyangxf ~] # scp / etc / sysconfig / rawdevices 172.2.9.2:/etc/sysconfig/.
root@172.2.9.2's password:
rawdevices 100% 177 0.2KB / s 00:00
[Root @ tanyangxf ~] #
At this time this service has not rawdevices
[Root @ node1 ~] # uname -a
Linux node1 2.6.32-279.el6.x86_64 # 1 SMP Wed Jun 13 18:24:36 EDT 2012 x86_64 x86_64 x86_64 GNU / Linux
[Root @ node1 ~] # chkconfig -list | grep raw
[Root @ node1 ~] #
We registered under service
[Root @ node1 ~] # chkconfig -add rawdevices
[Root @ node1 ~] # chkconfig -list | grep raw
rawdevices 0: off 1: off 2: off 3: on 4: on 5: on 6: off
[Root @ node1 ~] #
Writes a raw device configuration, and then start the service
[Root @ node1 ~] # cat / etc / sysconfig / rawdevices
# Raw device bindings
# Format: <rawdev> <major> <minor>
# <Rawdev> <blockdev>
# Example: / dev / raw / raw1 / dev / sda1
# / Dev / raw / raw2 8 5
/ Dev / raw / raw1 / dev / sdb1
[Root @ node1 ~] # /etc/init.d/rawdevices start
Assigning devices:
/ Dev / raw / raw1 -> / dev / sdb1
/ Dev / raw / raw1: bound to major 8, minor 17
done
[Root @ node1 ~] # raw -qa
/ Dev / raw / raw1: bound to major 8, minor 17
[Root @ node1 ~] #
So that we can then use as the rhel6 rhel5.4 rawdevicesfuw like to create a raw device.
Special note: When the device name change, raw will be a problem, if you can, please try to use udev. , These are my reasoning income has not been officially confirmed for research nature, interested friends can share together!


Here are the steps:


1. Add the startup script
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
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

2, registered under rawdevices Service
[Root @ node1 ~] # chkconfig --add rawdevices
[Root @ node1 ~] # chkconfig -list | grep raw
rawdevices 0: off 1: off 2: off 3: on 4: on 5: on 6: off
[Root @ node1 ~] #


3. Configure the raw device, specify the raw device mapping relationship
[Root @ rac1 ~] # cat / etc / sysconfig / rawdevices
# Raw device bindings
# Format: <rawdev> <major> <minor>
# <Rawdev> <blockdev>
# Example: / dev / raw / raw1 / dev / sda1
# / Dev / raw / raw2 8 5
/ Dev / raw / raw1 / dev / sda1
/ Dev / raw / raw2 / dev / sda2
/ Dev / raw / raw3 / dev / sda3
/ Dev / raw / raw4 / dev / sda4
/ Dev / raw / raw5 / dev / sda5
/ Dev / raw / raw6 / dev / sda6

4, modify /etc/udev/rules.d/60-raw.rules
[Root @ centos210 ~] # cat /etc/udev/rules.d/60-raw.rules
# Enter raw device bindings here.
#
# An example would be:
# ACTION == "add", KERNEL == "sda", RUN + = "/ bin / raw / dev / raw / raw1% N"
# To bind / dev / raw / raw1 to / dev / sda, or
# ACTION == "add", ENV {MAJOR} == "8", ENV {MINOR} == "1", RUN + = "/ bin / raw / dev / raw / raw2% M% m"
# To bind / dev / raw / raw2 to the device with major 8, minor 1.
#ACTION == "Add", KERNEL == "/ dev / sdb1", RUN + = "/ bin / raw / dev / raw / raw1% N"
#ACTION == "Add", ENV {MAJOR} == "8", ENV {MINOR} == "17", RUN + = "/ bin / raw / dev / raw / raw1% M% m"
#ACTION == "Add", KERNEL == "/ dev / sdc1", RUN + = "/ bin / raw / dev / raw / raw2% N"
#ACTION == "Add", ENV {MAJOR} == "8", ENV {MINOR} == "33", RUN + = "/ bin / raw / dev / raw / raw2% M% m"
#ACTION == "Add", KERNEL == "/ dev / sdd1", RUN + = "/ bin / raw / dev / raw / raw3% N"
#ACTION == "Add", ENV {MAJOR} == "8", ENV {MINOR} == "49", RUN + = "/ bin / raw / dev / raw / raw3% M% m"
#ACTION == "Add", KERNEL == "/ dev / sde1", RUN + = "/ bin / raw / dev / raw / raw4% N"
#ACTION == "Add", ENV {MAJOR} == "8", ENV {MINOR} == "65", RUN + = "/ bin / raw / dev / raw / raw4% M% m"
KERNEL == "raw [1-6]", OWNER = "grid", GROUP = "oinstall", MODE = "640"

Restart rawdevices
[Root @ node1 ~] # /etc/init.d/rawdevices start
Assigning devices:
/ Dev / raw / raw1 -> / dev / sdb1
/ Dev / raw / raw1: bound to major 8, minor 17
done
Check whether the binding is successful
[Root @ node1 ~] # raw -qa

5. Add to the boot
[Root @ rac1 ~] #chkconfig --add rawdevices
6. Restart the server OK
reboot

No comments:

Post a Comment