Ansible常用模块
华子目录
- Ansible四个命令模块
- 1.组成
- 2.特点
- 3.区别
- 3.1`command、shell`模块
- 3.2`raw`模块
- 4.`command`模块
- 4.1参数表
- 4.2`free_form`参数
- 5.`shell`模块
- 5.1作用
- 5.2例如
- 6.`script`模块
- 6.1示例
- 7.`raw`模块
- 7.1参数
- 7.2示例
- 文件操作模块
- 1.`file`模块
- 1.1参数
- 1.2示例
- 2.copy模块
- 2.1参数
Ansible四个命令模块
1.组成
command、shell、raw
2.特点
应尽量避免
使用这三个模块
来执行命令,因为其他模块大部分都是幂等性
的,可以自动进行更改跟踪。幂等性
:输入相同,输出相同,无论多少次执行
。比如说确认接口,如果传入订单号,返回确认ok
,如果已经确认过了
,再次调用确认接口,返回如果还是确认ok
,那么这个接口
就是满足幂等性
command、shell、raw不具备幂等性
3.区别
3.1command、shell
模块
- 相同点:要求受管主机上安装
python
- 不同点:
command
可以在受管主机上执行Linux命令
,但是不支持环境变量和操作符(例如'|' '<' '>' '&'
),shell模块
需要调用/bin/sh
指令执行
3.2raw
模块
- 不需要受管主机安装
python
,直接使用远程shell
运行命令,通常用于无法安装python的系统(例如:网络设备等)
4.command
模块
4.1参数表
名称 | 必选 | 备注 |
---|---|---|
chdir | no(不是必选参数) | 运行command命令前先cd到这个目录 |
creates | no | 如果这个参数对应的文件存在,就不运行command |
free_form | yes | 需要执行的脚本(没有真正的参数为free_form) |
executable | no | 改变用来执行命令的shell,是可执行文件的绝对路径 |
removes | no | 如果这个参数对应的文件不存在,就不运行command,与creates参数作用相反 |
stdin | no | 2.4后的新增,将命令的stdin设置为指定的值 |
4.2free_form
参数
必须参数
,指定需要远程执行的命令。
free_form 参数与其他参数(如果想要使用一个参数,那么则需要为这个参数赋值,也就是name=value模式)并不相同。
- 如:需要在
远程主机
上执行ls
命令时,错误
写法:free_form=ls
,因为并没有任何参数
的名字是free_form
,若要在远程主机中执行ls
命令时,直接
写成ls
即可。因为command
模块的作用是执行命令
,所以任何一个可以在远程主机上执行的命令
都可以被称为free_form
- 例:
[root@server ~]# ansible-inventory --graph #分组查看
@all:|--@ungrouped:| |--node1.example.com| |--node2.example.com
[root@server ~]# ansible all -m command -a "ls /root" #查看目录
node2.example.com | CHANGED | rc=0 >>
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
node1.example.com | CHANGED | rc=0 >>
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
frp_0.56.0_linux_amd64
frp_0.56.0_linux_amd64.tar.gz
mysql-8.0.37-linux-glibc2.17-x86_64.tar.xz
[root@server ~]# ansible all -m command -a "cd /"
node2.example.com | CHANGED | rc=0 >>node1.example.com | CHANGED | rc=0 >>
[root@server ~]# ansible all -m command -a "pwd"
node2.example.com | CHANGED | rc=0 >>
/root
node1.example.com | CHANGED | rc=0 >>
/root
[root@server ~]# ansible all -m command -a "touch file.ansible"
node1.example.com | CHANGED | rc=0 >>node2.example.com | CHANGED | rc=0 >>[root@node1 ~]# ls
公共 文档 模板 下载 anaconda-ks.cfg file.ansible[root@node2 ~]# ls
公共 模板 视频 anaconda-ks.cfg file.ansible
[root@server ~]# ansible all -m command -a "ls /root creates=file.ansible" #当文件file.ansible存在则就不执行前面的命令
node1.example.com | SUCCESS | rc=0 >>
skipped, since file.ansible existsDid not run command since 'file.ansible' exists
node2.example.com | SUCCESS | rc=0 >>
skipped, since file.ansible existsDid not run command since 'file.ansible' exists
[root@server ~]# ansible all -m command -a "ls /root removes=file.ansible" #当文件file.ansible不存在则就不执行前面的命令
node2.example.com | CHANGED | rc=0 >>
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
file.ansible
node1.example.com | CHANGED | rc=0 >>
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
file.ansible
frp_0.56.0_linux_amd64
frp_0.56.0_linux_amd64.tar.gz
mysql-8.0.37-linux-glibc2.17-x86_64.tar.xz
#无法使用管道符和输入输出重定向
[root@server ~]# ansible all -m command -a "echo 'hello world' > file.ansible"
node1.example.com | CHANGED | rc=0 >>
hello world > file.ansible
node2.example.com | CHANGED | rc=0 >>
hello world > file.ansible
[root@server ~]# ansible all -m command -a "cat file.ansible"
node2.example.com | CHANGED | rc=0 >>node1.example.com | CHANGED | rc=0 >>[root@server ~]# ansible all -m command -a "ls /root | grep file.ansible"
node2.example.com | FAILED | rc=2 >>
file.ansible/root:
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
file.ansiblels: 无法访问 '|': 没有那个文件或目录
ls: 无法访问 'grep': 没有那个文件或目录non-zero return code
node1.example.com | FAILED | rc=2 >>
file.ansible/root:
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
file.ansible
frp_0.56.0_linux_amd64
frp_0.56.0_linux_amd64.tar.gz
mysql-8.0.37-linux-glibc2.17-x86_64.tar.xzls: 无法访问 '|': 没有那个文件或目录
ls: 无法访问 'grep': 没有那个文件或目录non-zero return code
5.shell
模块
5.1作用
-
- 让
远程主机
在shell进程
下执行命令
,从而支持shell的特性
,如管道等
,参数
与command模块
几乎相同,但在执行命令的时候调用
的是/bin/sh
- 让
5.2例如
[root@server ~]# ansible all -m shell -a "tree chdir=/root"
node2.example.com | CHANGED | rc=0 >>
.
├── 公共
├── 模板
├── 视频
├── 图片
├── 文档
├── 下载
├── 音乐
├── 桌面
├── anaconda-ks.cfg
└── file.ansible8 directories, 2 files
node1.example.com | CHANGED | rc=0 >>
.
├── 公共
├── 模板
├── 视频
├── 图片
├── 文档
├── 下载
├── 音乐
├── 桌面
├── anaconda-ks.cfg
├── file.ansible
├── frp_0.56.0_linux_amd64
│ ├── frpc
│ ├── frpc.toml
│ └── LICENSE
├── frp_0.56.0_linux_amd64.tar.gz
└── mysql-8.0.37-linux-glibc2.17-x86_64.tar.xz9 directories, 7 files
[root@server ~]# ansible node1.example.com -m shell -a "echo 'hello world' > file.ansible"
node1.example.com | CHANGED | rc=0 >>[root@server ~]# ansible node1.example.com -m shell -a "cat /root/file.ansible"
node1.example.com | CHANGED | rc=0 >>
hello world
6.script
模块
script
与shell
类似,都可以执行脚本区别
:script
执行的脚本在ansible管理机
上,而shell
执行的脚本必须先放到目标节点
上去,才能执行shell
执行可以使用环境变量
,bash
等,但是script
只是执行.sh
脚本,不能带bash
6.1示例
- 在
server
端写一个t2.sh
的脚本
[root@server ~]# vim t2.sh
#!/bin/bash
echo "hello world"[root@server ~]# ansible all -m script -a "t2.sh"
node2.example.com | CHANGED => {"changed": true,"rc": 0,"stderr": "Shared connection to node2.example.com closed.\r\n","stderr_lines": ["Shared connection to node2.example.com closed."],"stdout": "hello world\r\n","stdout_lines": ["hello world"]
}
node1.example.com | CHANGED => {"changed": true,"rc": 0,"stderr": "Shared connection to node1.example.com closed.\r\n","stderr_lines": ["Shared connection to node1.example.com closed."],"stdout": "hello world\r\n","stdout_lines": ["hello world"]
}
- 在目标节点上
[root@node1 ~]# vim t2.sh
#!/bin/bash
echo "hello world"[root@node2 ~]# vim t2.sh
#!/bin/bash
echo "hello world"[root@server ~]# ansible all -m shell -a "bash t2.sh"
node2.example.com | CHANGED | rc=0 >>
hello world
node1.example.com | CHANGED | rc=0 >>
hello world
7.raw
模块
raw
模块主要用于执行一些低级
的命令,一般适用于下列两种场景
第一种
:在较老的(python2.4和之前的版本
)主机上执行命令第二种
:对任何
没有安装python
的设备(如路由器
)- 注意:在任何
其他情况
下,使用shell
或command
模块更为合适
7.1参数
名称 | 必选 | 备注 |
---|---|---|
executable | no(可以不选) | 改变用来执行命令的shell,是可执行文件的绝对路径 |
free_form | yes | 需要执行的脚本(没有真正的参数为free_form) |
7.2示例
[root@server ~]# ansible all -m raw -a "pwd"
node1.example.com | CHANGED | rc=0 >>
/root
Shared connection to node1.example.com closed.node2.example.com | CHANGED | rc=0 >>
/root
Shared connection to node2.example.com closed.
[root@server ~]# ansible all -m raw -a "echo 'hello world'"
node1.example.com | CHANGED | rc=0 >>
hello world
Shared connection to node1.example.com closed.node2.example.com | CHANGED | rc=0 >>
hello world
Shared connection to node2.example.com closed.
文件操作模块
1.file
模块
作用:实现对文件的基本操作
,如:创建
目录或文件,删除
目录或文件,修改文件权限
等
1.1参数
path
:必须参数
,用于指定
要操作的文件
或目录
,在之前版本的ansible
中,使用dest参数
或者name参数
指定要操作的文件或目录
,为了兼容之前的版本
,使用dest
或name
也可以state:
格式
:path=“路径” state= touch | directory | link | hard | absent
此参数
使用灵活,如:在远程主机
中创建一个目录
,则使用path参数
指定对应的目录路径
,假设在远程主机上创建/testdir/a/b
目录,则设置路径:path=/testdir/a/b
,但ansible
无法从/testdir/a/b
这个路径看出b
是一个文件
还是一个目录
,所以需要通过state
参数进行说明
参数 | 值 | 含义 |
---|---|---|
state= | absent | 删除 远程机器上的指定文件 或目录 |
state= | directory | 创建 一个空目录 |
state= | file | 查看 指定目录 是否存在 |
state= | touch | 创建 一个空文件 |
state= | hard/link | 创建 链接文件 |
-
src
:当state
设置为link
或者hard
时,表示创建一个软链
或硬链
,则必须通过指明src参数
即可指定链接源
-
force
: 当state=link
的时,使用force=yes
参数表示强制
创建链接文件
,该文件
分为三种情况
:- 当要创建的
链接文件
指向的源文件
并不存在
时,使用此参数,可以先强制
创建出链接文件
- 当
存储目录
中已经存在
与链接文件
同名的文件
时,会将同名文件
覆盖为链接文件
,相当于删除同名文件
,创建链接文件
- 当你要创建
链接文件
的目录
中已经存在
与链接文件
同名的文件,并且链接文件指向的源文件
也不存在,这时会强制替换
同名文件为链接文件
- 当要创建的
-
owner
:用于指定被操作文件的属主信息
,属主
对应的用户
必须在远程主机中存在
,否则会报错
-
group
:用于指定
被操作文件的属组
,属组
对应的组
必须在远程主机
中存在,否则会报错
-
mode
:用于指定
被操作文件
的权限
,如:- 要将
文件权限
设置为: “rw-r-x---
”,则可以使用mode=650
进行设置,或者使用mode=0650
- 要设置
特殊权限
,如:为二进制文件
设置suid
,则可以使用mode=4700
- 要将
-
recurse
:当要操作的文件
为目录
时,recurse
设置为yes
可以递归
的修改
目录中文件的属性
和权限
1.2示例
- 在所有
远程主机
上创建一个名为data
的目录,如果存在
则不做操作
[root@server ~]# ansible all -m file -a "path=/root/data state=directory"
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"gid": 0,"group": "root","mode": "0755","owner": "root","path": "/root/data","size": 6,"state": "directory","uid": 0
}
node2.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"gid": 0,"group": "root","mode": "0755","owner": "root","path": "/root/data","size": 6,"state": "directory","uid": 0
}[root@server ~]# ansible all -m command -a "ls chdir=/root"
node1.example.com | CHANGED | rc=0 >>
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
data
file.ansible
frp_0.56.0_linux_amd64
frp_0.56.0_linux_amd64.tar.gz
mysql-8.0.37-linux-glibc2.17-x86_64.tar.xz
t2.sh
node2.example.com | CHANGED | rc=0 >>
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
data
file.ansible
t2.sh
- 在
node1
主机上创建一个名为testfile1
的文件,如果testfile1
文件已经存在,则会更新
文件的时间戳
,与touch
命令的作用相同
[root@server ~]# ansible node1.example.com -m file -a "path=/root/data/testfile1 state=touch"
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/data/testfile1","gid": 0,"group": "root","mode": "0644","owner": "root","size": 0,"state": "file","uid": 0
}[root@server ~]# ansible node1.example.com -m command -a "ls chdir=/root/data"
node1.example.com | CHANGED | rc=0 >>
file1
testfile1
- 在
node1
上为testfile1
文件创建软链接
文件,软链接
名为linkfile1
[root@server ~]# ansible node1.example.com -m file -a "path=/root/data/linkfile1 state=link src=/root/data/testfile1"
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/data/linkfile1","gid": 0,"group": "root","mode": "0777","owner": "root","size": 20,"src": "/root/data/testfile1","state": "link","uid": 0
}[root@server ~]# ansible node1.example.com -m command -a "ls chdir=/root/data"
node1.example.com | CHANGED | rc=0 >>
file1
linkfile1
testfile1
- 在
node1
上为testfile1
文件创建硬链接
文件,硬链接
名为hardfile1
(类似于复制
)
[root@server ~]# ansible node1.example.com -m file -a "path=/root/data/hardfile1 state=hard src=/root/data/testfile1"
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/data/hardfile1","gid": 0,"group": "root","mode": "0644","owner": "root","size": 0,"src": "/root/data/testfile1","state": "hard","uid": 0
}[root@server ~]# ansible node1.example.com -m command -a "ls /root/data"
node1.example.com | CHANGED | rc=0 >>
file1
hardfile1
linkfile1
testfile1
- 在创建
链接
文件时,如果源文件
不存在,或者链接文件与其他文件同名
时,强制覆盖同名文件
或者创建链接文件
,参考上述force
参数的解释
[root@server ~]# ansible node1.example.com -m file -a "path=/root/data/linkfile3 state=link src=/root/data/123 force=yes" #注意:123文件不存在
[WARNING]: Cannot set fs attributes on a non-existent symlink target. follow should be
set to False to avoid this.
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/data/linkfile3","src": "/root/data/123"
}[root@server ~]# ansible node1.example.com -m command -a "ls chdir=/root/data"
node1.example.com | CHANGED | rc=0 >>
file1
hardfile1
linkfile1
linkfile3
testfile1
- 删除
node1
上的/root/data
目录
[root@server ~]# ansible node1.example.com -m file -a "path=/root/data state=absent"
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"path": "/root/data","state": "absent"
}[root@server ~]# ansible node1.example.com -m command -a "ls chdir=/root"
node1.example.com | CHANGED | rc=0 >>
公共
模板
视频
图片
文档
下载
音乐
桌面
anaconda-ks.cfg
file.ansible
frp_0.56.0_linux_amd64
frp_0.56.0_linux_amd64.tar.gz
mysql-8.0.37-linux-glibc2.17-x86_64.tar.xz
t2.sh
- 创建
文件
或目录
的时候指定属主
,或者修改远程主机
上的文件或目录的属主
[root@server ~]# ansible all -m file -a "path=/root/testfile1 state=touch owner=redhat" #新建文件并指定为属主为redhat,组默认为root
node2.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile1","gid": 0,"group": "root","mode": "0644","owner": "redhat","size": 0,"state": "file","uid": 1000
}
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile1","gid": 0,"group": "root","mode": "0644","owner": "redhat","size": 0,"state": "file","uid": 1000
}[root@server ~]# ansible all -m file -a "path=/root/testfile2 state=touch" #新建文件,默认为root
node2.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile2","gid": 0,"group": "root","mode": "0644","owner": "root","size": 0,"state": "file","uid": 0
}
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile2","gid": 0,"group": "root","mode": "0644","owner": "root","size": 0,"state": "file","uid": 0
}
#修改属主和组
[root@server ~]# ansible all -m file -a "path=/root/testfile2 state=touch owner=redhat group=redhat"
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile2","gid": 1000,"group": "redhat","mode": "0644","owner": "redhat","size": 0,"state": "file","uid": 1000
}
node2.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile2","gid": 1000,"group": "redhat","mode": "0644","owner": "redhat","size": 0,"state": "file","uid": 1000
}
- 创建
文件或目录
的时候指定权限
,或者修改远程主机
上的文件或目录的权限
[root@server ~]# ansible all -m file -a "path=/root/testfile1 state=touch mode=777"
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile1","gid": 0,"group": "root","mode": "0777","owner": "redhat","size": 0,"state": "file","uid": 1000
}
node2.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"dest": "/root/testfile1","gid": 0,"group": "root","mode": "0777","owner": "redhat","size": 0,"state": "file","uid": 1000
}
递归
方式将目录中的文件
的属主属组
都设置为redhat
[root@server ~]# ansible all -m file -a "path=/data/test/demo state=directory owner=redhat group=redhat recurse=yes"
node2.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"gid": 1000,"group": "redhat","mode": "0755","owner": "redhat","path": "/data/test/demo","size": 6,"state": "directory","uid": 1000
}
node1.example.com | CHANGED => {"ansible_facts": {"discovered_interpreter_python": "/usr/bin/python3"},"changed": true,"gid": 1000,"group": "redhat","mode": "0755","owner": "redhat","path": "/data/test/demo","size": 6,"state": "directory","uid": 1000
}[root@node1 ~]# ll /data/test
总用量 0
drwxr-xr-x 2 redhat redhat 6 7月 7 22:15 demo[root@node2 ~]# ll /data/test/
总用量 0
drwxr-xr-x 2 redhat redhat 6 7月 7 22:15 demo
2.copy模块
作用:拷贝文件
,将ansible
主机上的文件
拷贝到远程受控
主机中
2.1参数
参数 | 默认值 | 含义 |
---|---|---|
src | 用于指定需要copy 的文件或目录 | |
backup | no,yes | 当远程主机的目标路径中已存在同名文件 ,并且与ansible 主机中的文件内容不同时,是否对远程主机的文件进行备份,设为yes 时,会先备份远程主机中的文件,然后再拷贝到远程主机 |
content | 当不使用src指定拷贝的文件时,可以使用content直接指定文件内容,src与content两个参数必有其一,否则会报错 | |
dest | 用于指定文件将被拷贝到远程主机的哪个目录中,dest为必须参数 | |
group | 指定文件拷贝到远程主机后的属组,但是远程主机上必须有对应的组,否则会报错 | |
owner | 指定文件拷贝到远程主机后的属主,但是远程主机上必须有对应的用户,否则会报 | |
mode | 错文指定文件拷贝到远程主机后的权限,如果你想将权限设置为"rw-r–r–",则可以使用mode=0644表示,如果你想要在user对应的权限位上添加执行权限,则可以使用mode=u+x表示 | |
force | no,yes | 当远程主机的目标路径中已经存在同名文件,并且与ansible主机中的文件内容不同时,是否强制覆盖,默认值为yes,表示覆盖,如果设置为no,则不会执行覆盖拷贝操作,远程主机中的文件保持不变 |
相关文章:
Ansible常用模块
华子目录 Ansible四个命令模块1.组成2.特点3.区别3.1command、shell模块3.2raw模块 4.command模块4.1参数表4.2free_form参数 5.shell模块5.1作用5.2例如 6.script模块6.1示例 7.raw模块7.1参数7.2示例 文件操作模块1.file模块1.1参数1.2示例 2.copy模块2.1参数 Ansible四个命令…...
【JavaScript脚本宇宙】提升用户体验:探索 JavaScript 库中的浏览器特性支持检测
深入探讨JavaScript库:功能、配置与应用场景 前言 在现代的Web开发中,JavaScript库扮演着至关重要的角色,帮助开发人员简化代码、提高效率、实现更好的用户体验。本文将探讨几个常用的JavaScript库,包括模块加载库、数据绑定库和…...
深度学习:C++和Python如何对大图进行小目标检测
最近在医美和工业两条线来回穿梭,甚是疲倦,一会儿搞搞医美的人像美容,一会儿搞搞工业的检测,最近新接的一个项目,关于瑕疵检测的,目标图像也并不是很大吧,需要放大后,才能看见细小的…...
Eureka从入门到精通面试题及答案参考
什么是Eureka?它在微服务架构中扮演什么角色? Eureka是Netflix开源的一款基于REST的服务发现组件,它主要应用于构建分布式系统中的服务注册与发现。在微服务架构中,Eureka扮演着至关重要的角色,它让微服务架构中的各个服务实例能够互相发现、相互调用,从而实现了服务之间…...

