10.32/10.33 rsync经过服务同步html
10.34 linux系统日志node
10.35 screen工具linux
扩展vim
Linux日志文件总管logrotate http://linux.cn/article-4126-1.html安全
xargs用法详解 http://blog.csdn.net/zhangfn2011/article/details/6776925服务器
rsync --daemon
telnet IP地址 837
rsync -avL 本地客户端发要送的文件或目录 服务端IP::[可更名] rsync -avL 服务端IP::要接收的文件或目录 本地客户端接收地址[可更名]
辑服务配置文件ssh
vim /etc/rsyncd.conf port=873 默认是873, log file=/var/log/rsync.log pid file=/var/run/rsyncd.pid address=192.168.133.130 [test] path=/root/rsync use chroot=true max connections=4 read only=no list=true uid=root gid=root auth users=test secrets file=/etc/rsyncd.passwd hosts allow=192.168.133.132 1.1.1.1 2.2.2.2 192.168.133.0/24
port:指定在哪一个端口启动rsyncd服务,默认是873端口。 log file:指定日志文件。 pid file:指定pid文件,这个文件的做用涉及服务的启动、中止等进程管理操做。 address:指定启动rsyncd服务的IP。假如你的机器有多个IP,就能够指定由其中一个启动rsyncd服务,若是不指定该参数,默认是在所有IP上启动。 []:指定模块名,里面内容自定义。 path:指定数据存放的路径。 use chroot true|false:表示在传输文件前首先chroot到path参数所指定的目录下。这样作的缘由是实现额外的安全防御,但缺点是须要以roots权限,而且不能备份指向外部的符号链接所指向的目录文件。默认状况下chroot值为true,若是你的数据当中有软链接文件,阿铭建议你设置成false。
[root@axiang01 ~]# rsync --daemon 开启rsync监听服务 [root@axiang01 ~]# ps aux | grep rsync 查看进程 root 2291 0.0 0.0 114644 544 ? Ss 13:57 0:00 rsync --daemon root 2295 0.0 0.0 112664 968 pts/0 S+ 13:58 0:00 grep --color=auto rsync [root@axiang01 ~]# netstat -lntp 查看监听端口号,如修改须要重启监听 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:22 0.0.0.0:* LISTEN 1041/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1606/master tcp 0 0 192.168.83.11:873 0.0.0.0:* LISTEN 2291/rsync tcp6 0 0 :::22 :::* LISTEN 1041/sshd tcp6 0 0 ::1:25 :::* LISTEN 1606/master [root@axiang01 ~]# vim /etc/rsyncd.conf 修改监听配置
[root@axiang01 ~]# mkdir /tmp/rsync 须要手动建立源目录 [root@axiang01 ~]# chmod 777 /tmp/rsync/ 添加权限 [root@axiang01 ~]# systemctl stop firewalld 关闭firewalld(默认组织非22端口监听) [root@axiang01 ~]# cat /var/log/rsync.log 能够查看同步log日志 [root@axiang01 ~]# cd /tmp/rsync/ [root@axiang01 /tmp/rsync]# ln -s /etc/passwd ./soflink.txt 建立软连接测试用
//axiang02上的命令 [root@axiang02 ~]# systemctl stop firewalld [root@axiang02 ~]# telnet 192.168.83.11 873 测试端口访问 [root@axiang02 ~]# rsync -avP /tmp/axiang.txt 192.168.83.11::test/axiang-02 推送文件测试 [root@axiang02 ~]# rsync -avLP 192.168.83.11::test/ /tmp/test/ 同步目录 [root@axiang02 ~]# ls -l /tmp/test 总用量 8 -rw-r--r--. 1 root root 1041 7月 18 22:32 axiang-02 -rw-r--r--. 1 root root 1041 7月 18 22:32 soflink.txt 软连接被拉过来了
max connections:指定最大的链接数,默认是0,即没有限制。 read only ture|false:若是为true,则不能上传到该模块指定的路径下。 list:表示当用户查询该服务器上的可用模块时,该模块是否被列出,设定为true则列出,false则隐藏。建议false。避免被他人查看到`rsync --port=666 192.168.83.11`  uid/gid:指定传输文件时以哪一个用户/组的身份传输。 改成nobody写不了 auth users:指定传输时要使用的用户名。 secrets file:指定密码文件,该参数连同上面的参数若是不指定,则不使用密码验证。注意该密码文件的权限必定要是600。格式:用户名:密码 hosts allow:表示被容许链接该模块的主机,能够是IP或者网段,若是是多个,中间用空格隔开。 当设置了auth users和secrets file后,客户端连服务端也须要用用户名密码了,若想在命令行中带上密码,能够设定一个密码文件 rsync -avL test@192.168.133.130::test/test1/ /tmp/test8/ --password-file=/etc/pass 其中/etc/pass内容就是一个密码,权限要改成600
[root@axiang01 /tmp/rsync]# killall rsync //关闭rsync进程 [root@axiang01 /tmp/rsync]# !ps ps aux | grep rsync root 2507 0.0 0.0 112664 972 pts/0 R+ 15:57 0:00 grep --color=auto rsync [root@axiang01 /tmp/rsync]# vim /etc/rsyncd.conf //修改rsync.conf端口 [root@axiang01 /tmp/rsync]# rsync --daemon [root@axiang01 /tmp/rsync]# ps aux | grep rsync root 2520 0.2 0.0 114644 540 ? Ss 15:59 0:00 rsync --daemon root 2522 0.0 0.0 112664 968 pts/0 S+ 15:59 0:00 grep --color=auto rsync [root@axiang01 /tmp/rsync]# !net netstat -lntp 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:22 0.0.0.0:* LISTEN 1041/sshd tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1606/master tcp 0 0 192.168.83.11:666 0.0.0.0:* LISTEN 2520/rsync tcp6 0 0 :::22 :::* LISTEN 1041/sshd tcp6 0 0 ::1:25 :::* LISTEN 1606/master [root@axiang01 /tmp/rsync]#
//--port指定端口 [root@axiang02 ~]# rsync -avLP 192.168.83.11::test/ /tmp/test/ --port 666 receiving incremental file list sent 26 bytes received 91 bytes 234.00 bytes/sec total size is 2082 speedup is 17.79
开启同步密码 tcp
//开启同步密码后,IP地址须要加名字了! [root@axiang02 ~]# rsync -avLP test@192.168.83.11::test/ /tmp/test/ Password: receiving incremental file list sent 54 bytes received 148 bytes 9.40 bytes/sec total size is 2082 speedup is 10.31 //若是客户端不想输入密码 [root@axiang02 ~]# vi /etc/rsync_pass.txt [root@axiang02 ~]# chmod 600 /etc/rsync_pass.txt //同步时调用密码文档--password-file=/xxx [root@axiang02 ~]# rsync -avLP test@192.168.83.11::test/ /tmp/test/ --password-file=/etc/rsync_pass.txt receiving incremental file list sent 54 bytes received 148 bytes 134.67 bytes/sec total size is 2082 speedup is 10.31 [root@axiang02 ~]#
愈来愈多的服务的启动及运行,常常会遇到问题,除了关注屏幕报错,还要关注具体的错误日志信息。看日志很是重要工具
/var/log/messages Linux系统总日志测试
dmesg命令
/var/log/dmesg 日志,
last命令
lastb命令
/var/log/secure
yum install -y screen screen //直接回车就进入了虚拟终端 vmstat [ctral-a]+[d] //将Screen丢到后台 screen -ls //查看现有虚拟终端列表 screen -r xxx //进入指定的终端 exit //删除screen screen -S yyy //指定screen名,省的忘了screen是干啥的 screen -ls screen -r yyy //用指定名进入