有些 Web API (google map or ...) 不能讓你直用 for 呼叫數次,因此,要採用 setTimeout 處理, 如下...
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
$(function () {
//準備從1/1做到5/31
var d = new Date(2011, 0, 1);
var june = new Date(2011, 5, 1);
//將待處理的日期放進Array中
var jobQueue = [];
while (d < june) {
var yy = d.getFullYear();
var mm = d.getMonth() + 1;
if (mm < 10) mm = "0" + mm;
var dd = d.getDate();
if (dd < 10) dd = "0" + dd;
//產生yyyy/MM/dd格式日期
jobQueue.push(yy + "/" + mm + "/" + dd);
d.setDate(d.getDate() + 1);
}
var $body = $("body");
function run() {
//檢查是否還有待處理工具
if (jobQueue.length > 0) {
s = jobQueue.shift();
$.post("DoSomething.aspx?date=" + s, {}, function (r) {
//顯示執行結果
$body.append("<div>" + s + ":" + r + "</div>");
//使用setTimeout可調節連續執行的速度
setTimeout(function () {
run();
}, 10);
});
}
}
run();
});
</script>
</head>
<body></body></html>
這樣就可以處理回圈呼叫了~
Ref: http://blog.darkthread.net/post-2011-06-01-ajax-loop-with-js.aspx
2011年12月29日 星期四
當..Dom還沒建立卻要塞東西時...
要檢查狀態,要這樣....
....
//利用setInterval 0.1秒觸發一次檢查
var hnd = setInterval(function () {
var t = $(frm).contents().find("div").text();
//若已取到資料
if (t) {
//顯示結果
showMsg("Ready + setInterval Trick for " + frm.id + " -> " + t);
//終止setInterval輪詢檢查
clearInterval(hnd);
}
}, 100);
....
原始Codes
var $frms = $("#frmA,#frmB");
$frms.load(function () {
showMsg("Load Event for " + this.id + "->" +
$(this).contents().find("div").text());
});
setTimeout(function () {
$frms.each(function () {
//在ready事件中,this不會指向IFrame,故這裡另設變數保存之
var frm = this;
$(frm).ready(function () {
//ready事件不保證DOM已載入完成,故可能取不到資料
showMsg("Ready Event for " + frm.id + " -> " +
$(frm).contents().find("div").text());
//利用setInterval 0.1秒觸發一次檢查
var hnd = setInterval(function () {
var t = $(frm).contents().find("div").text();
//若已取到資料
if (t) {
//顯示結果
showMsg("Ready + setInterval Trick for " +
frm.id + " -> " + t);
//終止setInterval輪詢檢查
clearInterval(hnd);
}
}, 100);
});
});
}, 1000);
Ref. http://blog.darkthread.net/post-2011-10-27-iframe-load.aspx
....
//利用setInterval 0.1秒觸發一次檢查
var hnd = setInterval(function () {
var t = $(frm).contents().find("div").text();
//若已取到資料
if (t) {
//顯示結果
showMsg("Ready + setInterval Trick for " + frm.id + " -> " + t);
//終止setInterval輪詢檢查
clearInterval(hnd);
}
}, 100);
....
原始Codes
var $frms = $("#frmA,#frmB");
$frms.load(function () {
showMsg("Load Event for " + this.id + "->" +
$(this).contents().find("div").text());
});
setTimeout(function () {
$frms.each(function () {
//在ready事件中,this不會指向IFrame,故這裡另設變數保存之
var frm = this;
$(frm).ready(function () {
//ready事件不保證DOM已載入完成,故可能取不到資料
showMsg("Ready Event for " + frm.id + " -> " +
$(frm).contents().find("div").text());
//利用setInterval 0.1秒觸發一次檢查
var hnd = setInterval(function () {
var t = $(frm).contents().find("div").text();
//若已取到資料
if (t) {
//顯示結果
showMsg("Ready + setInterval Trick for " +
frm.id + " -> " + t);
//終止setInterval輪詢檢查
clearInterval(hnd);
}
}, 100);
});
});
}, 1000);
Ref. http://blog.darkthread.net/post-2011-10-27-iframe-load.aspx
2011年12月27日 星期二
2011年12月5日 星期一
Google Map InfoWindow 控制只顯示一個
" If you only want one info window to display at a time (as is the behavior on Google Maps), you need only create one info window, which you can reassign to different locations or markers upon map events (such as user clicks).
Therefore, you may simply want to create one
InfoWindow
object just after you initialize your map, and then handle the click
event handler as follows:google.maps.event.addListener(curMarker, 'click', function() {
infowindow.setContent(contentString);
infowindow.open(map, curMarker);
});
Then the
也就是說, 只要變數名稱一樣就好, API 會自動關掉其他同名的 InfoWindow.
InfoWindow
should automatically close when you click on a new marker without having to call the close()
method. "也就是說, 只要變數名稱一樣就好, API 會自動關掉其他同名的 InfoWindow.
2011年11月11日 星期五
SSH 設定 for X11
in "/etc/ssh/ssh_config"
打開
ForwardAgent no
ForwardX11 no
FallBackToRsh no
to YES!!
and turn off GSSs.
打開
ForwardAgent no
ForwardX11 no
FallBackToRsh no
to YES!!
and turn off GSSs.
2011年11月2日 星期三
Ubuntu 遠端桌面不更新問題
首先 這個指令可以帶出現有桌面
/usr/lib/vino/vino-server --display=:0.0 &
然後!!!
$ gconf-editor
/desktop/gnome/remote_access/disable_xdamage
把這值打勾
就可以了!!!!!
/usr/lib/vino/vino-server --display=:0.0 &
然後!!!
$ gconf-editor
/desktop/gnome/remote_access/disable_xdamage
把這值打勾
就可以了!!!!!
2011年10月31日 星期一
2011年10月26日 星期三
Ubuntu 10 apt-get proxy
/etc/apt/apt.conf
Add one extra line
Acquire::http::Proxy "http://username:password@192.168.1.1:3128";
Add one extra line
Acquire::http::Proxy "http://username:password@192.168.1.1:3128";
2011年10月13日 星期四
7-Zip on CentOS
借用一下同事的 Notes...
wget http:
//nchc
.dl.sourceforge.net
/sourceforge/p7zip/p7zip_4
.65_src_all.
tar
.bz2
tar
-xjvf p7zip_4.65_src_all.
tar
.bz2
cd
p7zip_4.65
make
make
install
# usage
7za x ${COMPRESSED_FILE} -o${OUTPUT_FOLDER}
2011年7月11日 星期一
Ubuntu 11.04 安裝 Sun Java 6 JDK
Ubuntu 11.04 安裝 Sun Java 6 JDK
- 開啟執行Synaptic 套件管理程式。
- 工具列>設定>套件庫>其他軟體>勾選 「Canonical夥伴」,點選「關閉」按鈕確認。
- 關閉Synaptic 套件管理程式,並且再次重新啟動。
- 利用快速過濾功能搜尋 sun-java6
- 視個人需求勾選「sun-java6-jre」、「sun-java6-plugin」與「sun-java6-fonts」等套件,並按下「套用」功能進行套件安裝。
2011年5月25日 星期三
SAMBA optimize conf.
smb.conf
[global]
workgroup = MYGROUP
server string = Samba Server
log file = /var/log/samba/%m.log
max log size = 50
dns proxy = no
security = share
unix charset = utf8
display charset = utf8
dos charset = cp950
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65535 SO_SNDBUF=65535
syslog = 1
syslog only = yes
strict sync = no
sync always = no
log level = 1
read raw = yes
write raw = yes
oplocks = yes
max xmit = 65535
dead time = 15
getwd cache = yes
lpq = 30
large readwrite = no
[123]
path = /mnt/123
public = yes
writable = yes
[global]
workgroup = MYGROUP
server string = Samba Server
log file = /var/log/samba/%m.log
max log size = 50
dns proxy = no
security = share
unix charset = utf8
display charset = utf8
dos charset = cp950
socket options = TCP_NODELAY IPTOS_LOWDELAY SO_RCVBUF=65535 SO_SNDBUF=65535
syslog = 1
syslog only = yes
strict sync = no
sync always = no
log level = 1
read raw = yes
write raw = yes
oplocks = yes
max xmit = 65535
dead time = 15
getwd cache = yes
lpq = 30
large readwrite = no
[123]
path = /mnt/123
public = yes
writable = yes
VMware dep. NAT
nat.conf
# Linux NAT configuration file
[host]
# NAT gateway address
ip = 172.16.12.2
netmask = 255.255.255.0
# VMnet device if not specified on command line
device = /dev/vmnet8
# Allow PORT/EPRT FTP commands (they need incoming TCP stream ...)
activeFTP = 1
# Allows the source to have any OUI. Turn this one if you change the OUI
# in the MAC address of your virtual machines.
allowAnyOUI = 1
[udp]
# Timeout in seconds, 0 = no timeout, default = 60; real value might
# be up to 100% longer
timeout = 60
[incomingudp]
[incomingtcp]
10000 = 172.16.12.10:80
10001 = 172.16.12.11:80
10002 = 172.16.12.12:80
10003 = 172.16.12.13:80
10004 = 172.16.12.14:80
10005 = 172.16.12.15:80
10006 = 172.16.12.16:80
10007 = 172.16.12.17:80
20000 = 172.16.12.10:22
20001 = 172.16.12.11:22
20002 = 172.16.12.12:22
20003 = 172.16.12.13:22
20004 = 172.16.12.14:22
20005 = 172.16.12.15:22
20006 = 172.16.12.16:22
20007 = 172.16.12.17:22
then
/usr/bin/vmware-networks --stop
/usr/bin/vmware-networks --start
# Linux NAT configuration file
[host]
# NAT gateway address
ip = 172.16.12.2
netmask = 255.255.255.0
# VMnet device if not specified on command line
device = /dev/vmnet8
# Allow PORT/EPRT FTP commands (they need incoming TCP stream ...)
activeFTP = 1
# Allows the source to have any OUI. Turn this one if you change the OUI
# in the MAC address of your virtual machines.
allowAnyOUI = 1
[udp]
# Timeout in seconds, 0 = no timeout, default = 60; real value might
# be up to 100% longer
timeout = 60
[incomingudp]
[incomingtcp]
10000 = 172.16.12.10:80
10001 = 172.16.12.11:80
10002 = 172.16.12.12:80
10003 = 172.16.12.13:80
10004 = 172.16.12.14:80
10005 = 172.16.12.15:80
10006 = 172.16.12.16:80
10007 = 172.16.12.17:80
20000 = 172.16.12.10:22
20001 = 172.16.12.11:22
20002 = 172.16.12.12:22
20003 = 172.16.12.13:22
20004 = 172.16.12.14:22
20005 = 172.16.12.15:22
20006 = 172.16.12.16:22
20007 = 172.16.12.17:22
then
/usr/bin/vmware-networks --stop
/usr/bin/vmware-networks --start
2011年5月18日 星期三
News for javascript and postgreSQL
JAVASCRIPT testing tool
http://www.swift-lizard.com/2009/11/24/test-driven-development-with-jquery-qunit/
PostgreSQL pgpool-II
http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#reference
http://www.swift-lizard.com/2009/11/24/test-driven-development-with-jquery-qunit/
PostgreSQL pgpool-II
http://pgpool.projects.postgresql.org/pgpool-II/doc/pgpool-en.html#reference
2011年5月10日 星期二
Para-vir. installation tips
For para-vir. guest HTTP source req.
Install httpd server yum -y install httpd create a directory to mount your iso mkdir /var/www/html/pub mount -o loop /path-to-your-iso-image /var/www/html/pub turn off SELinux & Firewall setenforce 0 iptables -F service httpd start You should now be ready to install your Vm from http://<ip of dom0>/pub
XEN on CentOS Install
以下手動....
yum install -y xen virt-manager kernel-xen ipvsadm
chkconfig xend on
vim /boot/grub/grub.conf
default=0
reboot
....................
echo "Copying VMs"
for i in `seq 33 1 43`
do
echo "172.108.$i.2 NAT setting..."
ssh -l root 172.108.$i.2 "scp root@172.108.31.2:/var/lib/xen/images/*.img /var/lib/xen/images &"
ssh -l root 172.108.$i.2 "scp root@172.108.31.2:/etc/xen/ATC* /etc/xen &"
done
scp root@172.108.31.2:/var/lib/xen/images/*.img /var/lib/xen/images
scp root@172.108.31.2:/etc/xen/ATC* /etc/xen
XEN NAT
echo "Start Setting up NAT"
for i in `seq 31 1 43`
do
echo "172.108.$i.2 NAT setting..."
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10000 -s rr | ipvsadm -a -t 172.108.$i.2:10000 -r 192.168.122.5:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10001 -s rr | ipvsadm -a -t 172.108.$i.2:10001 -r 192.168.122.6:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10002 -s rr | ipvsadm -a -t 172.108.$i.2:10002 -r 192.168.122.7:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10003 -s rr | ipvsadm -a -t 172.108.$i.2:10003 -r 192.168.122.8:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10004 -s rr | ipvsadm -a -t 172.108.$i.2:10004 -r 192.168.122.9:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10005 -s rr | ipvsadm -a -t 172.108.$i.2:10005 -r 192.168.122.10:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10006 -s rr | ipvsadm -a -t 172.108.$i.2:10006 -r 192.168.122.11:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10007 -s rr | ipvsadm -a -t 172.108.$i.2:10007 -r 192.168.122.12:80 -m"
done
xm COMMAND
echo "Start All Xen VMs"
for i in `seq 31 1 43`
do
echo "172.108.$i.2 starting..."
ssh -l root 172.108.$i.2 "xm create ATC0 | xm create ATC1 | xm create ATC2 | xm create ATC3 | xm create ATC4 | xm create ATC5 | xm create ATC6 | xm create ATC7 &"
done
echo "Stop All Xen VMs"
for i in `seq 31 1 43`
do
echo "172.108.$i.2 stoping..."
ssh -l root 172.108.$i.2 "xm shutdown ATC0 | xm shutdown ATC1 | xm shutdown ATC2 | xm shutdown ATC3 | xm shutdown ATC4 | xm shutdown ATC5 | xm shutdown ATC6 | xm shutdown ATC7 &"
done
Test CGIs
http://172.108.31.2:10001/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10002/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10003/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10004/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10005/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10006/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10007/cgi-bin/testcgi.cgi?action=node_status
yum install -y xen virt-manager kernel-xen ipvsadm
chkconfig xend on
vim /boot/grub/grub.conf
default=0
reboot
....................
echo "Copying VMs"
for i in `seq 33 1 43`
do
echo "172.108.$i.2 NAT setting..."
ssh -l root 172.108.$i.2 "scp root@172.108.31.2:/var/lib/xen/images/*.img /var/lib/xen/images &"
ssh -l root 172.108.$i.2 "scp root@172.108.31.2:/etc/xen/ATC* /etc/xen &"
done
scp root@172.108.31.2:/var/lib/xen/images/*.img /var/lib/xen/images
scp root@172.108.31.2:/etc/xen/ATC* /etc/xen
XEN NAT
echo "Start Setting up NAT"
for i in `seq 31 1 43`
do
echo "172.108.$i.2 NAT setting..."
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10000 -s rr | ipvsadm -a -t 172.108.$i.2:10000 -r 192.168.122.5:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10001 -s rr | ipvsadm -a -t 172.108.$i.2:10001 -r 192.168.122.6:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10002 -s rr | ipvsadm -a -t 172.108.$i.2:10002 -r 192.168.122.7:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10003 -s rr | ipvsadm -a -t 172.108.$i.2:10003 -r 192.168.122.8:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10004 -s rr | ipvsadm -a -t 172.108.$i.2:10004 -r 192.168.122.9:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10005 -s rr | ipvsadm -a -t 172.108.$i.2:10005 -r 192.168.122.10:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10006 -s rr | ipvsadm -a -t 172.108.$i.2:10006 -r 192.168.122.11:80 -m"
ssh -l root 172.108.$i.2 "ipvsadm -A -t 172.108.$i.2:10007 -s rr | ipvsadm -a -t 172.108.$i.2:10007 -r 192.168.122.12:80 -m"
done
xm COMMAND
echo "Start All Xen VMs"
for i in `seq 31 1 43`
do
echo "172.108.$i.2 starting..."
ssh -l root 172.108.$i.2 "xm create ATC0 | xm create ATC1 | xm create ATC2 | xm create ATC3 | xm create ATC4 | xm create ATC5 | xm create ATC6 | xm create ATC7 &"
done
echo "Stop All Xen VMs"
for i in `seq 31 1 43`
do
echo "172.108.$i.2 stoping..."
ssh -l root 172.108.$i.2 "xm shutdown ATC0 | xm shutdown ATC1 | xm shutdown ATC2 | xm shutdown ATC3 | xm shutdown ATC4 | xm shutdown ATC5 | xm shutdown ATC6 | xm shutdown ATC7 &"
done
Test CGIs
http://172.108.31.2:10001/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10002/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10003/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10004/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10005/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10006/cgi-bin/testcgi.cgi?action=node_status
http://172.108.31.2:10007/cgi-bin/testcgi.cgi?action=node_status
2011年5月5日 星期四
Apache~ GZIP 啟動
安裝 mod_deflate
修改 C:/AppServ/Apache2.2/conf/httpd.conf 添加
#LoadModule deflate_module modules/mod_deflate.so
去掉前面的 #
LoadModule deflate_module modules/mod_deflate.so
在底下添加:
存檔,重新啟動 Apache
修改 C:/AppServ/Apache2.2/conf/httpd.conf 添加
#LoadModule deflate_module modules/mod_deflate.so
去掉前面的 #
LoadModule deflate_module modules/mod_deflate.so
在底下添加:
<ifmodule mod_deflate.c> DeflateCompressionLevel 9 AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php AddOutputFilter DEFLATE js css </ifmodule>
2011年5月4日 星期三
2011年3月9日 星期三
最近
- XFS + RAID5 + LVM = 66T Single Drive. 可以隨時擴充 Raid or LVM up to EB scale.
- VMware workstation with vmrun command 可以控制很多行為 in Host and Guest.
- PXE 開機 是個好東西 用來網路開機並回復系統, 值得深入一點看.
- File system Limitations....16tb in linux can be solved by adupting XFS file system.
- CentOS:
yum
install
-y xfsprogs
mkfs.xfs -b size=4096
/dev/hda
- GetElementByID sometimes not work in IE and can be replace by using $("#123")[0].
- There is a BUG on the File upload form in IE8, when user wants to get the file path, the method to solve is as:
- var f = document.getElementById(filefield);
- f.select();
- var filename = document.selection.createRange().text;
- For showing Ajax status, place following codes in the begin and end of Ajax request:
- $("#status", window.parent.frames[0].document).show();
- $("#status", window.parent.frames[0].document).hide();
- Mdadm
- 可以不用等 sync, ----- mdadm --create --assume-clean /dev/md4 --level=raid5 --raid-devices=4 /dev/sd{n,o,p,q}
2011年1月25日 星期二
VirtualGL + TurboVNC
VirtualGL + TurboVNC
1. install VirtualGL + TurboVNC
2. Start TurboVNC Server by
ssh to server and
/opt/TurboVNC/bin/vncserver
3. Start TurboVNC Client by
/opt/TurboVNC/bin/vncviewer
And if U want to run any 3D applications MUST:
Procedure
In the terminal, start a 3D application using VirtualGL:
/opt/VirtualGL/bin/vglrun [vglrun options] {application_executable_or_script} {arguments}
The TurboVNC startup script sets the VGL_COMPRESS environment variable to 0, which will automatically enable the X11 Transport within VirtualGL.
applications can be
glxgears
/usr/games/foobillard
1. install VirtualGL + TurboVNC
2. Start TurboVNC Server by
ssh to server and
/opt/TurboVNC/bin/vncserver
3. Start TurboVNC Client by
/opt/TurboVNC/bin/vncviewer
And if U want to run any 3D applications MUST:
Procedure
In the terminal, start a 3D application using VirtualGL:
/opt/VirtualGL/bin/vglrun [vglrun options] {application_executable_or_script} {arguments}
The TurboVNC startup script sets the VGL_COMPRESS environment variable to 0, which will automatically enable the X11 Transport within VirtualGL.
applications can be
glxgears
/usr/games/foobillard
2011年1月24日 星期一
Arduino 初探
這個東西會是我以後 SmartHouse 的控制器...
優點:
1. 便宜 - 一組約1000, 可以有 13個 Digital I/O port and 6 Analog I/O port.
2. 可以連接 USB 透過 Terminal 直接送命令, as
echo "t" > /dev/ttyUSB0
配合下面 Code 可以控制開關LED 燈.
3. 透過訊號加強可以延伸至 50M, 應該有 repeater 可以繼續延伸才對.
4. 軟體 0022 版支援 Ubuntu 10.10
5. ...
優點:
1. 便宜 - 一組約1000, 可以有 13個 Digital I/O port and 6 Analog I/O port.
2. 可以連接 USB 透過 Terminal 直接送命令, as
echo "t" > /dev/ttyUSB0
配合下面 Code 可以控制開關LED 燈.
- void setup() {
- Serial.begin(9600);
- Serial.print("Ready");
- pinMode(13,OUTPUT);
- }
- void loop() {
- if ( Serial.available()) {
- char ch = Serial.read(); //接收由電腦端傳來的字元
- Serial.print(ch);
- switch(ch) {
- case 't':
- digitalWrite(13,HIGH); //將PIN3輸出高電位
- delay(1000);
- break;
- case 'r':
- digitalWrite(13,LOW); //將PIN3輸出高電位
- delay(1000);
- break;
- }
- }
- }
3. 透過訊號加強可以延伸至 50M, 應該有 repeater 可以繼續延伸才對.
4. 軟體 0022 版支援 Ubuntu 10.10
5. ...
2011年1月4日 星期二
MDADM-raid指令
#停止磁碟陣列
mdadm --manage --stop /dev/md0
#啟動磁碟陣列
mdadm --assemble --run /dev/md0
#查看RAID狀態
# mdadm --detail /dev/md0
#建立RAID5
mdadm --create /dev/md1 --level=raid5 --raid-devices=5 --chunk=4 /dev/sd{b,c,d,e,f}1
mdadm --create /dev/md1 --level=raid5 --raid-devices=5 --chunk=4 /dev/sd{g,h,i,j,k}1
#建立 RAID0
mdadm --create /dev/md0 --level=raid0 --raid-devices=3 /dev/sda4 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md0 --level=raid0 --raid-devices=5 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde3
#RAID的配置文件
/etc/mdadm.conf 的文件主要提供我們方便管理,編輯這個文件可以讓RAID更好的為我們工作,當然這個步驟不是必要的.不經過編輯配置文件也可以讓RAID工作。
首先掃描系統中的全部陣列
# mdadm --detail -scan
ARRAY /dev/md0 level=raid5 num-devices=3 UUID=37230e69:51bcf476:9889f244:18b07644
devices=/dev/sda,/dev/sdb,/dev/sdd,/dev/sdc
# vi /etc/mdadm.conf
-------------------------------------------------------------------------------------------------------
DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1
ARRAY /dev/md0 level=raid5 num-devices=3 UUID=37230e69:51bcf476:9889f244:18b07644
devices=/dev/sda,/dev/sdb,/dev/sdd,/dev/sdc
-------------------------------------------------------------------------------------------------------
其中的資料就如同 mdadm --detail -scan 一樣定義了RAID基本資料.
如果你不想手動設定用下面的指令同樣也可以.
mdadm --detail -scan >> /etc/mdadm.conf
#RAID的管理
mdadm /dev/md0 --add /dev/sdd1
mdadm /dev/md0 --fail /dev/sdc1
mdadm /dev/md0 --remove /dev/sdc1
mdadm --manage --run /dev/md0 重建指令 !!小心使用!!
#spare-group
#Multipath
mdadm -C /dev/md0 --level=multipath --raid-devices=2 /dev/sda1 /dev/sdb1
ARRAY /dev/md0 level=raid5 num-devices=5 metadata=00.90 spares=1 UUID=90dcc677:e6ef7c62:9baf8322:4f9d823d
ARRAY /dev/md1 level=raid5 num-devices=5 metadata=00.90 spares=1 UUID=981e1b70:736d1fb5:9baf8322:4f9d823d
#啟動磁碟陣列
mdadm --assemble --run /dev/md0
#查看RAID狀態
# mdadm --detail /dev/md0
#建立RAID5
mdadm --create /dev/md1 --level=raid5 --raid-devices=5 --chunk=4 /dev/sd{b,c,d,e,f}1
mdadm --create /dev/md1 --level=raid5 --raid-devices=5 --chunk=4 /dev/sd{g,h,i,j,k}1
#建立 RAID0
mdadm --create /dev/md0 --level=raid0 --raid-devices=3 /dev/sda4 /dev/sdb1 /dev/sdc1
mdadm --create /dev/md0 --level=raid0 --raid-devices=5 /dev/sda1 /dev/sdb1 /dev/sdc1 /dev/sdd1 /dev/sde3
#RAID的配置文件
/etc/mdadm.conf 的文件主要提供我們方便管理,編輯這個文件可以讓RAID更好的為我們工作,當然這個步驟不是必要的.不經過編輯配置文件也可以讓RAID工作。
首先掃描系統中的全部陣列
# mdadm --detail -scan
ARRAY /dev/md0 level=raid5 num-devices=3 UUID=37230e69:51bcf476:9889f244:18b07644
devices=/dev/sda,/dev/sdb,/dev/sdd,/dev/sdc
# vi /etc/mdadm.conf
-------------------------------------------------------------------------------------------------------
DEVICE /dev/sdb1 /dev/sdc1 /dev/sdd1
ARRAY /dev/md0 level=raid5 num-devices=3 UUID=37230e69:51bcf476:9889f244:18b07644
devices=/dev/sda,/dev/sdb,/dev/sdd,/dev/sdc
-------------------------------------------------------------------------------------------------------
其中的資料就如同 mdadm --detail -scan 一樣定義了RAID基本資料.
如果你不想手動設定用下面的指令同樣也可以.
mdadm --detail -scan >> /etc/mdadm.conf
#RAID的管理
mdadm /dev/md0 --add /dev/sdd1
mdadm /dev/md0 --fail /dev/sdc1
mdadm /dev/md0 --remove /dev/sdc1
mdadm --manage --run /dev/md0 重建指令 !!小心使用!!
#spare-group
#Multipath
mdadm -C /dev/md0 --level=multipath --raid-devices=2 /dev/sda1 /dev/sdb1
ARRAY /dev/md0 level=raid5 num-devices=5 metadata=00.90 spares=1 UUID=90dcc677:e6ef7c62:9baf8322:4f9d823d
ARRAY /dev/md1 level=raid5 num-devices=5 metadata=00.90 spares=1 UUID=981e1b70:736d1fb5:9baf8322:4f9d823d
Ref.
訂閱:
文章 (Atom)