CentOS 6 (74)

rsync客户端命令详解

  在对rsync服务器配置结束以后,下一步就需要在客户端发出rsync命令来实现将服务器端的文件备份到客户端来。rsync是一个功能非常强大的工具,其命令也有很多功能特色选项,我们下面就对它的选项一一进行分析说明。   首先,rsync的命令格式可以为:   rsync [OPTION]... SRC [SRC]... [USER@]HOST:DEST   rsync [OPTION]... [USER@]HOST:SRC DEST   rsync [OPTION]... SRC [SRC]... DEST   rsync [OPTION]... [USER@]HOST::SRC [DEST]   rsync [OPTION]... SRC [SRC]... [USER@]HOST::DEST   rsync [OPTION]... rsync://[USER@]HOST[:PORT]/SRC [DEST] rsync有六种不同的工作模式:   拷贝本地文件;当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式。   使用一个远程shell程序(如rsh、ssh)来实现将本地机器的内容拷贝到远程机器。当DST路径地址包含单个冒号":"分隔符时启动该模式。   使用一个远程shell程序(如rsh、ssh)来实现将远程机器的内容拷贝到本地机器。当SRC地址路径包含单个冒号":"分隔符时启动该模式。   从远程rsync服务器中拷贝文件到本地机。当SRC路径信息包含"::"分隔符时启动该模式。   从本地机器拷贝文件到远程rsync服务器中。当DST路径信息包含"::"分隔符时启动该模式。   列远程机的文件列表。这类似于rsync传输,不过只要在命令中省略掉本地机信息即可。 1、用法   在使用rsync传输文件时,需要指定一个源和一个目的,其中一个可能是远程机器的资源信息。例如:   rsync *.c foo:src/   表示将传输当前目录下所有以.c结尾的文件到机器foo的src目录下。如果任何文件已经存在于远程系统,则会调用远程更新协议来实现仅仅传输那些更新过的文件。   rsync -avz foo:src/bar /data/tmp   该命令则递归地传输机器foo上的src/bar目录下的所有内容到本地/data/tmp/bar目录中。文件以归档模式进行传输,以确保符号链结、属性、权限、属主等信息在传输中都被保存。此外,可以使用压缩技术来加快数据传输:   rsync -avz foo:src/bar/ /data/tmp   路径信息以"/"结尾时表示拷贝该目录,而不以"/"结尾表示拷贝该目录。当配合使用--delete选项时这两种情况的区别将会表现出来。   也可以以本地模式来使用rsync,如果SRC和DST路径中都没有任何":"符号则表示该命令运行在本地模式,等同于cp命令。   rsync somehost.mydomain.com::   这种模式则将会列出somehost.mydomain.com.可以访问的所有模块信息。   选项说明   -v, --verbose 详细模式输出 -q, --quiet 精简输出模式 -c, --checksum 打开校验开关,强制对文件传输进行校验 -a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD -r, --recursive 对子目录以递归模式处理 -R, --relative…
Read more...

rsync服务器架设(数据同步|文件增量备份)

  我们在使用服务器发布我们的网站的时候,通常要考虑到文件的备份,而文件的备份比较高效的备份是增加备份,rsync软件就是这样的一个工具。为了实现多个服务器负载均衡,我们需要这几个服务器之间进行数据同步,而rsync软件也能胜任,下面我们来介绍如何架设rsync服务器来达到文件增量备份和数据同步的功能。 什么是rsync rsync 是一个快速增量文件传输工具,它可以用于在同一主机备份内部的备分,我们还可以把它作为不同主机网络备份工具之用。本文主要讲述的是如何自架rsync服务器,以实现文件传输、备份和镜像。相对tar和wget来说,rsync 也有其自身的优点,比如速度快、安全、高效。 rsync的安装 在CentOS服务器,我们可以执行以下命令安装 yum install rsync 对于debian、ubuntu服务器,则是以下命令 sudo apt-get  install  rsync rsync服务器的配置文件rsyncd.conf 下面我们将涉及到三个文件 rsyncd.conf,rsyncd.secrets 和rsyncd.motd。 rsyncd.conf 是rsync服务器主要配置文件。 rsyncd.secrets是登录rsync服务器的密码文件。 rsyncd.motd是定义rysnc 服务器信息的,也就是用户登录信息。 下面我们分别建立这三个文件。 mkdir /etc/rsyncd 注:在/etc目录下创建一个rsyncd的目录,我们用来存放rsyncd.conf 和rsyncd.secrets文件; touch /etc/rsyncd/rsyncd.conf 注:创建rsyncd.conf ,这是rsync服务器的配置文件; touch /etc/rsyncd/rsyncd.secrets 注:创建rsyncd.secrets ,这是用户密码文件; chmod 600 /etc/rsyncd/rsyncd.secrets 注:为了密码的安全性,我们把权限设为600; touch /etc/rsyncd/rsyncd.motd 注:创建rsyncd.motd文件,这是定义服务器信息的文件。 下一就是我们修改 rsyncd.conf 和rsyncd.secrets 和rsyncd.motd 文件的时候了。 rsyncd.conf文件内容: # Minimal configuration file for rsync daemon # See rsync(1) and rsyncd.conf(5) man pages for help   # This line is required by the /etc/init.d/rsyncd script pid file = /var/run/rsyncd.pid    port = 873 address = 192.168.1.171  #uid = nobody #gid = nobody    uid = root    gid…
