Showing posts with label SPR720 NesShell. Show all posts
Showing posts with label SPR720 NesShell. Show all posts

Sunday, January 3, 2010

iSCSI/NFS on LVM on RAID5 (Software RAID) howto guide, CentOS 5.3

This is just a quid blog to show howto, cos I found there are not much on-line tutorial cover this in a easy way.

And of course, as I keep it simple, it only cover basic stuffs. Please feel free to comment and add on better approach.



## RAID ##
===============================
Links:
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch26_:_Linux_Software_RAID

= Create Partition with 'fdisk'
to create partition (with 'n')
modify the partition's label to RAID (with 't', and code is fd)
then 'w' to write the partition
repeat until the disks is done
do a 'partprobe' to make sure it's written and take effect
do 'fdisk -l' to make sure the partition tables is correct

= Assign disk to raid
mdadm -C -v /dev/md0 -l5 -n3 /dev/hdb1 /dev/hdc1 /dev/hdd1
# l5 => RAID 5, n3 => a RAID set of 3 disks
cat /proc/mdstat # make sure RAID is created. it will also show if it's sync-ing or recoverying
mdadm -D -s -v # Double check. or 'mdadm -D -s -V /dev/md0


## LVM ##
===============================
Links:
http://www.howtoforge.com/linux_lvm_p3

= Create Physical Volume(PV), Volume Group(VG) and Logical Volume(LV)
pvcreate /dev/md0 # assign "/dev/md0" as an PV
pvdisplay # make sure they're all set
vgcreate vg-raid /dev/md0 # create VG group "lvm-raid"
vgdisplay # Show the Volume Group status
lvcreate -n xStorage -L 40G vg-raid # Create a LV as xStorage, 40G from vg-raid
lvdisplay # Show Logical Volume status
ls /dev/vg-raid/xStorage # The created LV should be here..
mkfs.ext3 /dev/vg-raid/xStorage # format the LV to be used
mount /dev/vg-raid/xStorage /mnt # lets test if we could mount it. :-)
df -h # You should see it in your mounted list

## iSCSI ##
===============================
Links:
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html

= Installation
yum -y install scsi-target-utils iscsi-initiator-utils
chkconfig iscsid on
chkconfig iscsi on
chkconfig tgtd on
chkconfig --list | grep iscsi
chkconfig --list | grep tdtd
/etc/init.d/iscsi restart
/etc/init.d/tgtd restart
/etc/init.d/iscsid restart

= Configuring iSCSI Target (iSCSI Server)
tgt-setup-lun -d /dev/vg-raid/xStorage -n xStore 192.168.1.4 # create lun only accept client with IP 192.168.1.4
#*** NOTE: You can only setup lun with a device, not partition!! ***#
tgtadm --lld iscsi --op show --mode target # Show alll luns
iscsiadm --mode discovery --type sendtargets --portal 192.168.1.4 # List lun from the server
Change iptables:
iptables -I RH-Firewall-1-INPUT -p tcp -m tcp --dport 3260 -j ACCEPT # Open the port to all NIC
iptables-save > /etc/sysconfig/iptables # Save the updated rules to iptables configuration file

= Configuring iSCSI Initiator (iSCSI Client)
iscsiadm -m discovery --type sendtargets --portal 192.168.1.4 # Check if the iSCSI Target is accessable
iscsiadm -m node -T iqn.2001-04.com.NesSAN-xStore -l # -l to login to target, -u to logout
# add '--portal 192.168.1.4:3260' for specifid server
ll /dev/sd* # The new disk should be now there.
mount /dev/sdc /mnt # Lets mount it..
df -h
touch `hostname`-`date +%Y%m%d-%H%M%S` # Test if it's writable and if it's sync over the network


## NFS ##
===============================
Links:
http://www.cyberciti.biz/tips/howto-setup-linux-iscsi-target-sanwith-tgt.html


echo '
# Local Mount Name # Client Access List
/mnt 192.168.1.0/24(rw,no_root_squash,sync)
' >> /etc/exports

exportfs -a
/etc/init.d/nfs restart # Restart nfs mount

Sunday, November 1, 2009

BASH: Using untyped variable to get unlimited parameter

I have been working a backup script at work that support MySQL, PostgreSQL and file using mysql_dump, pg_dump and duplicity commands. Since the script will be running parallel, the script will be calling up itself a lot, I need a better parameter parsing. And I absolutely do not want to use 100 lines of code to do such simple task. It will be so hard to maintain. And when I was trying to improve my parameter parsing, I found something called "untyped variable". I am not sure if it's a proper name.

Anyway, the whole point of doing this is: you do not have to use a lot of if conditions or case to sort variable one by one. You can just put the variable name in a loop, and it will parse out all recognized variable names.

