rsync

rsync

文章目录

  • rsync
    • 1. rsync简介
    • 2. rsync特性
    • 3. rsync的ssh认证协议
    • 4. rsync命令
    • 5. rsync+inotify

1. rsync简介

rsynclinux系统下的数据镜像备份工具。使用快速增量备份工具Remote Sync可以远程同步,支持本地复制,或者与其他SSHrsync主机同步。

2. rsync特性

rsync支持很多特性:

  • 可以镜像保存整个目录树和文件系统
  • 可以很容易做到保持原来文件的权限、时间、软硬链接等等
  • 无须特殊权限即可安装
  • 快速:第一次同步时rsync会复制全部内容,但在下一次只传输修改过的文件。rsync在传输数据的过程中可以实行压缩及解压缩操作,因此可以使用更少的带宽
  • 安全:可以使用scpssh等方式来传输文件,当然也可以通过直接的socket连接
  • 支持匿名传输,以方便进行网站镜像

3. rsync的ssh认证协议

rsync命令来同步系统文件之前要先登录remote主机认证,认证过程中用到的协议有2种:

  • ssh协议
  • rsync协议
rsync server`端不用启动`rsync``daemon`进程,只要获取`remote host`的用户名和密码就可以直接`rsync`同步文件
`rsync server`端因为不用启动`daemon`进程,所以也不用配置文件`/etc/rsyncd.conf

ssh认证协议跟scp的原理是一样的,如果在同步过程中不想输入密码就用ssh-keygen -t rsa打通通道

//这种方式默认是省略了 -e ssh 的,与下面等价:
rsync -avz /SRC -e ssh root@172.16.12.129:/DEST -a  //文件宿主变化,时间戳不变-z  //压缩数据传输//当遇到要修改端口的时候,我们可以:
rsync -avz /SRC -e "ssh -p2222" root@172.16.12.129:/DEST  
//修改了ssh 协议的端口,默认是22

4. rsync命令

//Rsync的命令格式常用的有以下三种:rsync [OPTION]... SRC DESTrsync [OPTION]... SRC [USER@]HOST:DESTrsync [OPTION]... [USER@]HOST:SRC DEST//对应于以上三种命令格式,rsync有三种不同的工作模式:
1)拷贝本地文件。当SRC和DES路径信息都不包含有单个冒号":"分隔符时就启动这种工作模式。如:
[root@localhost ~]# ls
anaconda-ks.cfg  nfs.sh
[root@localhost ~]# rsync -a nfs.sh a.sh
[root@localhost ~]# ll
total 12
-rw-------. 1 root root 1453 Jun 13 19:27 anaconda-ks.cfg
-rwxr-xr-x  1 root root 1041 Aug  8 18:14 a.sh
-rwxr-xr-x  1 root root 1041 Aug  8 18:14 nfs.sh
[root@localhost ~]# ll -i
total 12
33574978 -rw-------. 1 root root 1453 Jun 13 19:27 anaconda-ks.cfg
33574979 -rwxr-xr-x  1 root root 1041 Aug  8 18:14 a.sh
33574990 -rwxr-xr-x  1 root root 1041 Aug  8 18:14 nfs.sh2)使用一个远程shell程序(如rsh、ssh)来实现将本地机器的内容拷贝到远程机器。当DST路径地址包 \
含单个冒号":"分隔符时启动该模式。如:
[root@localhost ~]# rsync -avz nfs.sh root@172.16.12.129:/root/b.sh
sending incremental file list
nfs.shsent 643 bytes  received 35 bytes  1,356.00 bytes/sec
total size is 1,041  speedup is 1.54
[root@localhost ~]# ssh root@172.16.12.129 'ls -l /root'
total 8
-rw-------. 1 root root 1454 Aug  6 04:39 anaconda-ks.cfg
-rwxr-xr-x  1 root root 1041 Aug  8  2018 b.sh3)使用一个远程shell程序(如rsh、ssh)来实现将远程机器的内容拷贝到本地机器。当SRC地址路径 \
包含单个冒号":"分隔符时启动该模式。如:
[root@localhost ~]# ls
anaconda-ks.cfg  a.sh  nfs.sh
[root@localhost ~]# rsync -avz root@172.16.12.129:/etc/yum.repos.d /root/
receiving incremental file list
yum.repos.d/
yum.repos.d/163.repo
yum.repos.d/redhat.reposent 66 bytes  received 918 bytes  1,968.00 bytes/sec
total size is 1,820  speedup is 1.85
[root@localhost ~]# ls
anaconda-ks.cfg  a.sh  nfs.sh  yum.repos.d
[root@localhost ~]# ls yum.repos.d/
163.repo  redhat.repo//rsync常用选项:-a, --archive       //归档-v, --verbose       //啰嗦模式-q, --quiet         //静默模式-r, --recursive     //递归-p, --perms         //保持原有的权限属性-z, --compress      //在传输时压缩,节省带宽,加快传输速度--delete            //在源服务器上做的删除操作也会在目标服务器上同步

