Showing posts with label NAD810. Show all posts
Showing posts with label NAD810. 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

Saturday, July 4, 2009

The easiest way to setup the most unsecure sendmail service in linux

Yes, the easiest way, and yes, the most unsecure, i mean it.

I hope this blog will help you. This is what I've found after 2 days of reading and frustration of trying to set up sendmail server/client for whole day.

And trust me, never setup sendmail on Friday... @@



--- Setup Sendmail ---

-- Server --
#vi /etc/mail/sendmail.mc
= Replace 192.168.168.1 with your mail server's IP.

DAEMON_OPTIONS(`Port=smtp,Addr=127.0.0.1, Name=MTA')dnl
DAEMON_OPTIONS(`Port=smtp,Addr=192.168.168.1, Name=MTA')dnl

## and...
= find "relay_based_on_MX" and comment or replace it with "loose_relay_check"

dnl #FEATURE(`relay_based_on_MX')dnl
FEATURE('loose_relay_check')dnl

# then..
echo "Connect:192.168.2 RELAY" >> /etc/mail/access

-- Client --
# find following line in sendmail.mc and change it.
[root@bb ~]# grep mail000 /etc/mail/sendmail.mc
define(`SMART_HOST', `mail0001.test')dnl


-- MAKE SURE --

= check if sendmail is listening to port 25
netstat -ant | grep LISTEN | grep 25

= check local or the service connect by telneting the port
telnet mail0001 25

= check sendmail status
service sendmail status


--- Links ---
-- Howto --
http://www.linuxhomenetworking.com/wiki/index.php/Quick_HOWTO_:_Ch21_:_Configuring_Linux_Mail_Servers

-- Masquerading --
http://www.brandonhutchinson.com/Sendmail_masquerading.html

-- Mail Relay --
http://www.sendmail.org/m4/anti_spam.html

PS:
Here is the story be hide this post. Has any one found that the documentation of sendmail is a mess?? I always found it overwhelm, all the tutorial gives you some options that you may not even understand. That's why, I think it's good to setup the most basic one and then build stuffs on top of it. Making a service work is more important than any thing after all. Well... the worst thing about the way I setup is someone may use you mail server to send spam.... well... u lose some resources cos people may use it to send spam but, you can setup other options once you make sure every thing is working.

20090723
When I read this page again, I found that the reason why I could send it, it`s because I have already accept all my internal network. After doing more configuring with sendmail, I realize it wasn`t a fully open relay. I now have SSL configured with sendmail and dovecot. I may post the tutorial later, once I`m sure that`s really working and it`s the simplest way to do.

Wednesday, March 18, 2009

How many VMs can my Asus EEE PC handle?? 2?? no.. 4?? em... hehe..




Intro:
I've been working on my NAD project with vbox's vms.. i'm really curous what this little single core cpu machine can do. Here is the config..

Asus EEE
- 2G Ram (MAX for eee)
- Fedora 10
- fresh boot
- laptop mode (as real ram as much as possible, instead of swap)
VMs
- 4 F10 with 256 ram, 4mb Video ram, text mode (init 3)
- 1 F10 with 512 ram, 12mb Video, X windows

Assumption:
- F10 host (Asus EEE) fresh boot with X running use about 500-700mb
- One F10 VM in text mode use around 250Mb
- idealy
- total 2gb ram means I can use at least 5 Vms.. (700+(250*5))
- when the VM in text mode and idle, it use 5-15% CPU
- start all VMs one by one to reduce run time and chance of crashes

Result:
- IT WORKS!!! 5VMs running smoothly!!
- impressive!!
- it use some swap but.. well.. cos the last one was 512mb F10..
- it may able to run 6 VMs smoothly if I have 2 more 256mb ram F10
- really impressive!!
- if it has service running (httpd, dns).. it may use a bit more memory... and a lot more CPU. using a 'find' command use 60% host CPU already!
- it may able to handle 6VMs or even 7VMs in text mode and still have an acceptable performance. even with some simple service on and those are not busy services..
- it's perfect for testing...
- it's absolutely impressive!!!! ;-p

Adding a bridge NIC(virbr, br, pan) in Fedora 10(F10), purely command lines..

I've been using Virtual Box for a while and love it. But the downside of vbox is you can not use your NIC's alias as the bridge or interface. So, I found out a way to add a bridge NIC in pure command mode. Since there is no such tutorial online, I would love to write this down and share with you. This is just a short tutorial that to show you create a virtual NIC in command lines only.


========================================================================

brctl addbr virbr2
ifconfig virbr2 up
ifconfig virbr2

# now, record the MAC address of your Virtual NIC

vi /etc/sysconfig/network-scripts/ifcfg-virbr2
# and type all following lines in there,
# but modify 'HWADDR' as the MAC address
# and change the IP as you want.

TYPE=Ethernet
DEVICE=virbr2
HWADDR=B6:9F:39:E6:DC:64
BOOTPROTO=none
ONBOOT=yes
USERCTL=no
PEERDNS=yes
IPV6INIT=no
NM_CONTROLLED=no
NETMASK=255.255.255.0
IPADDR=192.200.200.2


# now, check if it's really working
# if it's successfull, the ip you typed before should be assigned
service network restart
ifconfig virbr2


========================================================================
then, your virtual NIC should be up and running after restart.


PS: i put a long title on purpose, so other people can google it. :-)

Monday, January 26, 2009

Disable root ssh...

I've been wanted to run my own testing server. Finally, I set it up today. Sign up an account in DynDNS.com. Set up some setting in my wifi router so it can update my dynamic IP regular. After some configuration, that's it! It was like 10mins work. ssh works, tunneling works, sftp works.. nice!

But of course, having a server that would let people connect to it is quite dangerous. Especially, it's my home network. I was lucky enough to see Professor Raymond Chan online.. oh.. i'm not gonna miss the chance, right? SO, I asked him the best way to setup the iptables. So, I drop all incoming, except ssh port. I'm gonna open port 80 so I can play apache server a bit. ^^ And on my router side, I set more security options in my router. I may setup a VPN or something, just incase if someone hack into my server. They can't access some of my Windows machine.

Then, did some testing from different network... from cdot machines, from my iPhone.. cool.. it worked! But connecting from iPhone needs some trick. The trick is have to make sure the iPhone has an IP first. It's kinda weired...

When I was testing the login, I almost forgot to test if I could ssh with root.. oh.. yeah.. gotta disable it. 30second search on net, found the disable root login. I would love to share with any one...

= First, make sure u have root privilege, u can either use "sudo" or "su -".. then...
vi /etc/ssh/sshd_config
= find the following line.. remove "#" and change "yes" to "no"
PermitRootLogin no
= save and test!!

That's it!

At this point, I'm not sure what I'll be testing on it.. Apache, of course.. I may set up a small Beowulf cluster if it's possible. I hope I'll able to run VM in this machine.. but this machine is only like 700mhz AMD CPU with 512 ram.. it'd be really slow to run VM.

Ideally, I should put this server in front of my home network. Set it as a router with strong firewall protection, put my home network be hide it. I don't have a real plan for this yet... Lets see if I have time for it... ^^