Read more...

proftpd 500 OOPS: cannot change directory:/home/ftp

  但客户端访问提示如下错误: 500 OOPS: cannot change directory:/home/ftp 原因是他的CentOS系统安装了SELinux,因为默认下是没有开启FTP的支持,所以访问时都被阻止了。 //查看SELinux设置   # getsebool -a|grep ftp ftp_home_dir-->off   //使用setsebool命令开启     # setsebool ftp_home_dir 1   由于操作系统一旦重启后,这种设置需要重新设置,这里使用-P参数实现.   //setsebool使用-P参数,无需每次开机都输入这个命令   # setsebool -P ftp_home_dir 1
Read more...

Linux中重启的两个命令:reboot和init 6之间的区别

init命令用于改变操作系统的运行级别。 Init 6是重新启动机器。 reboot也是重新启动机器。 那么这两个命令到底有什么区别呢? 对这两个操作使用man命令看到的内容如下: "init 6" 基于一系列/etc/inittab文件,并且每个应用都会有一个相应shutdown脚本。 'init 6' 调用一系列shutdown脚本(/etc/rc0.d/K*)来使系统优雅关机; 'reboot'并不执行这些过程,reboot更是一个kernel级别的命令,不对应用使用shutdown脚本。 . 我们应该在通常情况下使用 init 6. reboot - reboot performs a sync(1M) operation on the disks, and then a multi- user reboot is initiated. See init(1M) for details. init 6 Stop the operating system and reboot to the state defined by the initdefault entry in /etc/inittab. 在出问题的状况下或强制重启时使用reboot.
Read more...

Howto disable IPv6 on Centos 6.3 or Redhat 6.3 RHEL

  Howto disable IPv6 on Centos 6.3 or Redhat 6.3 RHEL 1. Check IPv6 on your Centos or RHEL Server [root@Centos6 ~]# ip addr 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN qlen 1000 link/ether 00:0c:29:55:52:41 brd ff:ff:ff:ff:ff:ff inet 192.168.0.112/24 brd 192.168.0.255 scope global eth0 inet6 fe80::20c:29ff:fe55:5241/64 scope link valid_lft forever preferred_lft forever [root@Centos6 ~]# 2. Disabe ipv6 on your server [root@Centos6 ~]# vi /etc/modprobe.d/disable-ipv6.conf install ipv6 /bin/true [root@Centos6 ~]# vi /etc/sysconfig/network NETWORKING=yes NETWORKING_IPV6=no HOSTNAME=Centos6.3 GATEWAY=192.168.0.1…
Read more...

Centos 6 关闭 IPV6

  ipv6关闭方法    在/etc/modprobe.d/dist.conf结尾添加    alias net-pf-10 off  alias ipv6 off  可用vi等编辑器,也可以通过命令:  [root@localhost ~]# cat <<EOF>>/etc/modprobe.d/dist.conf  alias net-pf-10 off  alias ipv6 off  EOF
Read more...

find mtime 查找距当前时间n天以内修改的文件

find $PATH -mtime 0  查找距当前时间24小时以内修改的文件      Search  for  files  in  your home directory which have been modified in the last twenty-four hours.  This command works this way because the time since each file was last modified is divided by 24 hours and  any remainder  is  discarded.   That means that to match -mtime 0, a file will have to have a modification in the past which is less than 24 hours ago.   find $PATH -mtime +n  查找距当前时间n天以外修改的文件 如n=2     find $PATH -mtime +2  当前时间11-10 10:00 那么即从距离当前时间(2012-11-10 10:00)的2天前开始算起 find $PATH -mtime +2表示11-07 10:00之前修改过的所有文件都会查找出来,往更早的时间推移,如底下参考鸟哥的时间推移图片   find $PATH -mtime -n  查找距当前时间n天以内修改的文件 如n=2…
Read more...

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php on line 191
Call Stack
#TimeMemoryFunctionLocation
10.0007413616{main}( ).../index.php:0
20.09794263976Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.09794263976Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.338711453960Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.339611478240Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.340311533568Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.340611560968require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.347611896160K2ControllerItemlist->execute( ).../k2.php:64
90.347611896160K2ControllerItemlist->display( ).../BaseController.php:710
100.361612803104K2ControllerItemlist->display( ).../itemlist.php:49
110.361612803104K2ControllerItemlist->display( ).../controller.php:19
120.364613017368Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.366113038056K2ViewItemlist->display( ).../ViewController.php:102
140.560216239832K2ViewItemlist->display( ).../view.html.php:1407
150.560216239832K2ViewItemlist->loadTemplate( ).../HtmlView.php:230
160.562816308304include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php' ).../HtmlView.php:701