5. rsync+inotify

rsync与传统的cptar备份方式相比,rsync具有安全性高、备份迅速、支持增量备份等优点,通过rsync可以解决对实时性要求不高的数据备份需求,例如定期的备份文件服务器数据到远端服务器,对本地磁盘定期做数据镜像等。
随着应用系统规模的不断扩大,对数据的安全性和可靠性也提出的更好的要求,rsync在高端业务系统中也逐渐暴露出了很多不足,首先,rsync同步数据时,需要扫描所有文件后进行比对,进行差量传输。如果文件数量达到了百万甚至千万量级,扫描所有文件将是非常耗时的。而且正在发生变化的往往是其中很少的一部分,这是非常低效的方式。其次,rsync不能实时的去监测、同步数据,虽然它可以通过linux守护进程的方式进行触发同步,但是两次触发动作一定会有时间差,这样就导致了服务端和客户端数据可能出现不一致,无法在应用故障时完全的恢复数据。基于以上原因,rsync+inotify组合出现了!

Inotify是一种强大的、细粒度的、异步的文件系统事件监控机制,linux内核从2.6.13起,加入了Inotify支持,通过Inotify可以监控文件系统中添加、删除,修改、移动等各种细微事件,利用这个内核接口,第三方软件就可以监控文件系统下文件的各种变化情况,而inotify-tools就是这样的一个第三方软件。
在前面有讲到,rsync可以实现触发式的文件同步,但是通过crontab守护进程方式进行触发,同步的数据和实际数据会有差异,而inotify可以监控文件系统的各种变化,当文件有任何变动时,就触发rsync同步,这样刚好解决了同步数据的实时性问题。

环境说明:

服务器类型IP地址应用操作系统
源服务器172.16.12.128rsync inotify-tools 脚本centos7/redhat7
目标服务器172.16.12.129rsynccentos7/redhat7

需求:

  • 把源服务器上/etc目录实时同步到目标服务器的/tmp/下

在目标服务器上做以下操作:

//关闭防火墙与SELINUX
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/sysconfig/selinux//安装rsync服务端软件
[root@localhost ~]# yum -y install rsync
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
myrepo                                          | 4.1 kB     00:00
(1/2): myrepo/group_gz                            | 137 kB   00:00
(2/2): myrepo/primary_db                          | 4.0 MB   00:00
Resolving Dependencies
--> Running transaction check
---> Package rsync.x86_64 0:3.0.9-18.el7 will be installed
......
myrepo/productid                                | 1.6 kB     00:00Verifying  : rsync-3.0.9-18.el7.x86_64                           1/1Installed:rsync.x86_64 0:3.0.9-18.el7Complete!//设置rsyncd.conf配置文件
[root@localhost ~]# cat >> /etc/rsyncd.conf <<EOF
log file = /var/log/rsyncd.log    # 日志文件位置,启动rsync后自动产生这个文件,无需提前创建
pidfile = /var/run/rsyncd.pid     # pid文件的存放位置
lock file = /var/run/rsync.lock   # 支持max connections参数的锁文件
secrets file = /etc/rsync.pass    # 用户认证配置文件,里面保存用户名称和密码,必须手动创建这个文件[etc_from_client]     # 自定义同步名称
path = /tmp/          # rsync服务端数据存放路径,客户端的数据将同步至此目录
comment = sync etc from client
uid = root        # 设置rsync运行权限为root
gid = root        # 设置rsync运行权限为root
port = 873        # 默认端口
ignore errors     # 表示出现错误忽略错误
use chroot = no       # 默认为true,修改为no,增加对目录文件软连接的备份
read only = no    # 设置rsync服务端为读写权限
list = no     # 不显示rsync服务端资源列表
max connections = 200     # 最大连接数
timeout = 600     # 设置超时时间
auth users = admin        # 执行数据同步的用户名,可以设置多个,用英文状态下逗号隔开
hosts allow = 172.16.12.128   # 允许进行数据同步的客户端IP地址,可以设置多个,用英文状态下逗号隔开
hosts deny = 192.168.1.1      # 禁止数据同步的客户端IP地址,可以设置多个,用英文状态下逗号隔开
EOF//创建用户认证文件
[root@localhost ~]# echo 'admin:123456' > /etc/rsync.pass
[root@localhost ~]# cat /etc/rsync.pass
admin:123456//设置文件权限
[root@localhost ~]# chmod 600 /etc/rsync*
[root@localhost ~]# ll /etc/rsync*
-rw-------. 1 root root 802 Aug  9 22:45 /etc/rsyncd.conf
-rw-------. 1 root root  13 Aug  9 22:47 /etc/rsync.pass//启动rsync服务并设置开机自启动
[root@localhost ~]# systemctl start rsyncd
[root@localhost ~]# systemctl enable rsyncd
Created symlink from /etc/systemd/system/multi-user.target.wants/rsyncd.service to /usr/lib/systemd/system/rsyncd.service.
[root@localhost ~]# ss -antl
State       Recv-Q Send-Q Local Address:Port               Peer Address:Port
LISTEN      0      128     *:22                  *:*
LISTEN      0      100    127.0.0.1:25                  *:*
LISTEN      0      5       *:873                 *:*
LISTEN      0      128    :::22                 :::*
LISTEN      0      100       ::1:25                 :::*
LISTEN      0      5      :::873                :::*

在源服务器上做以下操作:

/关闭防火墙与SELINUX
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# getenforce
Enforcing
[root@localhost ~]# setenforce 0
[root@localhost ~]# sed -ri 's/^(SELINUX=).*/\1disabled/g' /etc/sysconfig/selinux//配置yum源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
--2018-08-10 12:07:17--  http://mirrors.163.com/.help/CentOS7-Base-163.repo
Resolving mirrors.163.com (mirrors.163.com)... 59.111.0.251
Connecting to mirrors.163.com (mirrors.163.com)|59.111.0.251|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1572 (1.5K) [application/octet-stream]
Saving to: ‘CentOS7-Base-163.repo’100%[=================================>] 1,572       --.-K/s   in 0s2018-08-10 12:07:17 (191 MB/s) - ‘CentOS7-Base-163.repo’ saved [1572/1572]
[root@localhost ~]# sed -i 's/\$releasever/7/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[root@localhost ~]# sed -i 's/^enabled=.*/enabled=1/g' /etc/yum.repos.d/CentOS7-Base-163.repo
[root@localhost ~]# yum -y install epel-release
安装过程略。。。。//安装rsync服务端软件,只需要安装,不要启动,不需要配置
[root@localhost ~]# yum -y install rsync
Loaded plugins: product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
myrepo                                          | 4.1 kB     00:00
(1/2): myrepo/group_gz                            | 137 kB   00:00
(2/2): myrepo/primary_db                          | 4.0 MB   00:00
Resolving Dependencies
--> Running transaction check
---> Package rsync.x86_64 0:3.0.9-18.el7 will be installed
......
myrepo/productid                                | 1.6 kB     00:00Verifying  : rsync-3.0.9-18.el7.x86_64                           1/1Installed:rsync.x86_64 0:3.0.9-18.el7Complete!//创建认证密码文件
[root@localhost ~]# echo '123456' > /etc/rsync.pass
[root@localhost ~]# cat /etc/rsync.pass
123456//设置文件权限,只设置文件所有者具有读取、写入权限即可
[root@localhost ~]# chmod 600 /etc/rsync.pass
[root@localhost ~]# ll /etc/rsync.pass
-rw------- 1 root root 7 Aug 10 11:40 /etc/rsync.pass//在源服务器上创建测试目录,然后在源服务器运行以下命令
[root@localhost ~]# ls
anaconda-ks.cfg
[root@localhost ~]# mkdir -pv /root/etc/test
mkdir: created directory ‘/root/etc’
mkdir: created directory ‘/root/etc/test’
[root@localhost ~]# rsync -avH --port 873 --progress --delete /root/etc/ admin@172.16.12.129::etc_from_client --password-file=/etc/rsync.pass
sending incremental file list
./
deleting systemd-private-899c38a51df749efb3104e68d77739ff-vmtoolsd.service-28tQpq/tmp/vmware-root/
deleting systemd-private-899c38a51df749efb3104e68d77739ff-vmtoolsd.service-28tQpq/tmp/
deleting systemd-private-899c38a51df749efb3104e68d77739ff-vmtoolsd.service-28tQpq/
deleting systemd-private-899c38a51df749efb3104e68d77739ff-vgauthd.service-0QH6Vs/tmp/
deleting systemd-private-899c38a51df749efb3104e68d77739ff-vgauthd.service-0QH6Vs/
deleting systemd-private-899c38a51df749efb3104e68d77739ff-chronyd.service-4Z4q8n/tmp/
deleting systemd-private-899c38a51df749efb3104e68d77739ff-chronyd.service-4Z4q8n/
deleting .font-unix/
deleting .XIM-unix/
deleting .X11-unix/
deleting .Test-unix/
deleting .ICE-unix/
deleting yum.log
deleting ks-script-G8Z8sn
test/sent 49 bytes  received 15 bytes  128.00 bytes/sec
total size is 0  speedup is 0.00
//运行完成后,在目标服务器上查看,在/tmp目录下有test目录,说明数据同步成功//安装inotify-tools工具,实时触发rsync进行同步
//查看服务器内核是否支持inotify
[root@localhost ~]# ll /proc/sys/fs/inotify/
total 0
-rw-r--r-- 1 root root 0 Aug 10 11:19 max_queued_events
-rw-r--r-- 1 root root 0 Aug 10 11:19 max_user_instances
-rw-r--r-- 1 root root 0 Aug 10 11:19 max_user_watches
//如果有这三个max开头的文件则表示服务器内核支持inotify//安装inotify-tools
[root@localhost ~]# yum -y install make gcc gcc-c++
安装过程略....
[root@localhost ~]# yum -y install inotify-tools
安装过程略....//写同步脚本,此步乃最最重要的一步,请慎之又慎。让脚本自动去检测我们制定的目录下 \
//文件发生的变化,然后再执行rsync的命令把它同步到我们的服务器端去
[root@localhost ~]# mkdir /scripts
[root@localhost ~]# touch /scripts/inotify.sh
[root@localhost ~]# chmod 755 /scripts/inotify.sh
[root@localhost ~]# ll /scripts/inotify.sh
-rwxr-xr-x 1 root root 0 Aug 10 13:02 /scripts/inotify.sh
[root@localhost ~]# vim /scripts/inotify.sh
host=172.16.12.129      # 目标服务器的ip(备份服务器)
src=/etc        # 在源服务器上所要监控的备份目录(此处可以自定义,但是要保证存在)
des=etc_from_client     # 自定义的模块名,需要与目标服务器上定义的同步名称一致
password=/etc/rsync.pass        # 执行数据同步的密码文件
user=admin          # 执行数据同步的用户名
inotifywait=/usr/bin/inotifywait$inotifywait -mrq --timefmt '%Y%m%d %H:%M' --format '%T %w%f%e' -e modify,delete,create,attrib $src \
| while read files;dorsync -avzP --delete  --timeout=100 --password-file=${password} $src $user@$host::$desecho "${files} was rsynced" >>/tmp/rsync.log 2>&1
done//启动脚本
[root@localhost ~]# nohup bash /scripts/inotify.sh &
[1] 86871
[root@localhost ~]# nohup: ignoring input and appending output to ‘nohup.out’[root@localhost ~]# ps -ef|grep inotify
root      86871   2143  0 14:52 pts/0    00:00:00 bash /scripts/inotify.sh
root      86872  86871  0 14:52 pts/0    00:00:00 /usr/bin/inotifywait -mrq --timefmt %Y%m%d %H:%M --format %T %w%f%e -e modify,delete,create,attrib /etc
root      86873  86871  0 14:52 pts/0    00:00:00 bash /scripts/inotify.sh
root      86875   2143  0 14:52 pts/0    00:00:00 grep --color=auto inotify//在源服务器上生成一个新文件
[root@localhost ~]# ls /etc/httpd24/
extra  httpd.conf  magic  mime.types  original
[root@localhost ~]# echo 'hello world' > /etc/httpd24/test//查看inotify生成的日志
[root@localhost ~]# tail /tmp/rsync.log
20180810 14:59 /etc/httpd24/testCREATE was rsynced
20180810 14:59 /etc/httpd24/testMODIFY was rsynced
//从日志上可以看到,我们生成了一个test文件,并且添加了内容到其里面