I am using 'eval' to assign the values into variables. I was originally using 'export'. And I know there is actually some other way to do some, something like $($OPT)=$FIELDS, but somehow it didn't work for me. :-(


Using 'eval' to assign.
eval $OPT=$FIELDS


Parsing all variables and values

# Define all acceptable variable names here
ALL_OPT=(Type Host Pass User DB Table MaxTry BackupDir Src Dst Port sshUser Period dbExtra)

for WORD in $@ ; do # $WORD is the name of variable,
for OPT in ${ALL_OPT[*]} ; do # Check if I have the option in the list
FIELDS=""
case $WORD in
$OPT=?*) # To make sure it has '=' and at least one character after '='
FIELDS=${WORD:`echo ${#OPT}+1 |bc`} # grap the value
eval $OPT=$FIELDS # Assign the variable to
echo " export $OPT $FIELDS"
;;
Report)
echo "calling up Report"
bkReport
break
;;
esac
[ "$FIELDS" == "" ] || break # no value at all
done
done


Display all variable names and value

for OPT in ${ALL_OPT[*]} ; do
eval aaa=\$$OPT
echo $OPT = $aaa
done



Calling up the function

# Define all function names, which is the accepted variables value in first variable in ALL_OPT
ALL_TYPE=(Mysql File MySql Redmine)
[ $Type == "NULL" ] || for TypeCHK in ${ALL_TYPE[*]} ; do
if [ $Type == $TypeCHK ] ; then
ChkPeriod $Period
[ $? == 0 ] && bk$Type # Of course, you have to have the function, e.g: 'bkFile'.
fi
done


All codes

Monday, November 17, 2008

0.2 Relase Contributions - De-Luxer Community

It's almost the end of semester. I'm so glad that I'm doing LUX in Seneca@york. All my classmates are friendly and nice. We're like a small group of community, we help each other to learn and acheive our goals.

I'm so glad to meet Milton and Mohak. They helped me a lot on my LUX Project and the arcade project. Of course, I gave them some help too. Beside them, I also helped Steven Liang a little bit on his project. Since we don't speak perfect English, we try to help each other to understand what we miss in class and things for our projects.

I heard that next sem is gonna be tough on project. I've gotta finish my functions this month, so I can work on the GUI next sem.. ^^

And good luck on your project guys...

SPR720 Lab - Homebrew python game: GuessGuess(PG)

Love python... cos I don't need to spend too much time on setting variable type so i can have time to really do programing. Compiler is so helpful and style. And the most important thing is, it's cross platform!

So, here is the game I modify from the lab material... make sure you got your parents with me when you're playing it.. hehe.. you'll know...

http://matrix.senecac.on.ca/~tnchan/spr720/

Tuesday, November 11, 2008

Windows Data Migration Tools - Recusive! yahoo!!!

I've been doing my last flag for copy/moving user document function, which is comparing souce and target file and only copy the newer one from souce. It should check all sub-directories also. I was thinking to use os.path.walk, cos when i was talking in irc, someone told me to use it. So i go ahead... and.. here it came the nightmare.

I started coding this ReplaceOld function since 6am this morning.. I couldn't get it done after 4 hours of struggle, cos os.path.walk, dosen't allow me to do what I want. I need to go back to parent directory any time I want and I need the path after the source path. If I keep using this function, I may need to use nested array, which is headache and will use a lot of resources and do a lot of coding too.....

And this morning... finally, i figured out what to do... (on the way to washroom.. lol )...

RECURSIVE FUNCTION!!!

Yes!! so, i dun have to assign a lot of array and just call up the function itself, that's it! As long as my calculate is right, it'd be okay. To me it's just something like an other "for..." loop. And it works!!

But of course, this function is not completed yet. But I'm still so excited! Hope I can finish this function before this week. Then I can move on other functions... ^^

Last night, I started coding from 7pm last night to 7am.. oh yeah.. 12 hours of programing.. hehe... I got 400 lines done so far. And if I'm done with this function, I have 3 totally working functions which included a lot of error flag checking already. And I've got a very smart design of flag sorter/reader function from someone's code on net.

Can't wait to see it? Wait for my WDMT 0.2 release! ^^

Monday, November 3, 2008

Windows Data Migration Tool - Plan for 0.2 Rlease

After researching on Windows XP, Vista system, I think it's time to do some actual coding.

I'm planning to write all the codes for user and directory handling. Which included user search and create, directory search and create. The functions sounds complicated but the concept is easy. All it will do is list vista/xp home directory and generate a list, administrators files will be moved to root in linux.

The program will be writen in multiple function format, in one big python code files. User will be able to run the program with running "wdmt" with flags. It may not have full support in 0.2 release, but may able to handle basic user search and folders functions.

Please refer to my wiki for detail informations...

