saltstack 从minion传送文件到master及minion文件后端minionfs系统

简介: 演示如下: vagrant@saltminion1:/tmp$ touch talen.txt vagrant@saltminion1:/tmp$ echo This is a test .
演示如下:

  1. vagrant@saltminion1:/tmp$ touch talen.txt
  2. vagrant@saltminion1:/tmp$ echo This is a test . > talen.txt


  1. vagrant@saltmaster:/var/cache/salt/master$ sudo salt '*' test.ping
  2. minion2:
  3.     True
  4. minion1:
  5.     True
  6. vagrant@saltmaster:/var/cache/salt/master$ sudo salt '*' cp.push /tmp/talen.txt
  7. minion2:
  8.     False
  9. minion1:
  10.     True
  11. vagrant@saltmaster:/var/cache/salt/master$ cd /var/cache/salt/master/minions/minion
  12. minion1/ minion2/
  13. vagrant@saltmaster:/var/cache/salt/master/minions$ tree
  14. .
  15. ├── minion1
  16. │   ├── files
  17. │   │   └── tmp
  18. │   │   └── talen.txt
  19. │   └── mine.p
  20. └── minion2
  21.     └── mine.p

  22. 4 directories, 3 files

有时,我们需要传送在minion上产生的文件.
salt已经有从minion上传送文件到master的特性.默认因为安全性问题,没有启用.
修改master启用这个特性.
file_recv: True

点击(此处)折叠或打开

  1. vagrant@saltmaster:~ $ vim /etc/salt/master

  2. # Allow minions to push files to the master. This is disabled by default, for
  3. # security purposes.
  4. #file_recv: False
  5. file_recv: True

salt-cp cp模块是minion端的,其它函数功能参考
https://docs.saltstack.com/en/latest/ref/modules/all/salt.modules.cp.html#salt.modules.cp.push


# File Server Backend
#文件服务后端
#
# Salt supports a modular fileserver backend system, this system allows
# the salt master to link directly to third party systems to gather and
# manage the files available to minions. Multiple backends can be
# configured and will be searched for the requested file in the order in which
# they are defined here. The default setting only enables the standard backend
# "roots" which uses the "file_roots" option.
#salt支持一个模块化的文件服务后端系统,这个系统允许master直接链接到第三方平台系统收集和管理minions上的文件.请求文件将按定义的多个后端的顺序查询.默认使用file_roots选项只启用了最基本的roots.
#fileserver_backend:
#  - roots
#
# To use multiple backends list them in the order they are searched:
#fileserver_backend:
#  - git
#  - roots
#按顺序列出要查询的后端列表.
#
#如果你想让file_server允许追踪软链接文件系统树,取消下面的注释.默认是开启的,当前默认只应用于默认的文件服务后端.
# Uncomment the line below if you do not want the file_server to follow
# symlinks when walking the filesystem tree. This is set to True
# by default. Currently this only applies to the default roots
# fileserver_backend.
#fileserver_followsymlinks: False
#
# Uncomment the line below if you do not want symlinks to be
# treated as the files they are pointing to. By default this is set to
# False. By uncommenting the line below, any detected symlink while listing
# files on the Master will not be returned to the Minion.
#fileserver_ignoresymlinks: True
#
# By default, the Salt fileserver recurses fully into all defined environments
# to attempt to find files. To limit this behavior so that the fileserver only
# traverses directories with SLS files and special Salt directories like _modules,
# enable the option below. This might be useful for installations where a file root
# has a very large number of files and performance is impacted. Default is False.
# fileserver_limit_traversal: False
#
# The fileserver can fire events off every time the fileserver is updated,
# these are disabled by default, but can be easily turned on by setting this
# flag to True
#fileserver_events: False




如果想使用minion上的文件系统,简单启用两个参数
fileserver_backend:
  - roots
  - minion

file_recv: True
从下面的执行可以看到,当我们从minion1服务器上传文件到master后,minion1的上传目录/tmp已经可以在其它minions上看到了.
其它minions可以从minion1上共享的目录下载文件.

