zoukankan      html  css  js  c++  java
  • OS + Linux File nfs / samba / rsync / inotify / smb / webdav

    s

    Linux NFS 和 Samba 共享配置

    http://blog.csdn.net/tianlesoftware/article/details/5752092

    Linux下的Samba和NFS服务区别

    http://www.2cto.com/os/201202/120703.html

    sam能解决win和linux,linux和linux之间共享,SMB协议MS,SMB高级特性和windows特性联系紧密.linux向windows靠拢才用smb,累赘而且力从心.

    比我debian,安装nfs-server和client只要800K, 安装smbclient要19M, 其差别显而易见.

    NFS更简洁,方便,更原生,兼容性更好.smb好处和windows集成,利用windows域等等

     

    samba是DEC开始开发的,用于在不同的Unix机器间进行资源共享,采用udp协议。后来基于tcp重新开发后,效率有了很大提高。它使用的协议是SMB。微软不愿意交License费,在windows系统中对该协议重新进行了实现。既然samba和windows中的网络邻居都使用SMB协议。那么,samba自然主要用于在windows和unix之间共享资源。资源包括文件、打印机等等。

    NFS是SUN开发的,用于UNIX机器之间的资源共享。其设置相当容易,主要是配置/etc/exports文件,然后运行exportfs -a来共享出来。现在NFS已经成为UNIX/LINUX上的标配。

    两者的文档都说自己的效率高一些:)从我的经验来看,nfs的效率要稍微高一些,只是差别不是太大。

    从配置来看,samba比较复杂,nfs比较简单。但是复杂有复杂的道理,它让我们能够灵活的配置

     

    Linux 挂载win硬盘

    http://www.iteye.com/topic/582755

    linux 下,不过ntfs格式的文件系统挂载不上,作后发现/lib/modules/2.6.*-*/kernel/fs/目录下没有ntfs格式支持文件,所以应该下载你系统内核版本对应的ntfs格式支持包,解决方案如下: 
    1、先查看你系统内核的版本 
    #uname -pr 
    2.6.18-92.el5 i686 
    2、打开下面的网址: 
    http://sourceforge.net/projects/linux-ntfs/files/ 
    找到与你内核版本相同的*.rpm包,下载到本地文件中! 
    3、安装*rpm包文件 
    rpm -ivh *.rpm 
    至此你就能挂载你的ntfs文件格式的分区,你还会在这个目录/lib/modules/2.6.*-*/kernel/fs/下面发现ntfs目录!

     

    Linux挂载ntfs分区

    http://ubuntu.group.iteye.com/group/blog/911132

    由于安装了linux和xp双系统,而linux又只能支持windows下的fat 和fat32文件系统。所以要将原本xp的ntfs分区上的资料想在 linux上使用,就得把ntfs分区的里的东西移动到fat分区里,然后再挂载。(偶比较懒,想想就在心里放弃这种做法了)。在网上查了一下,Linux支持ntfs文件系统的主要有两种方法,一种是下载和内核对应的支持ntfs的
    kernel-module-ntfs-2.6.18-92.1.10.el5-2.1.27-0.rr.10.11.i686.rpm包,
    一种是下载两个源码包编译安装。
    一开始按照第一种方法来,用uname -r 查看我的内核版本是2.6.18-194.el5,于是开始找kernel-module-ntfs-2.6.18-194.el5-**的rpm包,但是找了n遍都没找到,所以还是推荐大家使用第二种方法,
    这种方法需要gcc编译环境,故之前还需安装gcc
    具体操作步骤如下:
    1.挂载光盘镜像
    mount  -t iso9660 -o loop rhel-server-5.5-i386-dvd.iso  /tmp 
    2.从光盘镜像中安装rpm包(似乎是下面的顺序,具体可以看提示哈)
        kernel-headers-2.6.18-194.el5.i386.rpm 
        glibc-headers-2.5-49.i386.rpm 
         glibc-devel-2.5-49.i386.rpm 
        gcc-4.1.2-48.el5.i386.rpm 
    3.下载fuse(http://fuse.sourceforge.net/)
    编译fuse时需要内核源码,镜像里是有的,没有的可以baidu或google一下,下载。
    #cp kernel-devel-2.6.18-92.1.6.el5.rpm /
    #cd /
    #rpm2cpio kernel-devel-2.6.18-92.1.6.el5.rpm | cpio -div 
    这下可以了
    后面的安装都很简单
    #./configure
    #make
    #make install 
    然后
    #modprobe fuse 
    如果没有任何提示的话,恭喜你成功了!
    4.安装好fuse之后开始安装ntf-3g(http://www.ntfs-3g.org)
    很简单
    #./configure
    #make
    #make install 
    安装好了,该怎么使用呢?
    使用ntfs
    #mount -t ntfs-3g /dev/sda1 /mnt/c
    #mount -t ntfs-3g /dev/sda1 /mnt/c -o force
    #ntfs-3g /dev/sda1 /mnt/c -o force 
    以上三种都可以!

    Redhat 6.3 x64位系统 NFS Server 和 NFS Client的配置方法

    ==============NFS server 2 服务端配置,IP:10.37.20.77================================
    1.启动服务,并设置开机自启动
    /etc/init.d/rpcbind start
    /etc/init.d/nfs start
    rpcinfo -p localhost
    chkconfig nfs on
    chkconfig rpcbind on
    2.配置nfs服务,在NFS服务端,注意这里不要有空格,如:0/24(rw.sync)
    echo "/data2 10.37.20.0/24(rw,sync)" >> /etc/exports
    mkdir -p /data2
    chown -R nfsnobody.nfsnobody /data2
    chmod 777 -R /data2
    showmount -e localhost 重新加载NFS配置,检查有无报错
    exportfs  -rv 重新加载NFS配置,检查有无报错
    reboot使设置生效。或者不重启,使用/etc/init.d/rpcbind restart;/etc/init.d/nfs restart
    ==============NFS client 客户端配置,IP:10.37.20.78 / 81 / 83 / 88 / 92================
    客户端
    /etc/init.d/rpcbind start
    /etc/init.d/nfs stop     (客户端如果不安装nfs服务,没有showmount命令,但是不需要开启此服务)
    设置开机自启动
    chkconfig rpcbind on
    chkconfig nfs off
    准备挂载
    showmount -e 10.37.20.76 (检查NFS Server机器有无共享盘可挂载)
    mkdir -p /data1
mkdir -p /data2
    mount -t nfs 10.37.20.76:/data1 /data1 准备挂载
    echo "mount -t nfs 10.37.20.76:/data1 /data1" >> /etc/rc.local   设置开机自动挂载。
    echo "mount -t nfs 10.37.20.77:/data2 /data2" >> /etc/rc.local   设置开机自动挂载。
    注:当新加NFS Client机器共享data1、data2目录后,NFS Server机器最好chmod 777 -R /data1 一下。
    ====================================================================================

      

    两台 linux 机器之间mount 
    http://192.168.100.149/bbs/viewthread.php?tid=50&extra=page%3D1

    比如我有两条 linux 机器,192.168.1.1  192.168.1.2
    现在我要将 192.168.1.1 下的/opt/mydir 目录挂在到 192.168.1.2 /opt/mydir1 目录下。
    需要以下操作:
    1.服务器端 192.168.1.1 
      在/etc/exports 目下添加共享目录
      /opt/mydir 192.168.1.2(rw)
    /opt/mydir   hostname(rw)
    hostname  是指192.168.1.2 的hostname, 需要在/etc/hosts 中添加 hosts

    2.启动192.168.1.1 的nfs 服务
             /etc/rc.d/init.d/portmap start (在REDHAT中PORTMAP是默认启动的)
       /etc/rc.d/init.d/nfs start 启动NFS服务
       /etc/rc.d/init.d/nfs stop 停止NFS服务

    3.在192.168.1.2 上mount 目录
    #mount -t nfs -o rw 192.168.1.1:/opt/mydir /opt/mydir1

     

    范例二 :

    mount -t nfs -o soft,intr,timeo=5,sync 10.164.203.215:/vx/aepdata /home/aep/data

    参数说明:

    -t nfs 是指定文件系统类型为nfs 【nfs:UNIX(LINUX) 文件网络共享】

    -o options 主要用来描述设备或档案的挂接方式:

    上面命令 -o soft,intr,timeo=5,sync 意思是

    soft:如果服务器不响应,返回错误。缺省值是 hard。

    intr在硬安装时允许键盘中断。

    timeo=5,设置网络文件系统(NFS)超时周期是一秒的十分之 n,此例中也就是0.5秒。

    sync 同步文件更新

    10.164.203.21:/vx/aepdata nfs 源服务器地址和目录 

    /home/aep/data 本地挂载目录

    注意事项:

    注意,NFS客户机和服务器的选项并不一定完全相同,而且有的时候会有冲突。比如说服务器以只读的方式导出,客户端却以可写的方式mount,虽然可以成功mount上,但尝试写入的时候就会发生错误。一般服务器和客户端配置冲突的时候,会以服务器的配置为准。

    对于很多使用NFS做为文件共享或者备份使用的系统来讲,-O [soft,hard]这个参数是值得我们考虑的。他会影响到运行在UNIX上生产系统的一些核心的应用,包括在启动时,运行时的状态。比如HACMP在NFS不正常挂载的情况下,HACMP会一直HAND在那儿,直到NFS客户端正常挂载。还有 ORACLE会使其宕机。 

    为啥nfs server断开后client端偶尔会不响应及解决办法

    http://blog.sina.com.cn/s/blog_86ca10130100vhrb.html

    nfs server unavailable/unreachable后,client端偶尔会出现很诡异的情况:任何命令都跑不了/跑了没输出

    找到了个解决办法,mount nfs的时候option制动为 intr, soft就可以避免如上这种情况:

    intr: 默认情况下,当一个nfs 变得不可达后,在这个挂载点上的操作如ls、cd等会hang住。指定这个参数后,ls/cd之类的命令会收到信号EINTR 从而退出。

    soft: 默认情况下,如果nfs server断开了,client这端会不停的尝试重新恢复连接而不是断开,这样频繁的重试会导致系统hang住,但是为啥就不知道了。指定soft后,client会timeout抛出异常而不是一直傻试。

    autofs的使用 - 按需挂载nfs

    http://blog.sina.com.cn/s/blog_86ca10130100vhqf.html

    对于写到/etc/fstab里面的文件系统,它们一直是处在挂载状态,不管你用或者不用,这样或多或少的会对资源有所浪费,尤其是对于一个存在大量nfs文件挂载的系统 - 大部分情况下,这些挂载是不需要一直存在的。

    而autofs恰好提供了一种功能:如果你长时间(可定义这个timeout值)不用一个文件系统(本地、nfs、smbfs等等),autofs会把这个文件系统卸载;当你需要用到的时候,只需要cd到挂载点或者ls下挂载点,autofs会为你自动挂接。

    NFS配置与安装

    http://phantom.iteye.com/blog/66673

    NFS介绍和一些问题的总结

    http://www.360doc.com/content/14/0526/19/1123425_381208263.shtml

    (总结)NFS服务常见故障排查和解决方法

    http://www.ha97.com/4798.html

    一、NFS服务常见故障排查:

    NFS服务出现了故障,主要从以下几个方面检查原因:

    (1)检查NFS客户机和服务器的负荷是否太高,Server和Client之间的网络是否正常;

    (2)检查/etc/exports文件的正确性;

    (3)必要时重启NFS和portmap服务;

    (4)运行下列命令重新启动portmap和NFS:

    # /etc/init.d/portmap restart

    # /etc/init.d/nfs restart

    # /etc/init.d/rpcbind restart (在RHEL/CentOS 6.x里面)

    # chkconfig portmap on

    # chkconfig nfs on

    # chkconfig rpcbind on (在RHEL/CentOS 6.x里面)

    注意:在RHEL/CentOS 6.x里面,portmap服务改名为rpcbind服务了;顺便说一下,rpcbind服务也是图形界面的关键基础服务,不启动此服务,不能启动图形桌面。

    (5) 检查Client上的mount命令或/etc/fstab的语法是否正确;

    (6) 查看内核是否支持NFS和RPC服务。一般正常安装的Linux系统都会默认支持NFS和RPC服务,除非你自己重新编译的内核,而且没选择nfs支持选项编译。

    二、NFS常见故障解决方法:

    1、The rpcbind failure error

    故障现象:

    nfs mount: server1:: RPC: Rpcbind failure

    RPC: Timed Out

    nfs mount: retrying: /mntpoint

    原因:

    第一,可能因为客户机的hosts文件中存在错误的ip地址、主机名或节点名组合;

    第二,服务器因为过载而暂时停止服务。

    2、The server not responding error

    现象:

    NFS server server2 not responding, still trying

    原因:

    第一,网络不通,用ping命令检测一下。

    第二,服务器关机。

    3、The NFS client fails a reboot error

    现象:

    启动客户机后停住了,不断显示如下提示信息:

    Setting default interface for multicast: add net 224.0.0.0: gateway:

    client_node_name.

    原因:

    在etc/vfstab的mount选项中使用了fg而又无法成功mount服务器上的资源,改成bg或将该行注释掉,直到服务器可用为止。

    4、The service not responding error

    现象:

    nfs mount: dbserver: NFS: Service not responding

    nfs mount: retrying: /mntpoint

    原因:

    第一,当前级别不是级别3,用who -r查看,用init 3切换。

    第二,NFS Server守护进程不存在,用ps -ef | grep nfs检查,用/etc/init.d/nfs start启动。

    5、The program not registered error

    现象:

    nfs mount: dbserver: RPC: Program not registered

    nfs mount: retrying: /mntpoint

    原因:

    第一,当前级别不是级别3。

    第二,mountd守护进程没有启动,用/etc/init.d/nfs脚本启动NFS守护进程。

    第三,看/etc/dfs/dfstab中的条目是否正常。

    6、The stale file handle error

    现象:

    stale NFS file handle

    原因:

    服务器上的共享资源移动位置了,在客户端使用umount和mount重新挂接就可以了。

    7、The unknown host error

    现象:

    nfs mount: sserver1:: RPC: Unknown host

    原因:

    hosts文件中的内容不正确。

    8、The mount point error

    现象:

    mount: mount-point /DS9 does not exist.

    原因:

    该挂接点在客户机上不存在,注意检查命令行或/etc/vfstab文件中相关条目的拼写。

    9、The no such file error

    现象:

    No such file or directory.

    原因:

    该挂接点在服务器上不存在,注意检查命令行或/etc/vfstab文件中相关条目的拼写。

    10、No route to host

    错误现象:

    # mount 10.10.11.211:/opt/data/xmldb /c2c-web1/data/xmldb -t nfs -o rw

    mount: mount to NFS server ’10.10.11.211′ failed: System Error: No route to host.

    原因:

    防火墙被打开,关闭防火墙。

    这个原因很多人都忽视了,如果开启了防火墙(包括iptables和硬件防火墙),NFS默认使用111端口,我们先要检测是否打开了这个端口,还要检查TCP_Wrappers的设定。

    11、Not owner

    现象:

    # mount -F nfs -o rw 10.10.2.3:/mnt/c2c/data/resinfo2 /data/data/resinfo2

    nfs mount: mount: /data/data/resinfo2: Not owner

    原因:

    这是Solaris 10版本挂载较低版本nfs时报的错误。

    解决:

    需要用-o vers=3参数

    示例:

    # mount -F nfs -o vers=3 10.10.2.3:/mnt/c2c/data/resinfo2 /data/data/resinfo2

    12、RPC: Program not registered & retrying

    现象:

    nfs mount: 10.10.2.3: : RPC: Program not registered

    nfs mount: retrying: /data/data/resinfo2

    原因:

    没有启动NFS共享端服务。

    解决:需要重新启动share端的NFS服务,

    Linux:

    mount: RPC: Program not registered

    # /etc/init.d/nfs restart

    Solaris:

    mount: RPC: Program not registered

    # /etc/rc.d/init.d/nfs restart

    13、can’t contact portmapper: RPC: Remote system error – Connection refused

    现象:

    # exportfs -a

    can’t contact portmapper: RPC: Remote system error – Connection refused

    原因:

    出现这个错误信息是由于server端的portmap没有启动。

    解决:

    # /etc/init.d/portmap start

    网络文件服务器(Network File System,简称NFS),是分布式计算系统的一个组成部分,可实现在异种网络上共享和装配远程文件系统。NFS由Sun公司开发,目前已经成为文件服务的一种标准(RFC1904,RFC1813)。其最大的功能就是可以通过网络,让不同操作系统的计算机可以共享数据,所以也可以将它看做是一个文件服务器。

        NFS网络出现了故障,可以从以下几个方面着手检查:

        (1) 检查NFS客户机和服务器的负荷是否太高,Server和Client之间的网络是否正常;

        (2) 检查/etc/exports文件的正确性;

        (3) 必要时重新启动NFS或portmap服务;

        (4)运行下列命令重新启动portmap和NFS: service portmap restart service nfs start

        (5) 检查Client上的mount命令或/etc/fstab的语法是否正确;

        (6) 查看内核是否支持NFS和RPC服务。

    附加:★NFS常见故障排除 

    -------------------

    1、The rpcbind failure error 

    故障现象: 

    nfs mount: server1:: RPC: Rpcbind failure 

    RPC: Timed Out 

    nfs mount: retrying: /mntpoint 

    原因: 

    第一,可能因为客户机的hosts文件中存在错误的ip地址、主机名或节点名组合; 

    第二,服务器因为过载而暂时停止服务。

    2、The server not responding error 

    现象: 

    NFS server server2 not responding, still trying 

    原因: 

    第一,网络不通,用ping命令检测一下。 

    第二,服务器关机。

    3、The NFS client fails a reboot error 

    现象: 

    启动客户机后停住了,不断显示如下提示信息: 

    Setting default interface for multicast: add net 224.0.0.0: gateway: 

    client_node_name. 

    原因: 

    在etc/vfstab的mount选项中使用了fg而又无法成功mount服务器上的资源,改成bg或将该行注释掉,直到服务器可用为止。

    4、The service not responding error 

    现象: 

    nfs mount: dbserver: NFS: Service not responding 

    nfs mount: retrying: /mntpoint 

    原因: 

    第一,当前级别不是级别3,用who –r查看,用init切换。 

    第二,NFS Server守护进程不存在,用ps –ef | grep nfs检查,用/etc/init.d/nfs.server start启动。

    5、The program not registered error 

    现象: 

    nfs mount: dbserver: RPC: Program not registered 

    nfs mount: retrying: /mntpoint 

    原因: 

    第一,当前级别不是级别3。 

    第二,mountd守护进程没有启动,用/etc/init.d/nfs.server脚本启动NFS守护进程。 

    第三,看/etc/dfs/dfstab中的条目是否正常。

    6、The stale file handle error 

    现象: 

    stale NFS file handle 

    原因: 

    服务器上的共享资源移动位置了,在客户端使用umount和mount重新挂接就可以了。

    7、The unknown host error 

    现象: 

    nfs mount: sserver1:: RPC: Unknown host 

    原因: 

    hosts文件中的内容不正确。

    8、The mount point error 

    现象: 

    mount: mount-point /DS9 does not exist. 

    原因: 

    该挂接点在客户机上不存在,注意检查命令行或/etc/vfstab文件中相关条目的拼写。

    9、The no such file error 

    现象: 

    No such file or directory. 

    原因: 

    该挂接点在服务器上不存在,注意检查命令行或/etc/vfstab文件中相关条目的拼写。

    10、No route to host 

    错误现象:

    [root@msa30 sysconfig]# mount 10.10.11.211:/opt/b2b-data/xmldb  /b2b-web1/b2b-data/xmldb  -t nfs  -o rw

    mount: mount to NFS server '10.10.11.211' failed: System Error: No route to host.

    原因:

    防火墙被打开,关闭防火墙。

    11、Not owner

    现象:

    [root@msa30:/founder/shell]# mount -F nfs -o rw 10.10.2.3:/mnt/b2b/b2b-data/resinfo2 /data/b2b-data/resinfo2

    nfs mount: mount: /data/b2b-data/resinfo2: Not owner

    原因:

    这是Solaris 10版本挂载较低版本nfs时报的错误。

    解决:

    需要用-o vers=3参数

    示例:

    [root@msa30:/founder/shell]# mount -F nfs -o vers=3  10.10.2.3:/mnt/b2b/b2b-data/resinfo2 /data/b2b-data/resinfo2

    12、RPC: Program not registered & retrying

    现象:

    nfs mount: 10.10.2.3: : RPC: Program not registered

    nfs mount: retrying: /data/b2b-data/resinfo2

    原因:

    没有启动NFS共享端服务。

    解决:需要重新启动share端的NFS服务,

    Linux:

    mount: RPC: Program not registered

    #service nfs restart

    Solaris:

    mount: RPC: Program not registered

    #/etc/rc.d/init.d/nfs restart

    13、can't contact portmapper: RPC: Remote system error - Connection refused

    现象:

    #exportfs -a

    can't contact portmapper: RPC: Remote system error - Connection refused

    原因:

    出现这个错误信息是由于SEVER端的PORTMAP没有启动。

    解决:

    #service portmap start

    #service pcmcia start

    AIX和linux之间挂载nfs错误

    http://www.iteye.com/topic/824287

    linux作为nfs服务器,其/etc/exports文件为

    引用
    [root@bflinux Tbackup]# cat /etc/exports 
    /Tbackup/orcl hisdb02(rw,async,no_root_squash)


    aix作为nfs客户端,其/etc/filesystems中已经添加如下条目

    引用
    /Tbackup/orcl: 
         dev= "/Tbackup/orcl" 
         vfs= nfs 
         nodename= bflinux 
         mount= true 
         type= nfs 
         options= rw,bg,hard,intr,vers=3,rsize=32768,wsize=32768,timeo=600,proto=tcp,biods=32  account= false



    在aix系统挂载时出现以下错误:

    引用
    root@hisdb02:/dev#mount /Tbackup/orcl 
    mount: 1831-008 giving up on: 
    bflinux:/Tbackup/orcl 
    vmount: Operation not permitted.



    经检查是由于nfs_use_reserved_ports保持默认值(linux为1,aix为0),只需将nfs_use_reserved_ports修改为1即可。

    引用
    root@hisdb02:/dev#nfso -a|grep nfs_use_reserved_ports 
          nfs_use_reserved_ports = 0 

    root@hisdb02:/dev#nfso -p -o nfs_use_reserved_ports=1 
    Setting nfs_use_reserved_ports to 1 
    Setting nfs_use_reserved_ports to 1 in nextboot file

     

    怎样在AIX中Mount Redhat Linux上的nfs文件系统?

    环境  任何机型,操作系统 AIX 4.3.3,Redhat 6.2  
    问题  当在R6上mount redhat linux的nfs时,系统报错: 
    1831-008: Operation not permitted  
    解答 当在R6上mount redhat linux的nfs时,系统报错: 
    1831-008: Operation not permitted 

    用nfso命令修改参数nfs_use_reserved_ports,如下: 
    #nfso -o nfs_use_reserved_ports=1  
    缺省时AIX的参数nfs_use_reserved_ports是0,而linux 
    在响应客户的mount请求时,需要使用reserved_ports。 
    修改参数后,故障排除。

     

    RedHat 挂载 NFS 分区!

    一个cron.daily引发的nfs 卸载问题 ,解决

    http://www.36ji.net/article/1129/12583.html

    more /var/spool/anacron/cron.daily

    NFS Server宕机后,NFS Client主机上df命令挂死 

    http://www.linuxidc.com/Linux/2012-05/60229.htm

    只要运行df命令,该session马上挂死,使用ctrl + C也不能终止。

    解决办法:

    方法1:删除/etc/mtab文件最后一行要挂载的内容,即可,ok

    [root@localhost Desktop]# vim /etc/mtab

    /dev/mapper/systemvg-rootlv / ext3 rw 0 0
    proc /proc proc rw 0 0
    sysfs /sys sysfs rw 0 0
    devpts /dev/pts devpts rw,gid=5,mode=620 0 0
    /dev/mapper/systemvg-tmplv /tmp ext3 rw 0 0
    /dev/mapper/systemvg-varlv /var ext3 rw 0 0
    /dev/mapper/systemvg-usrlv /usr ext3 rw 0 0
    /dev/mapper/systemvg-optlv /opt ext3 rw 0 0
    /dev/sda1 /boot ext3 rw 0 0
    tmpfs /dev/shm tmpfs rw 0 0
    /dev/mapper/testvg-testlv /test ext3 rw,noatime 0 0
    /dev/mapper/systemvg-homelv /home ext3 rw 0 0
    none /proc/sys/fs/binfmt_misc binfmt_misc rw 0 0
    sunrpc /var/lib/nfs/rpc_pipefs rpc_pipefs rw 0 0
    /test/soft/rhel-server-5.5-x86_64-dvd.iso /mnt/RHEL5.5_x64 iso9660 rw,loop=/dev/loop0 0 0
    /test/soft/rhel-server-6.3-x86_64-dvd.iso /mnt/RHEL6.3_X64 iso9660 rw,loop=/dev/loop1 0 0
    10.24.73.102:/home/lindows /test/tangxje/lindows nfs rw,addr=10.24.73.102 0 0
     

    方法2:等待NFS server故障恢复,nfs重启启用后,df命令挂死问题解决,但有可能需要重新挂载一下nfs才可以。

    Linux / Redhat df -h 死机 , df -h 卡住不动了,

    解决: 可能是NFS 的文件系统没有挂载上。

    [root@b2ctest1 ~]# df -h
    文件系统              容量  已用 可用 已用% 挂载点
    /dev/mapper/VolGroup00-LogVol00
                          284G  129G  140G  48% /
    /dev/hda1              99M   13M   82M  13% /boot
    tmpfs                 2.0G     0  2.0G   0% /dev/shm

    [root@b2ctest1 ~]# ps wwwaux

    执行df -hP停住不动 , Linux / Redhat df -h 死机 , df -h 卡住不动了
    mount 查看有一个远程nfs 
    umount /mnt  无法卸载
    lsof   /mnt  无进程使用
    service portmap stop
    umount /mnt 成功
    ps aux  进程正常,刚才那些进程都没有了

    RPC Error:Program not registered问题的解决办法

    http://stevenz.blog.hexun.com/16127677_d.html

    [root@b2ctest1 ~]# mount 192.168.100.186:/c/backup /mnt/tivoli
    mount: mount to NFS server '192.168.100.186' failed: RPC Error: Program not registered.

    服务器IP:172.0.0.1,主机名:p470-1, 通过NFS 共享/disk1目录

    在客户端使用 mount -t nfs p470-1:/disk1 /disk1

    时出现"mount: mount to NFS server 'p470-1' failed: RPC Error: Program not registered."错误提示。

    出错原因:p470-1由于网络原因nfs 服务被中断,重新开启p470-1的nfs 服务,

    然后在客户端重新mount disk1即可 , service nfs restart 或 /etc/rc.d/init.d/nfs restart

     

    问题:mount NFS Permission denied

    解决:

    [root@b2cbbs ~]# mount -t nfs -o rw 192.168.121.22:/root/soft /home/ftpsoft/
    mount: 192.168.121.22:/root/soft failed, reason given by server: Permission denied 
    [root@b2cbbstest ~]# chmod -R 777 /root/soft/
    [root@b2cbbstest ~]# /etc/rc.d/init.d/nfs restart
    关闭 NFS mountd:                                          [确定]
    关闭 NFS 守护进程:                                        [确定]
    关闭 NFS quotas:                                          [确定]
    关闭 NFS 服务:                                            [确定]
    启动 NFS 服务:                                            [确定]
    关掉 NFS 配额:                                            [确定]
    启动 NFS 守护进程:                                        [确定]
    启动 NFS mountd:                                          [确定]
    [root@b2cbbs soft]# df -h
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
                           55G   34G   19G  65% /
    /dev/sda1              99M   11M   83M  12% /boot
    tmpfs                 1.5G     0  1.5G   0% /dev/shm
    192.168.121.22:/root/soft
                           64G   30G   32G  48% /home/ftpsoft

     

    Linux Samba服务器配置小记 

    http://liang831002.blog.51cto.com/188904/86312

    rhel 5.4 samba服务器配置

    http://space.itpub.net/22459792/viewspace-631837

    一、samba软件包安装

        # yum install samba*                       安装samba软件包
        #chkconfig smb on                           samba的服务名为smb
        # rpm -ql samba | grep etc               查看samba的配置文件
        #rpm -ql samba | grep bin                  查看samba的执行命令
        #/etc/init.d/smb start                           先行启动服务
        #netstat -tpln | grep smb                     其端口为137,138,139,445

    二、防火墙设置

    #iptables -I INPUT -p tcp  --dport 137:139  -j  ACCEPT

    #iptables -I INPUT -p tcp  --dport  445   -j ACCEPT

    #iptables-save > /etc/sysconfig/iptables

    #/etc/init.d/iptables restart

    三、共享模式的samba设置

    修改/etc/samba/smb.conf

    workgroup = WORKGROUP

    security = share      共享模式,不需要密码

    [samba1]

    path = /mysamba     目录绝对路径,要共享出来的目录

    writeable = yes     允许写入

    public = yes          允许guest账户浏览

     #testparm  对配置文件做测试

    #/etc/init.d/smb  restart

     

    四、selinux设置

    #getenfore

    #setenfore  1

    #getsebool  -a | grep smb

    #getsebool -a |  grep samba

    #setsebool -P   samba_export_all_rw   on

    五、在xp的调试

    在浏览器中输入\\192.168.1.54 进入共享目录

    linux 中调试

    #smbclient  -L localhost   不使用用户名查看网络资源

    #mount -t  cifs  //localhost/samba1   /mnt/

    @目录的夹读写权限受到共享目录本身权限,selinux属性,服务本身配置的控制(readonly参数)

     

    [root@b2cbbstest ~]# rpm -qa | grep smb 
    pam_smb-1.1.7-7.2.1
    pam_smb-1.1.7-7.2.1
    gnome-vfs2-smb-2.16.2-4.el5

    [root@b2cbbstest ~]# rpm -qa | grep samba 
    samba-client-3.0.33-3.7.el5
    samba-common-3.0.33-3.7.el5
    samba-3.0.33-3.7.el5
    system-config-samba-1.2.41-3.el5

    [root@b2cbbstest ~]# rpm -ql samba | grep etc 
    /etc/logrotate.d/samba
    /etc/pam.d/samba
    /etc/rc.d/init.d/smb
    /etc/samba/smbusers
    /etc/sysconfig/samba

    [root@b2cbbstest ~]# chkconfig --list | grep smb 
    smb                0:off    1:off    2:off    3:off    4:off    5:on    6:off
    [root@b2cbbstest ~]# chkconfig smb on 
    [root@b2cbbstest ~]# chkconfig --list | grep smb
    smb                0:off    1:off    2:on    3:on    4:on    5:on    6:off

    [root@b2cbbstest ~]# chkconfig smb off 
    [root@b2cbbstest ~]# chkconfig --list | grep smb
    smb                0:off    1:off    2:off    3:off    4:off    5:off    6:off

    [root@b2cbbstest ~]# /usr/sbin/smbd --version 
    Version 3.0.33-3.7.el5

    [root@b2cbbstest ~]# /usr/sbin/nmbd --version 
    Version 3.0.33-3.7.el5

    [root@b2cbbstest ~]# whereis smbd

    smbd: /usr/sbin/smbd /usr/share/man/man8/smbd.8.gz

    [root@b2cbbstest ~]# whereis nmbd

    nmbd: /usr/sbin/nmbd /usr/share/man/man8/nmbd.8.gz

    [root@b2cbbstest ~]# whereis samba

    samba: /etc/samba /usr/share/samba /usr/share/man/man7/samba.7.gz

    [root@b2cbbstest ~]# ls -l /etc/samba/ 
    total 40
    -rw-r--r-- 1 root root   20 Dec 10  2008 lmhosts
    -rw------- 1 root root 4096 Nov  2 10:27 passdb.tdb
    -rw------- 1 root root 8192 Nov  2 10:27 secrets.tdb
    -rw-r--r-- 1 root root 9790 Nov  2 14:23 smb.conf
    -rw-r--r-- 1 root root  109 Nov  2 14:23 smbusers
    [root@b2cbbstest ~]# service smb 
    Usage: /etc/init.d/smb {start|stop|restart|reload|status|condrestart}

    [root@b2cbbstest ~]# service smb restart 
    Shutting down SMB services:                                [FAILED]
    Shutting down NMB services:                                [FAILED]
    Starting SMB services:                                     [  OK  ]
    Starting NMB services:                                     [  OK  ]

    [root@b2cbbstest ~]# net share

    Password:******
    soft
    IPC$

    [root@b2cbbstest samba]# ps -ef | grep smbd 
    root      2437     1  0 15:49 ?        00:00:00 smbd -D
    root      2442  2437  0 15:49 ?        00:00:00 smbd -D
    root      2452  1804  0 15:51 pts/2    00:00:00 grep smb
    [root@b2cbbstest samba]# ps -ef | grep nmbd 
    root      2440     1  0 15:49 ?        00:00:00 nmbd -D
    root      2454  1804  0 15:52 pts/2    00:00:00 grep nmb

    [root@b2cbbstest samba]# netstat -atpln | grep smb 
    tcp        0      0 0.0.0.0:139                 0.0.0.0:*                   LISTEN      2437/smbd           
    tcp        0      0 0.0.0.0:445                 0.0.0.0:*                   LISTEN      2437/smbd

    Linux Samba服务器配置小记

    公司需求:
    1.    公司搭建Samba服务器,将对公司数据进行统一的有效管理;
    2.    所有员工在公司局域网内不论在哪台电脑上工作,都能访问并能将自己的文件数据保存在Samba文件服务器上。
    3.    销售部,技术部都拥有各自部门的共享目录,其他部门不允许访问;
    4.   Samba服务器只供公司内部使用,并限量员工的使用空间。
    根据网络拓扑进行Samba服务器的部署步骤;
    一、建立公司员工账号及技术与销售组;
    二、将相关员工加入技术及销售组;
    三、建立销售及技术共享的目录,并更改目录相关权限;
    四、安装并配置Samba服务器;
    五、利用quota进行磁盘配额;
    关于如何建账号,组这里就不再叙述。直接从第三步开始进行部署;
    [root@server ~]# mkdir /home/sales
    [root@server ~]# mkdir /home/jishu
    [root@server ~]# chgrp jishu /home/jishu
    [root@server ~]# chmod 770 /home/jishu
    [root@server ~]# chgrp sales /home/sales
    [root@server ~]# chmod 770 /home/sales
    安装并配置Samba;
    [root@server ~]# rpm -qa samba*
    samba-common-3.0.23c-2
    samba-3.0.23c-2
    samba-client-3.0.23c-2
    默认系统已经安装好Samba组件;
    设置smb.conf配置文件如下:
    [root@server ~]# vi /etc/samba/smb.conf
    具体相关配置文件里面的参数,有兴趣自己去搜索相关资料;
    #设置主机方面的参数;
    [global]
    #与Linux主机名称有关的设置信息
       workgroup = keywise        工作组设置
       netbios name=server        Samba服务器的NETBIOS名称
       server string = This is liang’s Samba Server  
    #与语言有关的设置信息
       unix charset=utf8
       display charset=utf8
       dos charset=cp950
    #与日志文件有关的设置信息
       log file = /var/log/samba/%m.log   日志存放位置
       max log size = 50
    #与密码有关的设置信息
    security = user   访问需要提供密码   
       encrypt passwords=yes   是否加密
       smb password file=/etc/samba/smbpasswd  密码放置文件
    #新增每个用户的默认目录及群组用户目录,如下图;
    编辑完smb.conf文件后,保存退出;
    然后设置可使用Samba的账号与密码;
    先查看并确认密码文件是否存在,若不存在,得自行建立;
    [root@server ~]# ls -l /etc/samba/smbpasswd
    -rw------- 1 root root 207 Jul  6 01:15 /etc/samba/smbpasswd
    新增用户并查看/etc/samba/smbpassword;如下图;添加samba账户之前,确认系统中有相关账号;
    测试smb.conf语法设置的正确性;
    [root@server ~]# testparm
    Load smb config files from /etc/samba/smb.conf
    Processing section "[homes]"
    Processing section "[printers]"
    Processing section "[temp]"
    Processing section "[homes]"
    Processing section "[jishu]"
    Processing section "[sales]"
    Loaded services file OK.
    Server role: ROLE_STANDALONE
    Press enter to see a dump of your service definitions
    启动并观察SMB服务
    [root@server ~]# /etc/init.d/smb start
    Starting SMB services:                                     [  OK  ]
    Starting NMB services:                                     [  OK  ]
    [root@server ~]# netstat -tlunp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
    tcp        0      0 0.0.0.0:139                 0.0.0.0:*                   LISTEN      2667/smbd   
    tcp        0      0 0.0.0.0:445                 0.0.0.0:*                   LISTEN      2667/smbd   
    udp        0      0 192.168.1.50:137            0.0.0.0:*                               2671/nmbd   
    udp        0      0 0.0.0.0:137                 0.0.0.0:*                               2671/nmbd   
    udp        0      0 192.168.1.50:138            0.0.0.0:*                               2671/nmbd   
    udp        0      0 0.0.0.0:138                 0.0.0.0:*                               2671/nmbd   
    注:Samba默认会启动多个端口,TCP端口139,445;UDP端口137,138;
    测试SAMBA
    使用匿名账号查看,密码为空;看到相关的工享目录;
    使用jack账号查看,能看到自己的家目录;每个拥有SAMBA账号的用户,看到的目录都和自己的账号同名;
    开始在客户端进行测试;利用一个账户进行测试;在测试时,遇到相关LINUX防火墙安全性问题;因此建议先关闭防火墙,或建相应的规则允许通过;如下图:
    利用一个属于sales组的账户,访问sales共享目录,出现如下错误;
    查看由于账号没有加入sales组;因为/home/sales目录所属组为sales;因此没权限访问;
    [root@server ~]# ll /home
    total 72
    drwxrwx--- 2 root  jishu  4096 Jul  6 06:21 jishu
    drwx------ 2 liang liang  4096 Jul  6 06:16 liang
    drwx------ 2 root  root  16384 Jun 26 08:43 lost+found
    drwxrwx--- 2 root  users  4096 Jul  6 01:16 public
    drwxrwx--- 2 root  sales  4096 Jul  6 02:30 sales
    将账户加入相应组;
    [root@server ~]# vi /etc/group
    jishu:x:504:jack
    sales:x:505:tom
    然后利用net use * /del 删除已建连接;重新用Jack账号访问;
    能成功看到属于自己的私有目录;并对目录有写入权限;
    看对技术目录有没有权限写入,测试一下;因为Jack属于技术组;因此应该对jishu目录有写入权限;
    OK,测试成功;SAMBA基本配置完成;
    由于服务器空间有限,还得利用quota限制用户及组的空间使用;
    Quota的前提,磁盘空间必须为独立的分区;可以依据不同的用户及组来加以限制使用硬盘空间;这里以/home为例;
    比如限制每个用户的hardlimit为50MB;而softlimit为40MB; 
    1、修改/etc/fstab, 如下图;
    [root@server ~]# vi /etc/fstab
    [root@server ~]# mount–a
    [root@server ~]# sync;sync;sync; reboot
    建立quota所需要的设置文件;
    [root@server ~]# quotacheck -avug
    quotacheck: Scanning /dev/hda6 [/home] quotacheck: Cannot stat old user quota file: No such file or directory
    quotacheck: Cannot stat old group quota file: No such file or directory
    quotacheck: Cannot stat old user quota file: No such file or directory
    quotacheck: Cannot stat old group quota file: No such file or directory
    done
    quotacheck: Checked 10 directories and 21 files
    quotacheck: Old file not found.
    quotacheck: Old file not found.
    [root@server ~]#
    以上提示为找不到相关设置文件;只能自行建立;
    [root@server ~]# touch /home/aquota.user; touch /home/aquota.group
    [root@server ~]# quotacheck -avug
    quotacheck: Scanning /dev/hda6 [/home] done
    quotacheck: Checked 10 directories and 23 files
    [root@server ~]#
    启动quota
    [root@server ~]# quotaon -av
    /dev/hda6 [/home]: group quotas turned on
    /dev/hda6 [/home]: user quotas turned on
    [root@server ~]#
    设置用户磁盘配额;
    [root@server ~]# edquota -u jack
    磁盘配额也基本完成;如果要对组进行配额,就执行以下命令;这里就不多言了;
    [root@server ~]# edquota -g jishu

    用samba构建公司内部网络 

    前言

    公司内部大约电脑80台,其中两台邮件服务器(FreeBSD),两台windows 2003 AD 兼文件服务器,我们主要需求:1、帐号集中管理。2、文件共享。由于windows 的文件服务器功能很差,主要是权限管理方面(可能是我菜)。经常有用户无意删除别人的文件,当你在服务器设置了权限后,用户还可以在客户端修改文件的权限。
    由于自己一直对linux 感兴趣,所以对linux 应用方面比较了解,对于SAMBA 早已闻其大名,由于时间关系,一直没有机会去偿试。

    需求

    1、提供文件共享功能
    2、能像AD 那样集中管理帐户。
    3、能提供磁盘限额

    所需软件:

    1、Samba 3.x
    2、Debian 4.0

    注:不管你使用什么unix/linux系统,按这种方法都可以实现以上功能。

    一、安装设置SAMBA

    1、安装系统

    安装系统时注意,尽量将/home 目录放在一个分区上,因为要为该分区进行磁盘限额,并有足够大的空间为用户提供存储。

    mail:~# df -h
    Filesystem             Size   Used Avail Use% Mounted on
    /dev/sda1              2.3G   491M   1.7G   23% /
    tmpfs                   90M      0    90M    0% /lib/init/rw
    udev                    10M    56K    10M    1% /dev
    tmpfs                   90M      0    90M    0% /dev/shm
    /dev/sda6              5.3G   139M   4.9G    3% /home

    2、安装软件

    安装SAMBA 及 QUOTA 工具

    mail:~# apt-get install samba quota


    3、配置samba

    mail:~# cd /etc/samba/
    mail:/etc/samba# mv smb.conf smb.conf.bak
    mail:/etc/samba#vim smb.conf
    

    下面解释smb.conf 的配置文件(注意,当你将下面的文件复制到UNIX 时,最好把中文去除)

    #全局选项
    [global]
      #设置字符的格式,cp950   为繁体字符,cp963 为简体
             dos charset = cp950
             unix charset = utf8
             display charset = utf8
      #设置工作组,及你的机器名。
             workgroup = ELEMENT
             netbios name = ELEMENTSERVER
      #服务器设置
             server string = This is Element File server %v
             log file = /var/log/samba/%m.log #%m 为登录系统的机器名
             max log size = 500    #日志大小,单位为KB
             name resolve order = lmhosts bcast host #NETBIOS 查找的顺序,
             time server = Yes   #打开时间服务器
             socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192   #TCP 选项
             #以下为域服务器选项
      logon script = startup.bat   #当用户登录域时执行的脚本
             logon drive = K:    #映射到用户本地的盘符
             logon path =     #设置漫游文件位置,当没有这个选项时,将在用户目录下自动生成profile 文件夹,当你在= 后面保持空白时,将用户配置文件设置为本机。
             os level = 200   #域的级别,越高权限越大
             preferred master = Yes
             domain master = Yes
             dns proxy = No
             wins support = Yes #打开WINS 的支持
             admin users = root #加入域的用户
      #在UNIX 里,当你将一台机要与另一台机进行密码验证时,必须将机器增加一个帐户,比如: clinet01 ,必须增加client01$ 这个帐户。当你要将一台机器加入域时,下面的命令可以省去添加机器信任的麻烦。
             add machine script = /usr/sbin/useradd -d /dev/null -s /bin/false -g machines %u
       
    #windows 登录目录设置
    [netlogon]
             comment = Network logon Service
             path = /home/samba/netlogon
             write list = root
             guest ok = Yes
    #用户家目录设置
    [homes]
             comment = Home directories
             valid users = %S
             read only = No
             create mask = 0664
             browseable = No
    #临时文件,用于为用户进行文件交换
    [temp]
     comment = the user groups work directory
     path = /home/temp
     valid users = @users
     read only = No
     guest ok = Yes
    
    

    创建登录脚本

    mail:/etc/samba# mkdir -p /home/samba/netlogon/
    mail:/etc/samba# vim /home/samba/netlogon/startup.bat
    

    脚本内容

    net time \\elementserver /set /yes
    net use M: \\elementserver\temp
    

    转换脚本内容为DOS 格式

    mail:/etc/samba# apt-get install tofrodos
    mail:/etc/samba# unix2dos /home/samba/netlogon/startup.bat
    

    创建所临时文件夹

    mail:/etc/samba# mkdir /home/temp
    mail:/etc/samba# chgrp users /home/temp/
    mail:/etc/samba# chmod 1770 /home/temp/
    

    重启SAMBA

    mail:/etc/samba# /etc/init.d/samba restart
    Stopping Samba daemons: nmbd smbd.
    Starting Samba daemons: nmbd smbd.

    添加组及用户

    mail:/etc/samba# groupadd machines
    mail:/etc/samba# groupadd users

    添加一个系统用户

    mail:/etc/samba# useradd -m -s /bin/false -g users user01

    将用户添加为samba 用户

    mail:/etc/samba# smbpasswd -a user01
    New SMB password:
    Retype new SMB password:
    Added user user01.
    
    

    添加root 到samba 帐户中

    mail:/etc/samba# smbpasswd -a root
    New SMB password:
    Retype new SMB password:
    Added user root.

    二、设置磁盘限额

    1、打开磁盘限额(添加红色的内容)

    mail:~# vim /etc/fstab 
    # /etc/fstab: static file system information.
    #
    #                
    proc             /proc            proc     defaults         0        0
    /dev/sda1        /                ext3     defaults,errors=remount-ro 0        1
    /dev/sda6        /home            ext3     defaults,usrquota,grpquota
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
             0        2
    /dev/sda5        none             swap     sw               0        0
    /dev/hdc         /media/cdrom0    udf,iso9660 user,noauto      0        0
    /dev/fd0         /media/floppy0   auto     rw,user,noauto   0        0

    创建配置文件

    mail:/home# touch /home/aquota.user
    mail:/home# touch /home/aquota.group
    

    重启系统

    mail:/home# reboot

    配置组磁盘限额

    mail:~# edquota -g users

    下面配置30M 空间作为测试

    soft 是指软限制,当你超过这个限制时,系统警告你,但你还可以继续使用 
    hard 指硬限制,超过限制将不能使用。

    前面一组soft/hard 指空间限制,后面一组指文件数

    Disk quotas for group users (gid 100):
       Filesystem                    blocks        soft        hard      inodes      soft      hard
       /dev/sda6                         20        27000       30000           5         0         0 

     

    三、将windows 客户机加入域

    1、设置WINS,在WINS 服务器中,填入服务器IP地址,以便找到服务器

    2、在网域中填入工作组的名字,输入ROOT 的用户名及密码加入域

    3、登录服务器

    配置文件

    fstab

    smb.conf

    startup.bat

    参考文档

    http://linux.vbird.org/linux_server/0370samba.php

    http://linux.vbird.org/linux_basic/0420quota.php

    http://blog.5ilinux.com/archives/2003/11/samba30pdc.html

     

    RedHat Enterprise Linux 5.5 x64   Rsync  Service

    rsync clinet端取数据时,出Connection reset by peer 的错误。

    http://bbs.chinaunix.net/thread-2119601-1-1.html

     

    Server config 192.168.154.1:

     

    [root@lindows ~]# more /etc/xinetd.d/rsync

     

    # default: off
    # description: The rsync server is a good addition to an ftp server, as it \
    #       allows crc checksumming etc.
    service rsync
    {
            disable = no
            socket_type     = stream
            wait            = no
            user            = root
            server          = /usr/bin/rsync
            server_args     = --daemon
            log_on_failure  += USERID
    }
    

     

    开启rsync服务

    [root@lindows ~]# chkconfig rsync on

    编辑rsync配置

    [root@lindows ~]# vim /etc/rsyncd .conf

     

    ####***************************************####
    [test]
    pid file = /var/run/rsyncd.pid
    log file = /var/log/rsyncd.log
    path = /opt
    uid=root
    gid=root
    max connections = 200
    timeout = 600
    use chroot = no
    read only = yes
    list = yes
    ignore errors
    #auth user = root
    host_allow = *
    syslog facility = local3
    #rsync config
    #The' standard' things

    启动rsync进程

    [root@lindows ~]# /usr/bin/rsync --daemon --config=/etc/rsyncd.conf

    [root@lindows ~]# ps -ef | grep rsyncd

    root      6421     1  0 00:02 ?        00:00:00 /usr/bin/rsync --daemon --config=/etc/rsyncd.conf
    root      7376  5082  0 00:29 pts/1    00:00:00 grep rsyncd
    检查rsync端口

    [root@localhost opt]# grep rsync /etc/services 
    rsync           873/tcp                         # rsync
    rsync           873/udp                         # rsync
    airsync         2175/tcp                        # Microsoft Desktop AirSync Protocol
    airsync         2175/udp                        # Microsoft Desktop AirSync Protocol

    [root@localhost opt]# netstat -an | grep :873 
    tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      
    tcp        0      0 :::873                      :::*                        LISTEN     

    [root@localhost opt]# mkdir -p /opt/146soft

     

    Clinet Rsync config 192.168.154.142:

    查看rsync同步列表

    [root@localhost opt]# rsync --list-only 192.168.154.146:/opt/ 

    root@localhost opt]# rsync --list-only root@192.168.154.146:/opt/ 
    drwxr-xr-x        4096 2011/05/26 23:44:12 .
    drwxr-xr-x        4096 2011/05/26 23:35:55 54.146_soft
    测试rsync同步全部数据 ok

    [root@localhost opt]# rsync -auqz 192.168.154.146::test /opt/

    测试rsync同步增量数据 ok

    [root@localhost opt]#/usr/bin/rsync -avuztorpg --delete --progress 192.168.154.146::test ./ >> /opt/rsync_log/rsync_$HOSTNAME.log

    [root@localhost opt]#/usr/bin/rsync -avuztorpg --delete --progress root@192.168.154.146::test ./ >> /opt/rsync_log/rsync_$HOSTNAME.log

     

    http://www.ryong21.com/archives/576.html

    rsync error: timeout in data send/receive 
        如果同步的文件很多,rsync客户端会出现这样的错误:

            rsync error: timeout in data send/receive (code 30) at io.c(171) [sender=2.6.8]
            rsync: connection unexpectedly closed 

        在rsync命令中加上–timeout=TIME  设置 I/O 超时时间就可以了。TIME单位是秒。

     

    rsync的各种返回值的含义: 
    http://www.codelast.com/?p=796
    0    Success
    1    Syntax or usage error
    2    Protocol incompatibility
    3    Errors selecting input/output files, dirs
    4    Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot support them; or an option was specified that is supported by the client and not by the server.
    5    Error starting client-server protocol
    10    Error in socket I/O
    11    Error in file I/O
    12    Error in rsync protocol data stream
    13    Errors with program diagnostics
    14    Error in IPC code
    20    Received SIGUSR1 or SIGINT
    21    Some error returned by waitpid()
    22    Error allocating core memory buffers
    23    Partial transfer due to error
    24    Partial transfer due to vanished source files
    30    Timeout in data send/receive

     

     

    redhat linux inotify

    [root@B2Cmonitor inotify-tools-3.14]# whereis inotify 
    inotify: /usr/share/man/man7/inotify.7.gz
    [root@B2Cmonitor inotify-tools-3.14]# ll /proc/sys/fs/inotify/ 
    total 0
    -rw-r--r-- 1 root root 0 Nov 15 16:33 max_queued_events
    -rw-r--r-- 1 root root 0 Nov 15 16:33 max_user_instances
    -rw-r--r-- 1 root root 0 Nov 15 16:33 max_user_watches

    [root@B2Cmonitor inotify-tools-3.14]# more /proc/sys/fs/inotify/max_queued_events 
    16384
    [root@B2Cmonitor inotify-tools-3.14]# more /proc/sys/fs/inotify/max_user_watches 
    8192
    [root@B2Cmonitor inotify-tools-3.14]# more /proc/sys/fs/inotify/max_user_instances 
    128

    [root@B2Cmonitor inotify-tools-3.14]# cd /opt/soft/inotify-tools-3.14

    [root@B2Cmonitor inotify-tools-3.14]# ./configure

    [root@B2Cmonitor inotify-tools-3.14]# make & make install

    [root@B2Cmonitor inotify-tools-3.14]# whereis inotifywait
    inotifywait: /usr/local/bin/inotifywait

    [root@B2Cmonitor ~]# inotifywait --help

     

    inotifywait 3.14
    Wait for a particular event on a file or set of files.
    Usage: inotifywait [ options ] file1 [ file2 ] [ file3 ] [ ... ]
    Options:
        -h|--help         Show this help text.
        @<file>           Exclude the specified file from being watched.
        --exclude <pattern>
                          Exclude all events on files matching the
                          extended regular expression <pattern>.
        --excludei <pattern>
                          Like --exclude but case insensitive.
        -m|--monitor      Keep listening for events forever.  Without
                          this option, inotifywait will exit after one
                          event is received.
        -d|--daemon       Same as --monitor, except run in the background
                          logging events to a file specified by --outfile.
                          Implies --syslog.
        -r|--recursive    Watch directories recursively.
        --fromfile <file>
                          Read files to watch from <file> or `-' for stdin.
        -o|--outfile <file>
                          Print events to <file> rather than stdout.
        -s|--syslog       Send errors to syslog rather than stderr.
        -q|--quiet        Print less (only print events).
        -qq               Print nothing (not even events).
        --format <fmt>    Print using a specified printf-like format
                          string; read the man page for more details.
        --timefmt <fmt>    strftime-compatible format string for use with
                          %T in --format string.
        -c|--csv          Print events in CSV format.
        -t|--timeout <seconds>
                          When listening for a single event, time out after
                          waiting for an event for <seconds> seconds.
                          If <seconds> is 0, inotifywait will never time out.
        -e|--event <event1> [ -e|--event <event2> ... ]
            Listen for specific event(s).  If omitted, all events are 
            listened for.

    Exit status:
        0  -  An event you asked to watch for was received.
        1  -  An event you did not ask to watch for was received
              (usually delete_self or unmount), or some error occurred.
        2  -  The --timeout option was given and no events occurred
              in the specified interval of time.


    Events:
        access        file or directory contents were read
        modify        file or directory contents were written
        attrib        file or directory attributes changed
        close_write    file or directory closed, after being opened in
                       writeable mode
        close_nowrite    file or directory closed, after being opened in
                       read-only mode
        close        file or directory closed, regardless of read/write mode
        open        file or directory opened
        moved_to    file or directory moved to watched directory
        moved_from    file or directory moved from watched directory
        move        file or directory moved to or from watched directory
        create        file or directory created within watched directory
        delete        file or directory deleted within watched directory
        delete_self    file or directory was deleted
        unmount        file system containing file or directory unmounted

     

    inotifywait相关参数
    Inotifywait是一个监控等待事件,可以配合shell脚本使用它,下面介绍一下常用的一些参数:
     -m, 即--monitor,表示始终保持事件监听状态。
     -r, 即--recursive,表示递归查询目录。
     -q, 即--quiet,表示打印出监控事件。
     -e, 即--event,通过此参数可以指定要监控的事件,常见的事件有modify、delete、create、attrib等。
    更详细的请参看man  inotifywait。

     

    inotifywait监控root home 目录 
    [root@B2Cmonitor ~]# inotifywait -r -m $HOME 
    Setting up watches.  Beware: since -r was given, this may take a while!
    Watches established.
    /root/ OPEN,ISDIR 
    /root/ CLOSE_NOWRITE,CLOSE,ISDIR 
    /root/ OPEN,ISDIR 
    /root/ CLOSE_NOWRITE,CLOSE,ISDIR 
    /root/ DELETE Battlefield.3.Alpha.torrent

     

    inotifywait监控etc 目录

    [root@B2Cmonitor ~]# inotifywait -e create,delete,modify,move -mrq /etc &

    nfs example client

    [root@b2cdevnginx01 ~]# cat /etc/services | grep 2049 
    nfs        2049/tcp    nfsd
    nfs        2049/udp    nfsd

    [root@b2cdevnginx01 ~]# df -h 
    Filesystem            Size  Used Avail Use% Mounted on
    /dev/mapper/VolGroup00-LogVol00
                           16G  5.6G  9.1G  39% /
    /dev/sda1              99M   13M   82M  14% /boot
    tmpfs                 2.0G     0  2.0G   0% /dev/shm
    192.168.157.102:/opt/SNWCS/WC_EMALL.ear/Stores.war/ConsumerDirectStorefrontAssetStore
                          119G   57G   56G  51% /opt/sitnginx/nfs102_ConsumerDirectStorefrontAssetStore

    nfs example server

    [root@nginxpre1 ~]# netstat -an |grep :2049 
    tcp        0      0 0.0.0.0:2049                0.0.0.0:*                   LISTEN      
    tcp        0      0 192.168.157.102:2049        192.168.157.193:911         ESTABLISHED 
    udp        0      0 0.0.0.0:2049                0.0.0.0:*

    RedHat Linux 默认NFS端口对应表

    [root@nginxpre2 ~]# cat /etc/services  | grep nfs 
    nfs        2049/tcp    nfsd
    nfs        2049/udp    nfsd
    nfsd-status    1110/tcp            # Cluster status info
    nfsd-keepalive    1110/udp            # Client status info
    picknfs        1598/tcp            # picknfs
    picknfs        1598/udp            # picknfs
    shiva_confsrvr    1651/tcp            # shiva_confsrvr
    shiva_confsrvr    1651/udp            # shiva_confsrvr
    3d-nfsd        2323/tcp            # 3d-nfsd
    3d-nfsd        2323/udp            # 3d-nfsd
    mediacntrlnfsd    2363/tcp            # Media Central NFSD
    mediacntrlnfsd    2363/udp            # Media Central NFSD

    http://www.diybl.com/course/6_system/linux/Linuxjs/2008915/142931_2.html

    nfs 2049/tcp networked file system
    nfs 2049/udp networked file system
    nfsd 2049/udp nfs NFS server daemon
    shilp 2049/tcp
    shilp 2049/udp

    http://zh.wikipedia.org/wiki/TCP/UDP%E7%AB%AF%E5%8F%A3%E5%88%97%E8%A1%A8

    WebDAV (Redirected from Webdav)

    https://wiki.archlinux.org/index.php/WebDAV

    WebDAV (Web Distributed Authoring and Versioning) is an extension of HTTP 1.1 and therefore can be considered to be a procotol. It contains a set of concepts and accompanying extension methods to allow read and write across the HTTP 1.1 protocol. Instead of using NFS or SMB, WebDAV offers file transfers via HTTP. The goal of this how to is to setup a simple WebDAV configuration using Apache.

    OS + Linux File nfs / samba / rsync / inotify / smb / webdav

    https://www.iteye.com/blog/user/lindows/blog/883586

    RedHat Enterprise Linux 5.5 x64   Rsync  Service

    rsync clinet端取数据时,出Connection reset by peer 的错误。

    http://bbs.chinaunix.net/thread-2119601-1-1.html

    rsync配置

    http://rsync.samba.org

    https://www.cnblogs.com/zhenhui/p/5715840.html

    Server config 192.168.154.1:

    [root@lindows ~]# more /etc/xinetd.d/rsync

    1. # default: off  
    2. # description: The rsync server is a good addition to an ftp server, as it \  
    3. #       allows crc checksumming etc.  
    4. service rsync  
    5. {  
    6.         disable = no  
    7.         socket_type     = stream  
    8.         wait            = no  
    9.         user            = root  
    10.         server          = /usr/bin/rsync  
    11.         server_args     = --daemon  
    12.         log_on_failure  += USERID  
    13. }  

    开启rsync服务

    [root@lindows ~]# chkconfig rsync on

    编辑rsync配置

    [root@lindows ~]# vim /etc/rsyncd .conf

    1. ####***************************************####  
    2. [test]  
    3. pid file = /var/run/rsyncd.pid  
    4. log file = /var/log/rsyncd.log  
    5. path = /opt  
    6. uid=root  
    7. gid=root  
    8. max connections = 200  
    9. timeout = 600  
    10. use chroot = no  
    11. read only = yes  
    12. list = yes  
    13. ignore errors  
    14. #auth user = root  
    15. host_allow = *  
    16. syslog facility = local3  
    17. #rsync config  
    18. #The' standard' things  

    启动rsync进程

    [root@lindows ~]# /usr/bin/rsync --daemon --config=/etc/rsyncd.conf

    [root@lindows ~]# ps -ef | grep rsyncd

    root      6421     1  0 00:02 ?        00:00:00 /usr/bin/rsync --daemon --config=/etc/rsyncd.conf
    root      7376  5082  0 00:29 pts/1    00:00:00 grep rsyncd
    检查rsync端口

    [root@localhost opt]# grep rsync /etc/services 
    rsync           873/tcp                         # rsync
    rsync           873/udp                         # rsync
    airsync         2175/tcp                        # Microsoft Desktop AirSync Protocol
    airsync         2175/udp                        # Microsoft Desktop AirSync Protocol

    [root@localhost opt]# netstat -an | grep :873 
    tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      
    tcp        0      0 :::873                      :::*                        LISTEN     

    [root@localhost opt]# mkdir -p /opt/146soft

    Clinet Rsync config 192.168.154.142:

    查看rsync同步列表

    [root@localhost opt]# rsync --list-only 192.168.154.146:/opt/ 

    root@localhost opt]# rsync --list-only root@192.168.154.146:/opt/ 
    drwxr-xr-x        4096 2011/05/26 23:44:12 .
    drwxr-xr-x        4096 2011/05/26 23:35:55 54.146_soft
    测试rsync同步全部数据 ok

    [root@localhost opt]# rsync -auqz 192.168.154.146::test /opt/

    测试rsync同步增量数据 ok

    [root@localhost opt]#/usr/bin/rsync -avuztorpg --delete --progress 192.168.154.146::test ./ >> /opt/rsync_log/rsync_$HOSTNAME.log

    [root@localhost opt]#/usr/bin/rsync -avuztorpg --delete --progress root@192.168.154.146::test ./ >> /opt/rsync_log/rsync_$HOSTNAME.log

    http://www.ryong21.com/archives/576.html

    rsync error: timeout in data send/receive 
        如果同步的文件很多,rsync客户端会出现这样的错误:

            rsync error: timeout in data send/receive (code 30) at io.c(171) [sender=2.6.8]
            rsync: connection unexpectedly closed 

        在rsync命令中加上–timeout=TIME  设置 I/O 超时时间就可以了。TIME单位是秒。

    rsync的各种返回值的含义: 
    http://www.codelast.com/?p=796
    0    Success
    1    Syntax or usage error
    2    Protocol incompatibility
    3    Errors selecting input/output files, dirs
    4    Requested action not supported: an attempt was made to manipulate 64-bit files on a platform that cannot support them; or an option was specified that is supported by the client and not by the server.
    5    Error starting client-server protocol
    10    Error in socket I/O
    11    Error in file I/O
    12    Error in rsync protocol data stream
    13    Errors with program diagnostics
    14    Error in IPC code
    20    Received SIGUSR1 or SIGINT
    21    Some error returned by waitpid()
    22    Error allocating core memory buffers
    23    Partial transfer due to error
    24    Partial transfer due to vanished source files
    30    Timeout in data send/receive

    end

    end

  • 相关阅读:
    高精度模板 支持各种运算 c++
    404 页面不存在
    多柱汉诺塔问题“通解”——c++
    高精度gcd
    404 页面不存在
    如何开启音乐二倍速?不下载其他软件【win10】
    如何随时学习数学
    洛谷P1004 方格取数
    Title
    Title
  • 原文地址:https://www.cnblogs.com/lindows/p/14390331.html
Copyright © 2011-2022 走看看