=======Configuration of NFS share storage for VMWARE/Citrix by using FreeBSD with ZFS ======= ==== Introduction. ==== Recently we have moved our virtual infrastructure to VMWARE vSphere5. As a result old servers became free and space on the storages for VMWare became necessary. (Also we have tested Citrix %%XenServer 6%%) \\ Storage requirements: * availability of export NFS over TCP (vmware and citrix can connect to NFS share only with TCP ) * availability of snapshot creation. * availability of backuping snapshots to another server.\\ As a possible solution we decided to use %%FreeBSD%% 9.0 with ZFS and NFS. ==== Configuration ==== This [[http://wiki.freebsd.org/RootOnZFS/GPTZFSBoot/9.0-RELEASE|article]] is in detail describing process of deploying of %%FreeBSD%% 9.0 on a ZFS. Therefore we will focus only on configuration of ZFS, NFS and spapshot creation/backup script.\\ We deploy the %%FreeBSD%% on two servers. The first one will be called NFS and the second one will be called backup-server. **Don't forget to configure ntpd on both servers.** ==== ZFS ==== Creation of zfs pool rpool RAID5 zpool create rpool raidz1 /dev/ada2 /dev/ada3 /dev/ada4 Checking zpool status pool: rpool state: ONLINE scan: none requested config: NAME STATE READ WRITE CKSUM rpool ONLINE 0 0 0 raidz1-0 ONLINE 0 0 0 ada2 ONLINE 0 0 0 ada3 ONLINE 0 0 0 ada4 ONLINE 0 0 0 errors: No known data errors Creation of partition for VMWARE zfs create rpool/vm-store **Don't forget.** You should set zfs option that is described below for normal speed i/o providing. zfs set sync disabled rpool/vm-store more details about zfs tuning you can find in this [[http://wiki.freebsd.org/ZFSTuningGuide|article]] ==== NFS === **/etc/exports**\\ /rpool/vm-store -maproot=root IP1_VMWARE IP2_VMWARE IP3_VMWARE **For Citrix XenServer use\\ /rpool/vm-store -alldirs -maproot=root IP1_VMWARE IP2_VMWARE IP3_VMWARE** Add following lines to the file **/etc/rc.conf** nfs_server_enable="YES" rpcbind_enable="YES" mountd_enable="YES" rpc_statd_enable="YES" rpc_lockd_enable="YES" nfs_server_flags="-t -n 10 Start nfs: /etc/rc.d/nfsd start Mount partition in VMWARE or Citrix ==== Snapshot creation ==== you need to: * on the backup-server allow root ssh access file: /etc/ssh/sshd_config PermitRootLogin yes * on the NFS server allow password-free access from NFS server ssh-keygen -t rsa ssh-copy-id root@backup-server Create manually the first snapshot on NFS server and backup one to backup-server zfs snapshot rpool/vm-store@`/bin/date "+%Y%m%d"` zfs send rpool/vm-store@`/bin/date "+%Y%m%d"` | ssh park-nfs-node-backup zfs recv -Fuv rpool/vm-store@`/bin/date "+%Y%m%d"` Below is the simple script. One time per day it makes snapshot and sends it to backup-server incrementally. Snapshots are stored on a NFS-server within 3 days and within 30 days on a backup-server. Requirement is to start script at the next day after first snapshot was created. Also the script doesn't provide workability in cases of breaks in work that last more than one day. **createandsend.sh** #!/bin/sh num=`/bin/date "+%Y%m%d"` numm=`/bin/date -v-1d "+%Y%m%d"` days=`/bin/date -v-30d "+%Y%m%d"` onlinedays=`/bin/date -v-3d "+%Y%m%d"` #creating snapshot /sbin/zfs snapshot rpool/vm-store@$num /bin/sleep 20 /sbin/zfs send -i $numm rpool/vm-store@$num | /usr/bin/ssh backup-server zfs recv -Fuv rpool/vm-store@$num #destroying snapshot /sbin/zfs destroy rpool/vm-store@$onlinedays /usr/bin/ssh backup-server zfs destroy rpool/vm-store@$days Add this script to cron to start one time per day\\ ==== Testing ==== 1. Mount partitions to vmware nodes. 2. Creation of testing VM We have deployed VM win7 x86 with thick disk 40GB. Also we have installed [[http://www.passmark.com/products/pt.htm|Performance Test]] on the VM 3. Results of tests About the author https://www.linkedin.com/pub/alexey-vyrodov/59/976/16b {{:ru:jobs:perfresnfszfs.jpg?700|700}} ==== About author ==== [[https://www.linkedin.com/pub/alexey-vyrodov/59/976/16b|Profile]] of the author