io流 多线程
目录 一、io流 1.什么是io流 2.流的方向 i.输入流 ii.输出流 3.操作文件的类型 i.字节流 1.拷贝 ii.字符流 3.字符流输出流出数据 4.字节流和字符流的使用场景 5.练习 6.缓冲流 1.字节缓冲流拷贝文件 2.字符缓冲流特有的方法 1.方法 2.总结 7.转换流基本用法…...

人工智能、机器学习、神经网络、深度学习和卷积神经网络的概念和关系
人工智能(Artificial Intelligence,缩写为AI)--又称为机器智能,是研究、开发用于模拟、延伸和扩展人的智能的理论、方法、技术及应用系统的一门新的技术科学。 人工智能是智能学科重要的组成部分,它企图了解智能的实质…...

对话大模型Prompt是否需要礼貌点?
大模型相关目录 大模型,包括部署微调prompt/Agent应用开发、知识库增强、数据库增强、知识图谱增强、自然语言处理、多模态等大模型应用开发内容 从0起步,扬帆起航。 基于Dify的QA数据集构建(附代码)Qwen-2-7B和GLM-4-9B&#x…...

【驱动篇】龙芯LS2K0300之ADC驱动
实验目的 由于LS2K0300久久派开发板4.19内核还没有现成可用的ADC驱动,但是龙芯官方的5.10内核已经提供了ADC驱动,想要在4.19内核使用ADC就要参考5.10内核移植驱动,本次实验主要是关于ADC驱动的移植和使用 驱动移植 主要的驱动代码主要有3个…...

