1、首先到FreeBSD下载最新版的安装包
https://www.freebsd.org
我的版本是12.0
并创建两个虚拟机:FreeBSD1、FreeBSD2
2、修改Root的SSH权限
#vi /etc/ssh/sshd_config
将PermitRootLogin 的值设为 yes
3、修改FreeBSD源
创建:
/usr/local/etc/pkg/repos/FreeBSD.conf
内容:
FreeBSD: {
url: "pkg+http://mirrors.ustc.edu.cn/freebsd-pkg/${ABI}/quarterly",
}
运行:pkg update -f
4、安装VIM
pkg install vim
5、在FreeBSD1中安装如下配置SSH
创建文件:~/.ssh/config
内容:
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
IPQoS lowdelay throughput
6、配置免密登录
在客户机运行:
ssh-keygen -t rsa -P ''
scp .ssh/id_rsa.pub root@目标服务器:/root/.ssh/authorized_keys
7、在FreeBSD配置一个4GB大小的 ZFS ISCSI
zfs create -s -V 4G -b 4k zroot/testtarget
修改/etc/rc.conf
/etc/rc.conf
内容:
portal-group san {
discovery-auth-group no-authentication
listen 192.168.x.x
}
target iqn.2014-05.com.example:target0 {
auth-group no-authentication
portal-group san
lun 0 {
path /dev/zvol/zroot/testtarget
blocksize 4096
size 4G
}
}
运行:
chmod 600 /etc/ctl.conf
service ctld start
8、创建快照并发送到FreeBSD2
zfs snapshot zroot/testtarget@test1
zfs send zroot/testtarget@test1 | ssh 192.168.31.47 zfs receive zroot/testtarget@test1
zfs snapshot zroot/testtarget@test2
增量:zfs send -i zroot/testtarget@test1 zroot/testtarget@test2 | ssh 192.168.31.47 zfs receive zroot/testtarget
9、从FreeBSD2恢复
按照FreeBSD的方法配置ISCSI
修改/etc/rc.conf
重点:iqn.2014-05.com.example 这一行必须与FreeBSD的配置一样
/etc/rc.conf
内容:
portal-group san {
discovery-auth-group no-authentication
listen 192.168.x.x
}
target iqn.2014-05.com.example:target0 {
auth-group no-authentication
portal-group san
lun 0 {
path /dev/zvol/zroot/testtarget
blocksize 4096
size 4G
}
}
运行:
chmod 600 /etc/ctl.conf
service ctld start