10.32 rsync 通过服务同步 上

rsyncd.conf 样例 port=873 log file=/var/log/rsync.log pid file=/var/run/rsync.pid address=192.168.104.160 [test] path=/tmp/rsync use chroot=true max connections=4 read only=no list=true uid=root gid=root #auth users=test #sectets file=/etc/rsyncd.passwd hosts allow=192.168.104.165

	[root@aming-01 ~]# vi /etc/rsyncd.conf 
	[root@aming-01 ~]# rsync --daemon
	[root@aming-01 ~]# ps aux|grep rsync
	root       1380  0.0  0.0 114652   524 ?        Ss   05:37   0:00 rsync --daemon
	root       1382  0.0  0.0 112676   984 pts/0    S+   05:37   0:00 grep --color=auto rsync

	[root@aming-01 ~]# mkdir /tmp/rsync
	[root@aming-01 ~]# chmod 777 /tmp/rsync

	[root@aming-02 ~]# rsync -avP /tmp/aming.txt 192.168.104.160::test/aming-02.txt
	rsync: failed to connect to 192.168.104.160 (192.168.104.160): No route to host (113)
	rsync error: error in socket IO (code 10) at clientserver.c(122) [sender=3.0.9]

	[root@aming-02 ~]# systemctl stop firewalld.service
	[root@aming-01 ~]# systemctl stop firewalld.service
	[root@aming-02 ~]# telnet 192.168.104.160 873
	Trying 192.168.104.160...
	Connected to 192.168.104.160.
	Escape character is '^]'.
	@RSYNCD: 30.0

	[root@aming-02 ~]# rsync -avP /tmp/aming.txt 192.168.104.160::test/aming-02.txt
	sending incremental file list
	aming.txt
	        1054 100%    0.00kB/s    0:00:00 (xfer#1, to-check=0/1)

	sent 1127 bytes  received 27 bytes  2308.00 bytes/sec
	total size is 1054  speedup is 0.91


rsyncd.conf 配置文件详解

	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@aming-01 ~]# killall rsync
		[root@aming-01 ~]# ps aux|grep rsync
		ps aux|grep rsync
		root       2533  0.0  0.0 112676   984 pts/0    S+   07:11   0:00 grep --color=auto rsync
		[root@aming-01 ~]# rsync --daemon
		[root@aming-01 ~]# ps aux|grep rsync
		root       2535  0.0  0.0 114652   524 ?        Ss   07:11   0:00 rsync --daemon
		root       2537  0.0  0.0 112676   984 pts/0    R+   07:11   0:00 grep --color=auto rsync

		[root@aming-02 ~]# rsync -avLP --port 8730 192.168.104.160::test/ /tmp/test/
		receiving incremental file list
		created directory /tmp/test
		./
		aming-02.txt
		        1054 100%    1.01MB/s    0:00:00 (xfer#1, to-check=0/2)

		sent 48 bytes  received 1178 bytes  817.33 bytes/sec
		total size is 1054  speedup is 0.86

10.33 rsync 通过服务同步 下

max connections:指定最大的连接数,默认是0,即没有限制。
read only ture|false:如果为true,则不能上传到该模块指定的路径下。
list: 表示当用户查询该服务器上的可用模块时,该模块是否被列出,设定为true则列出,false则隐藏。
uid/gid:指定传输文件时以哪个用户/组的身份传输。
auth users:指定传输时要使用的用户名。
secrets file:指定密码文件,该参数连同上面的参数如果不指定,则不适用密码验证。注意改密码文件的权限一定要是600。格式:用户名:密码
hosts allow:表示被允许连接该模块的主机,可以是IP或者网段,如果是多个,中间用空格隔开。
当设置了auth users和secrets file 后,客户端连服务器也需要用用户名密码了,若想在命令行中带上密码,可以设定一个密码文件
rsync -avL test@192.168.104.160::test/test1/ /tmp/test8/ --passwd-file=/etc/pass
其中 /etc/pass 内容就是一个密码,权限要改为600


list=true
		[root@aming-02 ~]# rsync --port=8730 192.168.104.160::
		test 



		[root@aming-01 ~]# vi /etc/rsyncd.conf
		auth users=test
		sectets file=/etc/rsyncd.passwd    //去掉注释
		[root@aming-01 ~]# vi /etc/rsyncd.passwd
		test:aming   //添加
		[root@aming-01 ~]# chmod 600 /etc/rsyncd.passwd

		[root@aming-02 ~]# vi /etc/rsync_pass.txt
		aming   //只写密码
		[root@aming-02 ~]# chmod 600 /etc/rsync_pass.txt

	#####

10.34 Linux系统日志

/var/log/messages
/etc/logrotate.conf     日志切割配置文件
参考 https://my.oschina.net/u/2000675/blog/908189

dmesg 命令 (硬件问题基本都是在这里查看报错信息)
/var/log/dmesg  日志
last 命令,调用的文件是 /var/log/wtmp
lastb 命令查看登陆失败的用户,对应的文件是  /var/log/btmp
/var/log/secure


	[root@aming-01 ~]# cat /etc/logrotate.conf 
	# see "man logrotate" for details
	# rotate log files weekly
	weekly

	# keep 4 weeks worth of backlogs
	rotate 4

	# create new (empty) log files after rotating old ones
	create

	# use date as a suffix of the rotated file
	dateext

	# uncomment this if you want your log files compressed
	#compress

	# RPM packages drop log rotation information into this directory
	include /etc/logrotate.d

	# no packages own wtmp and btmp -- we'll rotate them here
	/var/log/wtmp {
	    monthly
	    create 0664 root utmp
		minsize 1M
	    rotate 1
	}

	/var/log/btmp {
	    missingok
	    monthly
	    create 0600 root utmp
	    rotate 1
	}

	# system-specific logs may be also be configured here.


	[root@aming-01 ~]# cat /etc/logrotate.d/syslog 
	/var/log/cron
	/var/log/maillog
	/var/log/messages
	/var/log/secure
	/var/log/spooler
	{
	    missingok
	    sharedscripts
	    postrotate
		/bin/kill -HUP `cat /var/run/syslogd.pid 2> /dev/null` 2> /dev/null || true
	    endscript
	}


	[root@aming-01 ~]# last
	root     pts/0        192.168.104.1    Sun Mar 11 22:15   still logged in   
	reboot   system boot  3.10.0-693.17.1. Sun Mar 11 22:14 - 04:25  (06:10)    
	root     pts/0        192.168.104.1    Sun Mar 11 05:17 - down   (02:11)    
	reboot   system boot  3.10.0-693.17.1. Sun Mar 11 05:15 - 07:29  (02:13)    
	root     pts/0        192.168.104.1    Sat Mar 10 03:42 - down   (03:29)    
	reboot   system boot  3.10.0-693.17.1. Sat Mar 10 03:35 - 07:12  (03:37)

10.35 screen 工具

为了不让一个任务中断
nohup command &
screen 是一个虚拟终端
yum install -y screen
screen 直接回车就进入了虚拟终端
ctrl+a 组合键再按d退出虚拟终端,但不是结束
screen -ls  查看虚拟终端列表
screen -r id 进入指定的终端
screen -S aming
screen -r aming