Thứ Tư, 30 tháng 3, 2022

Triển khai OCFS2 cùng đọc/ghi cho ứng dụng Cluster trên Linux

Oracle Cluster File System (OCFS2) là một hệ thống file mà các node của cluster có thể cùng đọc/ghi vào đó cùng 1 lúc, bao gồm cả RAC. Mặc dù OCFS2 có thể được sử dụng để chia sẻ tệp dữ liệu giữa các node RAC, nhưng khuyến cáo không nên dùng mà thay vào đó sử dụng ASM dưới dạng raw device hoặc thông qua phần mềm ASMLib. Mặc dù vậy, OCFS2 có một số công dụng trong môi trường RAC, chẳng hạn như cung cấp vị trí được chia sẻ cho UTL_FILE và các hoạt động bảng bên ngoài cho toàn bộ RAC. Bài viết dưới đây minh họa cài đặt và cấu hình cơ bản của OCFS2.

Thực hiện tất cả các thao tác sau trên tất cả các node trong cluster.

Tạo thư mục:

# mkdir /u02

Kiểm tra phiên bản kernel version: 

# uname -r
2.6.9-22.EL
#

Download phiên bản  OCFS2 kernel module và công cụ: 

Cài đặt:

# rpm -Uvh ocfs2-2.6.9-22.EL-1.2.1-1.i686.rpm \
           ocfs2console-1.2.1-1.i386.rpm \
           ocfs2-tools-1.2.1-1.i386.rpm \
           ocfs2-tools-debuginfo-1.2.1-1.i386.rpm
Preparing...                ########################################### [100%]
   1:ocfs2-tools            ########################################### [ 25%]
   2:ocfs2-2.6.9-22.EL      ########################################### [ 50%]
   3:ocfs2console           ########################################### [ 75%]
   4:ocfs2-tools-debuginfo  ########################################### [100%]
#

Bật OCFS2 Console từ root:

# ocfs2console


Vào "Cluster > Configure Nodes..." , không cần để ý thông tin dưới, ấn nút Close 


Owrr màn hình "Node Configuration" Chọn nút Add:

Đặt tên và địa chỉ IP cho node đầu tiên, sau đó ấn OK:


Thêm node thứ 2 sau đó ấn vào nút "Apply", sau đó ấn "Close"


Sửa "/etc/init.d/o2cb" script, Bỏ những dòng bên dưới:

### BEGIN INIT INFO
## Provides: o2cb
## Required-Start: $network
## Should-Start:
## Required-Stop:
## Default-Start: 2 3 5
## Default-Stop:
## Description: Load O2CB cluster services at system boot.
### END INIT INFO

Đăng ký lại dịch vụ o2cb:

# chkconfig --del o2cb
# chkconfig --add o2cb
# chkconfig --list o2cb
o2cb            0:off   1:off   2:on    3:on    4:on    5:on    6:off
#

Cấu hình dịch vụ o2cb:

# /etc/init.d/o2cb offline ocfs2
Cleaning heartbeat on ocfs2: OK
Stopping cluster ocfs2: OK
#
# /etc/init.d/o2cb unload
Unmounting ocfs2_dlmfs filesystem: OK
Unloading module "ocfs2_dlmfs": OK
Unmounting configfs filesystem: OK
Unloading module "configfs": OK
#
# /etc/init.d/o2cb configure
Configuring the O2CB driver.

This will configure the on-boot properties of the O2CB driver.
The following questions will determine whether the driver is loaded on
boot.  The current values will be shown in brackets ('[]').  Hitting
<ENTER> without typing an answer will keep that current value.  Ctrl-C
will abort.

Load O2CB driver on boot (y/n) [y]:
Cluster to start on boot (Enter "none" to clear) [ocfs2]:
Writing O2CB configuration: OK
Loading module "configfs": OK
Mounting configfs filesystem at /config: OK
Loading module "ocfs2_nodemanager": OK
Loading module "ocfs2_dlm": OK
Loading module "ocfs2_dlmfs": OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK
Starting cluster ocfs2: OK

Một số lệnh khác hay dùng: 

  • "/etc/init.d/o2cb load" - Nạp lại  mọi OCFS2 modules.
  • "/etc/init.d/o2cb online" - Đưa cluster online.
  • "/etc/init.d/o2cb offline" - Đặt cluster offline.
  • "/etc/init.d/o2cb unload" - Không nạp mọi OCFS2 modules.

Partition shared disk(s) chỉ trên 1 node. Dùng lệnh "fdisk" với đĩa "/dev/sdb" 

# cd /dev
# ls sd*
sda  sda1  sda2  sdb
# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.