Python入门 2024/7/3
目录 for循环的基础语法 遍历字符串 练习:数一数有几个a range语句 三个语法 语法1 语法2 语法3 练习:有几个偶数 变量作用域 for循环的嵌套使用 打印九九乘法表 发工资案例 continue和break语句 函数的基础定义语法 函数声明 函数调用 …...
Go 语言 Map(集合)
Go 语言 Map(集合) Map 是 Go 语言中一种非常重要的数据结构,它用于存储键值对。在 Go 中,Map 是一种无序的键值对的集合,其中每个键都是唯一的,而值则可以是任何类型。Map 是 Go 语言的内置类型,使用起来非常方便,同时也是许多 Go 程序中不可或缺的一部分。 Map 的声明…...

SpringCloud学习Day7:Seata
概念 Seata是一款开源的分布式事务解决方案,致力于在微服务架构下提供高性能和简单易用的分布式事务服务 工作流程 TC以Seata服务器形式独立部署,TM和RM则是以Seata Client的形式集成在微服务中运行...

【ubuntu中关于驱动得问题】—— 如何将nouveau驱动程序加入黑名单和安装NVIDIA显卡驱动
提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录 前言一、nouveau驱动程序加入黑名单二、安装NVIDIA显卡驱动总结 前言 NVIDIA显卡驱动是用于支持和优化NVIDIA显卡在计算机系统中运行的关键软件组件。该驱动程序能…...