Windows Data Migration Tool in Fedora Project

Windows Data Migration Tool in Seneca Open Source Wiki

Tuesday, October 7, 2008

MUM!!! I'm on TV!!! (Live)





Hey, mum!! I'm on tv!! well.. maybe youtube. So, at this moment, rpm speech is going in the class. ^^ BRB for more update

Monday, October 6, 2008

Install Wormux from source


Wormux is a open source game that support multi-platform system, since it's open source. And I believe it was build for linux, since it's even more complicated if you install it in Windows.

The installation was not easy at all, since I'm running a basic configured Fedora 9. I had to install a big amount of library files. I can't even find some of them even if I followed the instrucations. But I decided to go ahead and try it. The funny thing is when I run make it shows some of the lib files are optional. And after I did "make install" there was a lot of messages but no successfull message and I was guessing it was failed. But then i tried "which wormux" I found it was installed already! So, I ran the game and the game GUI pop up after 2 seconds!! IT WORKED!!! OMG...

I didn't really try to play this game, since I don't have much time. Now, I'll need to package it. ^^

Tuesday, September 30, 2008

SPR720 my madwifi driver..

I've been trying to install my Athero 5700 wifi driver in my fedora, but it always fails. Since I had a experience of successful installing HP laptop wifi driver in Ubuntu, so I install Ubuntu today.

I spend less than 1 hours to install ubuntu. Then i tried to install my driver in my fedora mount under ubuntu, but maybe there is soem permission problem, it didn't install. So, I copy the tar file to my root directory and install it there. It works like a charm. I don't even need to modify the kernel path or any thing.

Well... it was too soon to be happy. 'cos somehow the wifi still dosent' work. I upgrade Ubuntu to the most update version already. But NetworkManager still dosen't recongnize it. Why?? but why??? I'm start feeling so frustrated about Linux... But.. of course I won't give up. I've gotta learn, since I'm takign this course now...

Monday, September 29, 2008

SPR720 Failed in first trial

The lab was about unpacking a source package and install it. I tried to do it with my wifi driver. One stone two bird. I'm smart, huh? em.. not really...

I can't make install, 'cos it has problem with some library files and need kernel source. I made sure i got kernel header, then i even have the whole kernel souce. Still failed... I tried to make the source code, failed also... sigh.. nothing works. I started to hate Fedora... ;-p

But I'm gonna install some game, 'cos i heard it's easy, hehe... so be it.. wait for my good news.. ^^

Tuesday, September 23, 2008

2:30..

i give up... @@ good news is matrix didn't crash... i think i just have a bad day... ;-p

Birthday time, codding time.. ;-p

I have been working in the lab for lab work today. The last one I was doing was the bash script lab for SPR720. Since I still have one hour to work until the lab close at 10:30pm, so, I decide to give it a try, 'cos I have to work 10am and maybe finish at 1am at night.

But, guess what? The terminal just shut down itself after I tried to edit one line in vi... it just shutdown itself. I wasn't sure if it supposed to be like this, since it was 10:45pm already. I was thinking to give up this 1% lab. and get more sleep for work... but.. you know what? i'm not gonna give up!

I've just got home. I work tomrorow at 10am, need to wake up at 9am. So, I can went to bed at 3am, i'll still have 6 hours sleep, which is enough for me to work for my morning shift, 10am to 3pm. So, i'm gonna try it!! It's my birthday, I don't think i'm that unlucky.

Plus.. I've came up an idea... Instead of using my own machine to try the script. I'll store my code in my laptop and run it in matrix... ;-p How many matrix PC will I crash tonight? hehe...

I'm sure I'll have a lot of fun too.. kekee...

Sunday, September 7, 2008

SPR720 Lab1

I'm not sure if I need to post all 25 commands here.. so i just post what I think after I read about 30 commands.

The first thing I checked out was yum and other 3 yum related commands that's in Fedora. I was su surprised about yum when I first used it. I think i over heard someone show my workmate about yum 5 years ago at work. But I didn't pay attention about it. But once I've got my Linux and Milton shows me about Yum. I really love it. Yes, I love Yellow Dog Updater, hehe...

And I found the linux/unix commands has changed a lot. Before, we always have command with single character parameter to customise the command to suit our need. But now, instead of using hard-to-understand code, new programs/commands tend to use whole string instead. For example, xlogo, xload, etc. But why? for user friendly? or for better paramater input/put to GUI?

Then I found there is a lot of GUI command that store in /usr/bin. I found a command called "animate". I guess this program was developed few years ago, 'cos the GUI is kinda old school.

Man... over 3000 commands in my /usr/bin.. how long will it take to master them? And how many of you has master all of them?

Thursday, September 4, 2008

SPR720 NesShell

first post for SPR720...