设置脚本开机自动启动:

[root@localhost ~]# chmod +x /etc/rc.d/rc.local
[root@localhost ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x 1 root root 473 Aug 10 23:23 /etc/rc.d/rc.local
[root@localhost ~]# echo 'nohup /bin/bash /scripts/inotify.sh' >> /etc/rc.d/rc.local
[root@localhost ~]# tail /etc/rc.d/rc.local
# to run scripts during boot instead of using this file.
#
# In contrast to previous versions due to parallel execution during boot
# this script will NOT be run after all other services.
#
# Please note that you must run 'chmod +x /etc/rc.d/rc.local' to ensure
# that this script will be executed during boot.touch /var/lock/subsys/local
nohup /bin/bash /scripts/inotify.sh

到目标服务器上去查看是否把新生成的文件自动传上去了:

[root@localhost tmp]# pwd
/tmp
[root@localhost tmp]# ls
etc  test
[root@localhost tmp]# ls etc/httpd24/
extra  httpd.conf  magic  mime.types  original  test//由此可见,已将源服务器的/etc目录整个同步到了目标服务器,且新增的test文件也自动同步了
o ensure
# that this script will be executed during boot.touch /var/lock/subsys/local
nohup /bin/bash /scripts/inotify.sh

到目标服务器上去查看是否把新生成的文件自动传上去了:

[root@localhost tmp]# pwd
/tmp
[root@localhost tmp]# ls
etc  test
[root@localhost tmp]# ls etc/httpd24/
extra  httpd.conf  magic  mime.types  original  test//由此可见,已将源服务器的/etc目录整个同步到了目标服务器,且新增的test文件也自动同步了

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/627957.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Kafka 集群部署

目录 1、环境准备 2、搭建ZooKeeper集群 配置文件 节点标记 环境变量 启动集群 数据同步测试 故障测试 3、搭建 Kafka 集群 配置文件 环境变量 配置其他机器 启动服务 4、集群测试 创建 Topic 显示 Topic 配置 创建 Producer 创建consumer 删除Topic 查看Z…

代码随想录算法训练营第21天 | 530.二叉搜索树的最小绝对差 + 501.二叉搜索树中的众数 + 236.二叉树的最近公共祖先

今日任务 530.二叉搜索树的最小绝对差 - Easy 501.二叉搜索树中的众数 - Easy 236.二叉树的最近公共祖先 - Medium 530.二叉搜索树的最小绝对差 - Easy 题目链接&#xff1a;力扣-530. 二叉搜索树的最小绝对差 给你一个二叉搜索树的根节点 root &#xff0c;返回 树中任意两…

Postgres操作jsonb数据

Postgres操作jsonb数据 PostgreSQL 对 jsonb 类型的筛选查询可以使用 -> 或者 ->> 操作符。 -> 操作符用于通过 JSON 对象中的键来获取对应的值。 ->> 操作符可以将获取到的值转化为字符串类型。 1 查询 -- 数据准备 CREATE TABLE test (id SERIAL PRIMARY …

windows下的私钥权限管理

被问到Windows的私钥是否可以共享给多个用户&#xff0c;我们知道CNG创建的私钥&#xff0c;压根就没有提供跨用户和组的机制&#xff0c;因此无论对称还是非对称&#xff0c;CNG中的私钥没办法在用户间共享。 Windows支持的SACL中的访问客体&#xff0c;也不包括密钥。 但是…

Vulnhub靶机:driftingblues 6

一、介绍 运行环境&#xff1a;Virtualbox 攻击机&#xff1a;kali&#xff08;10.0.2.15&#xff09; 靶机&#xff1a;driftingblues6&#xff08;10.0.2.22&#xff09; 目标&#xff1a;获取靶机root权限和flag 靶机下载地址&#xff1a;https://www.vulnhub.com/entr…

服务拆分及远程调用

分布式架构都离不开服务的拆分&#xff0c;微服务也是一样。 1.微服务拆分 不同微服务&#xff0c;不要重复开发相同业务 微服务数据独立&#xff0c;不要访问其它微服务的数据库 微服务可以将自己的业务暴露为接口&#xff0c;供其它微服务调用 2.远程调用 以前时&#xf…

如何在Linux中使用~/.bashrc配置Java环境变量

为什么使用 ~/.bashrc 而不是 ~/.profile 原因 ~/.bashrc和~/.profile&#xff08;或在某些系统中是~/.bash_profile或~/.bash_login&#xff09;是用来配置用户的shell环境的两个不同的文件。它们的主要区别在于它们被加载的时机和适用的场合&#xff1a; ~/.bashrc主要用于…

1 python计算机基础

计算机基础和环境搭建 1 计算机基础和环境搭建1.计算机基础1.1 基本概念1.2 编程语言1.3 编译器/解释器 2.学习编程的本质3.Python的介绍3.1 语言的分类3.2 Python3.3 Python的解释器种类&#xff08;了解&#xff09;3.4 CPython解释器的版本 4.环境搭建4.1 安装Python解释器4…

关于C#中Monitor的wait/pulse的理解

wait&#xff1a;表示释放对象上的锁并阻止当前线程&#xff0c;直到它重新获取该锁。 pulse&#xff1a;表示通知等待队列中的线程锁定对象状态的更改。 当线程调用 Wait 时&#xff0c;它会释放对象上的锁并进入对象的等待队列。 对象的就绪队列中的下一个线程 (如果有一个…

Matlab交互式的局部放大图

在数据可视化中&#xff0c;很多时候需要对某一区间的数据进行局部放大&#xff0c;以获得对比度更高的可视化效果。下面利用 MATLAB 语言实现一个交互式的局部放大图绘制。 源码自行下载&#xff1a; 链接&#xff1a;https://pan.baidu.com/s/1yItVSinh6vU4ImlbZW6Deg?pwd9d…

《2023年度程序员收入报告》 :旧金山位居第一,北京程序员中位数超60万元

2024年刚刚拉开序幕&#xff0c;备受瞩目的程序员薪资调研报告再度登场。由知名数据采集平台levels.fyi 搜集并整理了《2023年全球程序员收入报告》&#xff0c;为我们揭示了程序员最新的收入情况&#xff0c;其中有哪些值得关注的亮点呢&#xff1f; 行情向好&#xff0c;大多…

burp靶场——XXE注入

XML 外部实体 (XXE) 注入 1. 什么是xxe漏洞&#xff1a; https://portswigger.net/web-security/xxe#what-is-xml-external-entity-injection XML 外部实体注入&#xff08;也称为 XXE&#xff09;是一种 Web 安全漏洞&#xff0c;允许攻击者干扰应用程序对 XML 数据的处理。…

GEE:机器学习分类中每个类别的概率图像可视化

作者:CSDN @ _养乐多_ 在 Google Earth Engine(GEE) 中应用机器学习分类器进行多分类时,有一个需求是想知道每个像素对于每个类别的分类概率。 比如在进行随机森林分类时,每个决策树会生成一个类别,通过投票选择票数最多的类别作为最终分类。除了最终分类结果,其他类别…

Pandas.DataFrame.groupby() 数据分组(数据透视、分类汇总) 详解 含代码 含测试数据集 随Pandas版本持续更新

关于Pandas版本&#xff1a; 本文基于 pandas2.1.2 编写。 关于本文内容更新&#xff1a; 随着pandas的stable版本更迭&#xff0c;本文持续更新&#xff0c;不断完善补充。 Pandas稳定版更新及变动内容整合专题&#xff1a; Pandas稳定版更新及变动迭持续更新。 Pandas API参…

计算机组成原理 运输层

文章目录 运输层运输层协议概述进程之间的通信运输层的两个主要协议运输层的端口 用户数据报协议 UDPUDP 概述UDP 的首部格式 传输控制协议 TCP 概述TCP 最主要的特点TCP 的连接 可靠传输的工作原理停止等待协议连续 ARQ协议 TCP 报文段的首部格式TCP 可靠传输的实现以字节为单…

TensorRT模型优化部署 (八)--模型剪枝Pruning

系列文章目录 第一章 TensorRT优化部署&#xff08;一&#xff09;–TensorRT和ONNX基础 第二章 TensorRT优化部署&#xff08;二&#xff09;–剖析ONNX架构 第三章 TensorRT优化部署&#xff08;三&#xff09;–ONNX注册算子 第四章 TensorRT模型优化部署&#xff08;四&am…

Go-安装与基础语法

TOC 1. Go 安装与环境变量 1.1 下载 需要从Go语言的官方网站下载适合你操作系统的Go语言安装包。Go语言支持多种操作系统&#xff0c;包括Windows、Linux和Mac OS。 对于Windows用户&#xff0c;下载.msi文件&#xff0c;然后双击该文件&#xff0c;按照提示进行安装即可。…

python的装饰器详解

目录 一&#xff1a;介绍 二&#xff1a;在方法中使用 三&#xff1a;在类中使用 四&#xff1a;python自带的装饰器 一&#xff1a;介绍 Python的装饰器是一种高阶函数&#xff0c;它允许你在不改变函数内部逻辑的情况下&#xff0c;给函数添加额外的功能。装饰器本质上是…

剖析setinterval用法

1 基本语法 JavaScript&#xff1a;setInterval() 用法详解_js setinterval-CSDN博客 setInterval() 是 JavaScript 中的一个内置函数&#xff0c;它用于在指定的间隔时间内重复执行一段代码&#xff0c;实现周期性操作。该函数的语法如下&#xff1a; setInterval(function…