LabVIEW从测试曲线中提取特征值
在LabVIEW中开发用于从测试曲线中提取特征值的功能时,可以考虑以下几点: 数据采集与处理: 确保你能够有效地采集和处理测试曲线数据。这可能涉及使用DAQ模块或其他数据采集设备来获取曲线数据,并在LabVIEW中进行处理和分析。 特…...

【应届应知应会】SQL常用知识点50道
SueWakeup 个人主页:SueWakeup 系列专栏:借他一双眼,愿这盛世如先生所愿 个性签名:人生乏味啊,我欲令之光怪陆离 本文封面由 凌七七~❤ 友情提供 目录 数据库的概念 (什么是数据库) RDBMS NOSQL 数据库的分类 …...

【雷丰阳-谷粒商城 】【分布式高级篇-微服务架构篇】【21】【购物车】
持续学习&持续更新中… 守破离 【雷丰阳-谷粒商城 】【分布式高级篇-微服务架构篇】【21】【购物车】 购物车需求描述购物车数据结构数据Model抽取实现流程(参照京东)代码实现参考 购物车需求描述 用户可以在登录状态下将商品添加到购物车【用户购物…...

科技赋能智慧应急:“数字孪生+无人机”在防汛救灾中的应用
近期,全国多地暴雨持续,“麻辣王子工厂停工”“水上派出所成水上的派出所了”等相关词条冲上热搜,让人们看到了全国各地城市内涝、洪涝带来的严重灾情。暴雨带来的影响可见一斑,潜在的洪水、泥石流、山体滑坡等地质灾害更应提高警…...

