Tuesday, August 18, 2009

[Level 2] OpenSolaris new feature and ZFS hands-on step by step.

I have a hands-on lab tonight (8/17) in Gjun.
The allowing the the cheat sheet of the ZFS...

[[ ZFS fundamental management ]]
***************************************************
***************************************************
[Disk pool management]
1. check disk:
# devfsadm
# iostat -En
# rmformat
# format


2. Create disk pool:
2-a. create mirror:
# zpool create -f -m /zfs/mirror test_pool mirror c0t1d0 c0t1d1 mirror c0t1d2 c0t1d3 spare c0t1d4
2-b. create raidz:
# zpool create -f -m /zfs/raidz raidz_pool raidz c0t1d0 c0t1d1 c0t1d2 spare c0t1d3
2-c. display pool constructor only
# zpool create -n test_pool mirror c0t1d0 c0t1d1 mirror c0t1d2 c0t1d3 spare c0t1d4


3. list pool information:
# zpool list
# zpool status [-x]
# zpool iostat -v test_pool 5


4. get/set pool parameters:
# zpool get all test_pool
# zpool set autoreplace=on test_pool


5. export/import pool
# zpool import [-f] test_pool
# zpool export test_pool


PS. use local file to create pool ( for test only... )
# mkfile 64m /tmp/f1 /tmp/f2 /tmp/f3
# zpool create -f test_pool mirror /tmp/f1 /tmp/f2 spare /tmp/f3


***************************************************


[ZFS File system operation]
1. create ZFS:
# zfs create test_pool/fs1
# zfs create -p test_pool/a/b/c
# zfs create -o mountpoint=/mnt/fs1 test_pool/fs1


2. get/set zfs parameters:
# zfs get all test_pool/fs1
# zfs set compression=on test_pool/fs1
# zfs set quota=10G test_pool/fs1
# zfs set reservation=1G test_pool/fs1
# zfs set mountpoint=/temp/mirror_dir test_pool/fs1
# zfs set mountpoint=legacy test_pool/fs1 => mount -F zfs test_pool/fs1 /mnt/fs1
# zfs set mountpoint=none test_pool/fs1


3. ZFS snapshot/rollback/clone/promote:
# zfs snapshot test_pool/fs1@20090817
# zfs rollback test_pool/fs1@20090817
# zfs clone test_pool/fs1@20090817 test_pool/fs2
# zfs promote test_pool/fs2
PS.
# zfs set snapdir=hidden|visible test_pool/fs1


4. time slider
# svcs -a *auto-snapshot*
System -> Administration -> Time slider -> Enable Time Slider -> Advanced Options -> Custom
Start nautilus -> Restore -> scoll the bar
[[ Lab1 ]]
***************************************************
***************************************************
Please create the environment to fit following request:
* create a mirror disk pool with three disks and one of the disk must be hotspare.
* change the pool mount point as /mnt/mypool.
* create a ZFS file system as mypool/fs1
* create a file named f1 on mypool/fs1
* create a snapshot on mypool/fs1 with snapshot name s1
* clone a file system name mypool/c1 from above snapshot
* user promote sub command to replace s1 from c1




[[ create easy NAS. smb + nfs + ftp ]]
***************************************************
***************************************************
[ setting SMB client/server]
ref:
http://docs.sun.com/app/docs/doc/820-2429


0. stop samba server
SMB server and samba server cannot run at the same time,
and must to stop samba server first.
# svcs *samba*
# svcadm disable svc:/network/samba
# svcadm disable svc:/network/wins


1. install SMB server packages
System -> Administration -> Package manager
and search with the key word "smb"
Checked the package "SUNWsmbs, SUNWsmbskr", and click the button Install/Update
After install the packages and reboot server
# init 6


2. start SMB server, setting PAM and join WORKGROUP.
# svcadm enable -r smb/server
add the line below into /etc/pam.conf
" other password required pam_smb_passwd.so.1 nowarn "
PS. From now on, when you use the command "passwd" will update the samba password,
but you have to set the password again with exist users.
# smbadm join -w WORKGROUP


3. start SMB client
# svcadm enable -r smb/client


4. set SMB workgroup username/password
# pfexec su - (root/opensolaris)
# mkdir -p /export/home
# useradd -m -d /export/home/stanley stanley
# passwd stanley (stanley123)
PS. samba password will save in /var/smb/smbpasswd


5. Setting file share with SMB protocol
5-1. create ZFS
# zfs create -o casesensitivity=mixed -o nbmand=on rpool/nas
The first option -o let ZFS be case-insensitive in UINX and case-insensitive in Windows.
The second -o let ZFS and support both locks(Locking) with SMB and NFS.


5-2. user ZFS command to share file in SMB protocol
# zfs set sharesmb=name=nas,rw=@192.168.1.0/24 rpool/nas
# smbutil view //stanley[:stanley123]@smb_server, if not assign password ":stanley123", will occure password request


5-3. use command sharemgr to share file
create share group
# sharemgr create nasgrp
add folder in share group
# sharemgr add-share -s /tmp -d "tmp folder" -r tmp nasgrp
# sharemgr set -P nfs -p anon=0 nasgrp
check share status
# sharemgr show -vp


6.
a. OpenSolaris
a-1. use GUI tools
Places -> Connect to network
Service type: Windows share
Server: smb_server
Share: rpool_share
Username: stanley
and then click the button "Connect"
a-2. use command mount
# mount -F smbfs //stanley[:stanley123]@smb_server/nas /mnt
b. Windows
start -> execute
\\smb_server\


7. check SMB server status
# smbstat -i


8. remove share folder
# sharemgr remove-share -s /tmp/nasgrp nasgrp
# sharemgr delete nasgrp
# sharemgr show -vp


***************************************************
***************************************************


[ setting nfs]
1. check NFS services
svcs *nfs*
2. start NFS services
svcadm enable -r nfs/server
3. setting share with NFS
3-1. start NFS
# zfs set sharenfs=rw=@192.168.1.0/24,root=@192.168.1.0/24 rpool/nas
# zfs set sharenfs=on pool_name/fs
# sharemgr set -P nfs -p anon=0 nasgrp
4. cancel NFS shares
# zfs set sharenfs=off pool_name/fs


***************************************************


[setting ftp]
1. check ftp service
# svcs *ftp*
2. ftp service
# svcadm enable ftp
3. disallow listftp server
/etc/ftpd/ftpusers




[[ Lab2 ]]
***************************************************
***************************************************
creNAS system:
* This server must use SMB and share solaris files in Windows.
* create user who an syncolize the password between MS.
* (LAB1 continue...)create mypool/samba_shareZFS system
and set mount pon/samba_share, and use command(zfs) to create SMB.
* use zfs command to share nfs file system
ftp FTP server.