NFS:
前几天搞了linux的NFS,今天搭建freebsd的NFS,对比之下,freebsd下简单的多得多了!
服务器端(192.168.30.1):

vi /etc/rc.conf

1
2
3
4
rpcbind_enable="YES"
nfs_server_enable=”YES”
nfs_server_flags="-u -t -n 4"
mountd_flags="-r"

vi /etc/exports

1
2
3
/home -alldirs -maproot=root 192.168.30.7 192.168.30.8
/usr/sbin/nfsd -u -t -n 4
/usr/sbin/mountd -r

客户端(192.168.30.7,192.168.30.8):

vi /etc/rc.conf

1
2
3
nfs_client_enable="YES"
showmount -e 192.168.30.1
mount 192.168.30.1:/home/myproject /home/myproject

自动挂载

1
2
vi /etc/fstab
192.168.30.1:/home/myproject /home/myproject nfs rw 0 0

重新启动nfsd,mountd,我都是直接kill掉,然后启动,不知有没有简单方法

rsync 同步:
服务器端(192.168.30.1):
1安装

1
2
#cd /usr/ports/net/rsync
#make install clean

2配置
vi /usr/local/etc/rsyncd.conf
内容:

1
2
3
4
5
6
7
8
9
10
11
12
13
pid file = /var/run/rsyncd.pid
use chroot = yes
max connections = 4
log file = /var/log/rsyncd.log

[test]
path = /home/test/
auth users = root
uid = root
gid = wheel
hosts allow = 192.168.30.7,192.168.30.8
secrets file = /usr/local/etc/rsyncd.pub.secrets
read only = no

vi /usr/local/etc/rsyncd.pub.secrets
内容:

1
2
root:123456  #这里设置用户和密码
chmod 600 /usr/local/etc/rsyncd.pub.secrets #必须设置权限为600

/usr/local/bin/rsync —daemon

客户端(192.168.30.7,192.168.30.8):

安装:

1
2
cd /usr/ports/net/rsync
make install clean

配置:
vi /usr/local/etc/rsync.pub.key
内容:

1
2
123456    #这里只需填写密码,不要写用户
chmod 600 /usr/local/etc/rsync.pub.key

开始同步

1
/usr/local/bin/rsync -azrtopguL root@192.168.30.1::test    /home/bakup —password-file=/usr/local/etc/rsync.pub.key

添加到crontab,做计划任务,每半小时执行一次,

1
/30 *  /usr/local/bin/rsync -azrtopguL root@192.168.30.1::test    /home/bakup —password-file=/usr/local/etc/rsync.pub.key

————————-分割线————–

centos 下 rsync 客户端
A、安装:

1
2
3
4
5
tar -zxvf rsync-3.0.3.tar.gz
cd rsync-3.0.3
./configure
make
make install

B、添加密码文件
vi /etc/rsyncd.scrt #没有就新建
内容如下:

1
123456 (文件与服务器端认证文件不一样)

服务器端认证文件内容是:

1
root:123456

C、改文件权限为600

1
chmod 600 /etc/rsyncd.scrt

备份命令格式:

1
rsync -avz —password-file=密码文件路径 username@需要备份的主机IP::备份里的模块名称

例如:

1
2
rsync -avz —password-file=/etc/rsyncd.scrt wwyhy@192.168.1.201::testlink
/home/wangwei/testlink/upload_area