urfread刷算法|构建一棵树
大意 示例标签串: 处理结果: 题目1 根据标签串创建树 需求 需求:给出一个字符串,将这个字符串转换为一棵树。 字符串可以在代码里见到,是以#开头,按照\分割的字符串。 你需要将这个字符串࿰…...

在卷积神经网络(CNN)中为什么可以使用多个较小的卷积核替代一个较大的卷积核,以达到相同的感受野
在卷积神经网络(CNN)中为什么可以使用多个较小的卷积核替代一个较大的卷积核,以达到相同的感受野 flyfish 在卷积神经网络(CNN)中,可以使用多个较小的卷积核替代一个较大的卷积核,以达到相同的…...
【学习笔记】Mybatis-Plus(四):MP中内置的插件
内置插件 目前MP已经存在的内部插件包括如下: 插件类名作用PaginationInnerInterceptor分页插件。可以代替以前的PageHelperOptimisticLockerInnerInterceptor乐观锁插件。用于幂等性操作,采用版本更新记录DynamicTableNameInnerInterceptor动态表名Te…...

GlusterFS分布式存储系统
GlusterFS分布式存储系统 一,分布式文件系统理论基础 1.1 分布式文件系统出现 计算机通过文件系统管理,存储数据,而现在数据信息爆炸的时代中人们可以获取的数据成指数倍的增长,单纯通过增加硬盘个数来扩展计算机文件系统的存储…...