The number of cylinders for this disk is set to 1305.
There is nothing wrong with that, but this is larger than 1024,
and could in certain setups cause problems with:
1) software that runs at boot time (e.g., old versions of LILO)
2) booting and partitioning software from other OSs
   (e.g., DOS FDISK, OS/2 FDISK)
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

Command (m for help): n
Command action
   e   extended
   p   primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-1305, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-1305, default 1305):
Using default value 1305

Command (m for help): p

Disk /dev/sdb: 10.7 GB, 10737418240 bytes
255 heads, 63 sectors/track, 1305 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

   Device Boot      Start         End      Blocks   Id  System
/dev/sdb1               1        1305    10482381   83  Linux

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.
#

Trên node còn lại, dùng lệnh "fdisk" và gõ "w" để chắc chắn rằng partition đã tồn tại

Bật console OCFS2 trên node đầu tiên:

# ocfs2console

Ở màn hình Console, chọn menu "Tasks > Format". Chọn partiton phù hợp (dev/sdb1) và click OK và "Yes" ở màn hình tiếp theo:


Partition hiển thị trên màn hình console khi format hoàn thành: 

Click vào nút mount trên toolbar. Gõ vào mount point "/u02" và ghi chú vào options, sau đó chọn OK 

Partition bây giờ được mountpoint là /u02 trên màn hình console: 



Chỉ cầnmount operation trên các node còn lại, không cần format nhé 

Để tự động mount filesystem, thêm vào file "/etc/fstab" ở mỗi node: 

/dev/sdb1     /u02    ocfs2   _netdev,datavolume     0 0

Filesystem đã có thể dùng ở mọi node.

Hy vọng hữu ích cho bạn.

=============================
* KHOÁ HỌC ORACLE DATABASE A-Z ENTERPRISE trực tiếp từ tôi giúp bạn bước đầu trở thành những chuyên gia DBA, đủ kinh nghiệm đi thi chứng chỉ OA/OCP, đặc biệt là rất nhiều kinh nghiệm, bí kíp thực chiến trên các hệ thống Core tại VN chỉ sau 1 khoá học.
* CÁCH ĐĂNG KÝ: Gõ (.) hoặc để lại số điện thoại hoặc inbox https://m.me/tranvanbinh.vn hoặc Hotline/Zalo 090.29.12.888
* Chi tiết tham khảo:
https://bit.ly/oaz_w
=============================
KẾT NỐI VỚI CHUYÊN GIA TRẦN VĂN BÌNH:
📧 Mail: binhoracle@gmail.com
☎️ Mobile: 0902912888
⚡️ Skype: tranbinh48ca
👨 Facebook: https://www.facebook.com/BinhOracleMaster
👨 Inbox Messenger: https://m.me/101036604657441 (profile)
👨 Fanpage: https://www.facebook.com/tranvanbinh.vn
👨 Inbox Fanpage: https://m.me/tranvanbinh.vn
👨👩 Group FB: https://www.facebook.com/groups/DBAVietNam
👨 Website: https://www.tranvanbinh.vn
👨 Blogger: https://tranvanbinhmaster.blogspot.com
🎬 Youtube: http://bit.ly/ytb_binhoraclemaster
👨 Tiktok: https://www.tiktok.com/@binhoraclemaster?lang=vi
👨 Linkin: https://www.linkedin.com/in/binhoracle
👨 Twitter: https://twitter.com/binhoracle
👨 Địa chỉ: Tòa nhà Sun Square - 21 Lê Đức Thọ - Phường Mỹ Đình 1 - Quận Nam Từ Liêm - TP.Hà Nội

=============================
học oracle database, Tự học Oracle, Tài liệu Oracle 12c tiếng Việt, Hướng dẫn sử dụng Oracle Database, Oracle SQL cơ bản, Oracle SQL là gì, Khóa học Oracle Hà Nội, Học chứng chỉ Oracle ở đầu, Khóa học Oracle online,khóa học pl/sql, học dba, học dba ở việt nam, khóa học dba, khóa học dba sql, tài liệu học dba oracle, Khóa học Oracle online, học oracle sql, học oracle ở đâu tphcm, học oracle bắt đầu từ đâu, học oracle ở hà nội, oracle database tutorial, oracle database 12c, oracle database là gì, oracle database 11g, oracle download, oracle database 19c, oracle dba tutorial, oracle tunning, sql tunning , oracle 12c, oracle multitenant, Container Databases (CDB), Pluggable Databases (PDB), oracle cloud, oracle security, oracle fga, audit_trail, oracle dataguard, oracle goldengate, mview, oracle exadata, oracle oca, oracle ocp, oracle ocm , oracle weblogic, middleware, hoc solaris, hoc linux, hoc aix, unix, securecrt, xshell, mobaxterm, putty

ĐỌC NHIỀU

Trần Văn Bình - Oracle Database Master