点击(此处)折叠或打开

  1. vagrant@saltmaster:~$ sudo salt '*' cp.list_master_dirs
  2. minion2:
  3.     - .
  4.     - common
  5.     - minion1/tmp
  6. minion1:
  7.     - .
  8.     - common
  9.     - minion1/tmp
  10. vagrant@saltmaster:~$ sudo salt 'minion2' cp.get_file salt://minion1/tmp/talen.txt /tmp/talen.2.txt
  11. minion2:
  12.     /tmp/talen.2.txt
  13. vagrant@saltminion2:~$ ll /tmp/talen.2.txt
  14. -rw-r--r-- 1 root root 17 Apr 27 03:47 /tmp/talen.2.txt


目录
相关文章
|
1月前
|
缓存 前端开发 Go
从4开始,在后端系统中增加用户注册和登录功能
从4开始,在后端系统中增加用户注册和登录功能
26 0
|
1月前
|
人工智能 运维 监控
构建高性能微服务架构:现代后端开发的挑战与策略构建高效自动化运维系统的关键策略
【2月更文挑战第30天】 随着企业应用的复杂性增加,传统的单体应用架构已经难以满足快速迭代和高可用性的需求。微服务架构作为解决方案,以其服务的细粒度、独立性和弹性而受到青睐。本文将深入探讨如何构建一个高性能的微服务系统,包括关键的设计原则、常用的技术栈选择以及性能优化的最佳实践。我们将分析微服务在处理分布式事务、数据一致性以及服务发现等方面的挑战,并提出相应的解决策略。通过实例分析和案例研究,我们的目标是为后端开发人员提供一套实用的指南,帮助他们构建出既能快速响应市场变化,又能保持高效率和稳定性的微服务系统。 【2月更文挑战第30天】随着信息技术的飞速发展,企业对于信息系统的稳定性和效率要求
|
2天前
|
Kubernetes 测试技术 持续交付
深入理解微服务架构及其在现代后端系统中的应用
本文将深入探讨微服务架构的核心概念、设计原则以及如何在现代后端系统中实现和优化它。我们将从微服务的定义开始,逐步展开讨论其优势、面临的挑战,以及如何克服这些挑战。同时,文章还会涉及微服务与容器化技术、持续集成/持续部署(CI/CD)的协同作用,以及微服务架构的未来发展趋势。读者将获得对微服务架构全面而深刻的理解,并能够识别在实施过程中可能遇到的陷阱和解决方案。
21 1
|
5天前
|
SQL XML 数据库
后端数据库开发高级之通过在xml文件中映射实现动态SQL
后端数据库开发高级之通过在xml文件中映射实现动态SQL
13 3
|
5天前
|
SQL XML Java
后端数据库开发JDBC编程Mybatis之用基于XML文件的方式映射SQL语句实操
后端数据库开发JDBC编程Mybatis之用基于XML文件的方式映射SQL语句实操
23 3
|
5天前
|
存储 Java 应用服务中间件
后端企业级开发之yaml数据序列化格式文件详解2024
后端企业级开发之yaml数据序列化格式文件详解2024
8 0
|
25天前
|
前端开发 安全 Java
家政系统(用户端)介绍Java18+前端html+后端springboot
家政系统(用户端)介绍Java18+前端html+后端springboot
23 0
|
1月前
|
JSON JavaScript 前端开发
vue的 blob文件下载文件时,后端自定义异常,并返回json错误提示信息,前端捕获信息并展示给用户
vue的 blob文件下载文件时,后端自定义异常,并返回json错误提示信息,前端捕获信息并展示给用户
|
1月前
|
jenkins 持续交付
基于Jeecgboot前后端分离的平台后端系统采用jenkins发布
基于Jeecgboot前后端分离的平台后端系统采用jenkins发布
23 1
|
29天前
|
存储 架构师 安全
构建高效可靠的后端系统:挑战与应对
在当今数字化时代,后端系统作为支撑着各种网络服务和应用的核心组成部分,承担着巨大的压力和责任。本文探讨了构建高效可靠的后端系统所面临的挑战,并提出了应对这些挑战的策略和方法,旨在帮助开发人员和系统架构师更好地应对日益复杂的技术环境。