JavaSec-RCE
简介 RCE(Remote Code Execution),可以分为:命令注入(Command Injection)、代码注入(Code Injection) 代码注入 1.漏洞场景:Groovy代码注入 Groovy是一种基于JVM的动态语言,语法简洁,支持闭包、动态类型和Java互操作性,…...

大数据学习栈记——Neo4j的安装与使用
本文介绍图数据库Neofj的安装与使用,操作系统:Ubuntu24.04,Neofj版本:2025.04.0。 Apt安装 Neofj可以进行官网安装:Neo4j Deployment Center - Graph Database & Analytics 我这里安装是添加软件源的方法 最新版…...

PPT|230页| 制造集团企业供应链端到端的数字化解决方案:从需求到结算的全链路业务闭环构建
制造业采购供应链管理是企业运营的核心环节,供应链协同管理在供应链上下游企业之间建立紧密的合作关系,通过信息共享、资源整合、业务协同等方式,实现供应链的全面管理和优化,提高供应链的效率和透明度,降低供应链的成…...
线程同步:确保多线程程序的安全与高效!
全文目录: 开篇语前序前言第一部分:线程同步的概念与问题1.1 线程同步的概念1.2 线程同步的问题1.3 线程同步的解决方案 第二部分:synchronized关键字的使用2.1 使用 synchronized修饰方法2.2 使用 synchronized修饰代码块 第三部分ÿ…...
【ROS】Nav2源码之nav2_behavior_tree-行为树节点列表
1、行为树节点分类 在 Nav2(Navigation2)的行为树框架中,行为树节点插件按照功能分为 Action(动作节点)、Condition(条件节点)、Control(控制节点) 和 Decorator(装饰节点) 四类。 1.1 动作节点 Action 执行具体的机器人操作或任务,直接与硬件、传感器或外部系统…...
Python ROS2【机器人中间件框架】 简介
销量过万TEEIS德国护膝夏天用薄款 优惠券冠生园 百花蜂蜜428g 挤压瓶纯蜂蜜巨奇严选 鞋子除臭剂360ml 多芬身体磨砂膏280g健70%-75%酒精消毒棉片湿巾1418cm 80片/袋3袋大包清洁食品用消毒 优惠券AIMORNY52朵红玫瑰永生香皂花同城配送非鲜花七夕情人节生日礼物送女友 热卖妙洁棉…...

基于TurtleBot3在Gazebo地图实现机器人远程控制
1. TurtleBot3环境配置 # 下载TurtleBot3核心包 mkdir -p ~/catkin_ws/src cd ~/catkin_ws/src git clone -b noetic-devel https://github.com/ROBOTIS-GIT/turtlebot3.git git clone -b noetic https://github.com/ROBOTIS-GIT/turtlebot3_msgs.git git clone -b noetic-dev…...

LINUX 69 FTP 客服管理系统 man 5 /etc/vsftpd/vsftpd.conf
FTP 客服管理系统 实现kefu123登录,不允许匿名访问,kefu只能访问/data/kefu目录,不能查看其他目录 创建账号密码 useradd kefu echo 123|passwd -stdin kefu [rootcode caozx26420]# echo 123|passwd --stdin kefu 更改用户 kefu 的密码…...

Netty从入门到进阶(二)
二、Netty入门 1. 概述 1.1 Netty是什么 Netty is an asynchronous event-driven network application framework for rapid development of maintainable high performance protocol servers & clients. Netty是一个异步的、基于事件驱动的网络应用框架,用于…...
解决:Android studio 编译后报错\app\src\main\cpp\CMakeLists.txt‘ to exist
现象: android studio报错: [CXX1409] D:\GitLab\xxxxx\app.cxx\Debug\3f3w4y1i\arm64-v8a\android_gradle_build.json : expected buildFiles file ‘D:\GitLab\xxxxx\app\src\main\cpp\CMakeLists.txt’ to exist 解决: 不要动CMakeLists.…...