首页 文章 精选 留言 我的

精选列表

搜索[文档处理],共10000篇文章
优秀的个人博客,低调大师

介绍两种从 Docker 容器写入卷时的文件权限处理方式

出品丨Docker公司(ID:docker-cn)编译丨小东每周一、三、五,与您不见不散! 容器常常用作原生安装工具的替代品。在主机上使用具有所需版本的容器要比使用过时的工具好的多。但是,只要容器与主机系统进行交互,文件会留下错误或损坏的权限。幸运的是,解决该问题的方法并不需要使用脚本。 问题描述 当容器挂载一个本地目录并将文件写入其中时,其所有权由容器内的用户决定: nicholas@host:~/source$ mkdir source nicholas@host:~/source$ docker run -it --rm --volume $(pwd):/source --workdir /source ubuntu root@a031d11c9515:/source# mkdir subdir root@a031d11c9515:/source# touch subdir/newfile root@a031d11c9515:/source# exit exit nicholas@host:~/source$ ls -lR .: total 4 drwxr-xr-x 2 root root 4096 Jul 16 19:35 subdir ./subdir: total 0 -rw-r--r-- 1 root root 0 Jul 16 19:35 newfile nicholas@host:~/source$ rm -rf subdir/ rm: cannot remove 'subdir/newfile': Permission denied 另外,您还可能无法删除这些目录和拥有错误所有权的文件。 解决方案1:从容器中删除 一个非常常见的解决方案是从容器内部更改文件和目录的所有权: nicholas@host:~/source$ docker run -it --rm --volume $(pwd):/source --workdir /source ubuntu root@d1c3bee8bb2b:/source# ls -al total 12 drwxrwxr-x 3 1000 1004 4096 Jul 16 19:35 . drwxr-xr-x 1 root root 4096 Jul 16 19:39 .. drwxr-xr-x 2 root root 4096 Jul 16 19:35 subdir root@d1c3bee8bb2b:/source# chown 1000:1000 subdir/ -R root@d1c3bee8bb2b:/source# ls -l total 4 drwxr-xr-x 2 1000 1000 4096 Jul 16 19:35 subdir root@d1c3bee8bb2b:/source# exit exit nicholas@host:~/source$ ls -l total 4 drwxr-xr-x 2 nicholas lpadmin 4096 Jul 16 19:35 subdir nicholas@host:~/source$ 这种方法的缺点是需要添加额外的逻辑,以及您需要知道运行该容器用户的用户 ID 和组 ID。 解决方案2:创建拥有正确所有权的文件 第二种解决方案更简洁,它将使用容器内的正确所有权创建文件和目录。Docker 提供了一个参数来设置容器内用户的用户 ID 和组 ID: nicholas@host:~/source$ docker run -it --rm --volume $(pwd):/source --workdir /source --user $(id -u):$(id -g) ubuntu groups: cannot find name for group ID 1004 I have no name!@bf7f355f3b65:/source$ touch newfile I have no name!@bf7f355f3b65:/source$ exit exit nicholas@host:~/source$ ls -l total 4 -rw-r--r-- 1 nicholas nicholas 0 Jul 16 19:42 newfile drwxr-xr-x 2 nicholas lpadmin 4096 Jul 16 19:35 subdir nicholas@host:~/source$ 这种方法可以很好的帮您解决用户 ID 和组 ID 的错误。 请注意,出于安全目的,在容器内以 root 身份运行是最糟糕的做法。Dockerfile 应始终使用 USER 指令从而避免直接使用 root 权限。

优秀的个人博客,低调大师

Docker Windows Server 应用迁移计划上线,让您轻松处理旧版应用程序!

出品丨Docker公司(ID:docker-cn)编译丨小东每周一、三、五,与您不见不散! 上周,我们发布了 Docker Windows Server 应用程序迁移计划,旨在帮助公司快速、轻松地迁移应用程序以及对旧版的 Windows Server 2008 应用程序进行现代化改造,同时推动在任何地方的任何应用程序进行持续创新。 我们认识到 Windows Server 2008 是当今使用最广泛的操作系统之一,而即将在 2020年1月到来的停止支持让 IT 组织几乎没有可行的选择来经济、高效地保护其旧版的应用程序和数据。 Docker Windows Server 应用程序迁移计划是实现容器化和保护旧版 Windows Server 应用程序的最佳和唯一方法,同时可以让软件驱动业务实现转型。通过 Docker Windows Server 应用程序迁移计划,客户得到: Docker Enterprise:业界领先的、唯一适用于 Windows Server 应用程序的企业级容器平台。 Docker Enterprise 是业界领先的企业级容器平台,为数百万开发人员和 IT 专业人士所熟知。它也是唯一可以运行 Windows Server 应用程序的容器平台,它支持 Windows Server 2016、1709、1803 以及 2019 版本。Docker Enterprise 通过更高效的服务器整合以及减少硬件和许可的手段,通常可以让组织可以节省50%的成本或更多。 经过行业验证的工具和服务:轻松帮助企业进行服务发现、容器化改造以及应用程序迁移。 凭借经过行业验证的服务,Docker 是唯一一家可以提供即时结果的容器平台。这些服务利用专用的工具来成功实现企业 Windows Server 应用程序的容器化改造。这项新服务基于 Docker 与数百家企业的合作以及共同实现旧版的应用程序现代化改造的丰富经验。为了加速旧版应用程序的迁移,Docker 利用专用工具(Docker Application Converter)来自动扫描特定应用程序的系统,并通过自动创建 Docker 容器来加速容器化过程。同样的,经过 Docker认证的基础架构可提高客户操作 Docker Enterprise 容器平台的能力。经过 Docker 认证的基础架构包括配置最佳实践、自动化工具和经过验证的解决方案指南,用于将容器集成到 VMware vSphere、Microsoft Azure 和 Amazon Web Services 等企业 IT 基础架构中。 持续创新的基础:帮助软件驱动业务进行转型,支持在任何地方的任何应用程序进行持续创新。 Docker 容器平台让组织能够使现有应用程序进行现代化改造并采用新技术来满足业务需求。这使得转型能够由业务驱动来决定而非依赖于技术驱动。这样,客户就可以轻松地、平滑地集成新的技术堆栈和架构,不会产生冲突,包括:云原生应用程序、微服务、数据科学、边缘计算和人工智能。 我们的客户,欧洲电信公司 Tele2 正在使用 Docker Enterprise 来帮助其大规模整合旧版的 Windows 应用程序。 Tele2 公司的技术架构师 Gregory Bohcke 表示:“我们希望将所有的一切都迁移到云端,从而改变我们作为电信提供商开展业务的方式。Docker Enterprise 是实现这一愿望的关键部分。借助 Docker Enterprise,我们已经将超过一半的应用程序组合进行了容器化改造并且提高了部署效率。我们期待着尽快将 Docker Enterprise 2.1 版本中的高级 Windows Server 支持功能投入到生产中。” 通过 Docker Enterprise 容器平台将旧版的应用程序及其依赖关系进行容器化改造,企业可以在不更改代码的情况下将旧版应用程序迁移到 Windows Server 2016(以及更高版本的操作系统)中,从而节省数百万美元的开发成本。而且,由于容器化应用程序独立于底层操作系统运行,它打破了依赖性很强的升级体系,创建了一种不受未来影响的架构,让您可以轻松地保持最新操作系统的最新状态。 浏览:https://www.docker.com/solutions/windows-server-migration 了解关于 Docker Windows Server 应用程序迁移计划的更多详情。

优秀的个人博客,低调大师

Spark Streaming实时流处理学习——分布式日志收集框架Flume

2. 分布式日志收集框架Flume 2.1 业务现状分析 如上图,大量的系统和各种服务的日志数据持续生成。用户有了很好的商业创意想要充分利用这些系统日志信息。比如用户行为分析,轨迹跟踪等等。如何将日志上传到Hadoop集群上?对比方案存在什么问题,以及有什么优势? 方案1: 容错,负载均衡,高延时等问题如何消除? 方案2: Flume框架 2.2 Flume概述 flume官网 http://flume.apache.orgFlume is a distributed, reliable, and available service for efficiently collecting(收集), aggregating(聚合), and moving(移动)large amounts of log data. It has a simple and flexible architecture based on streaming data flows. It is robust and fault tolerant with tunable reliability mechanisms and many failover and recovery mechanisms. It uses a simple extensible data model that allows for online analytic application. Flume是有Cloudera提供的一个分布式、高可靠、高可用的服务,用于分布式的海量日志的高效收集、聚合、移动的系统Flume的设计目标 可靠性 扩展性 管理性(agent有效的管理者) 业界同类产品对比 Flume(*): Cloudera/Apache Java Scribe: Facebook C/C++ 不再维护 Chukwa:Yahoo/Apache Java 不再维护 Fluentd:Ruby Logstash(*):ELK(ElasticSearch,Kibana) Flume发展史 Cloudera 0.9.2 Flume-OG flume-728 Flume-NG => Apache 2012.7 1.0 2015.5 1.6 (* +) ~ 1.8 2.3 Flume架构及核心组件 Source(收集) Channel(聚合) Sink(输出) multi-agent flow In order to flow the data across multiple agents or hops, the sink of the previous agent and source of the current hop need to be avro type with the sink pointing to the hostname (or IP address) and port of the source.A very common scenario in log collection is a large number of log producing clients sending data to a few consumer agents that are attached to the storage subsystem. For example, logs collected from hundreds of web servers sent to a dozen of agents that write to HDFS cluster. This can be achieved in Flume by configuring a number of first tier agents with an avro sink, all pointing to an avro source of single agent (Again you could use the thrift sources/sinks/clients in such a scenario). This source on the second tier agent consolidates the received events into a single channel which is consumed by a sink to its final destination. Multiplexing the flow Flume supports multiplexing the event flow to one or more destinations. This is achieved by defining a flow multiplexer that can replicate or selectively route an event to one or more channels.The above example shows a source from agent “foo” fanning out the flow to three different channels. This fan out can be replicating or multiplexing. In case of replicating flow, each event is sent to all three channels. For the multiplexing case, an event is delivered to a subset of available channels when an event’s attribute matches a preconfigured value. For example, if an event attribute called “txnType” is set to “customer”, then it should go to channel1 and channel3, if it’s “vendor” then it should go to channel2, otherwise channel3. The mapping can be set in the agent’s configuration file. 2.4 Flume环境部署 前置条件 Java Runtime Environment - Java 1.8 or later Memory - Sufficient memory for configurations used by sources, channels or sinks Disk Space - Sufficient disk space for configurations used by channels or sinks Directory Permissions - Read/Write permissions for directories used by agent 安装JDK 下载JDK包 解压JDK包 tar -zxvf jdk-8u162-linux-x64.tar.gz [install dir] * 配置JAVA环境变量: 修改系统配置文件 /etc/profile 或者 ~/.bash_profile export JAVA_HOME=[jdk install dir] export PATH = $JAVA_HOME/bin:$PATH 执行指令 source /etc/profile 或者 source ~/.bash_profile 使得配置生效。 执行指令 java -version 检测环境配置是否生效。 安装Flume 下载Flume包 wget http://www.apache.org/dist/flume/1.7.0/apache-flume-1.7.0-bin.tar.gz 解压Flume包 tar -zxvf apache-flume-1.7.0-bin.tar.gz -C [install dir] 配置Flume环境变量 vim /etc/profile 或者 vim ~/.bash_profile export FLUME_HOME=[flume install dir] export PATH = $FLUME_HOME/bin:$PATH 执行指令 source /etc/profile 或者 source ~/.bash_profile 使得配置生效。 修改flume-env.sh脚本文件 export JAVA_HOME=[jdk install dir] 执行指令 flume-ng version 检测安装情况 2.5 Flume实战 需求1:从指定的网络端口采集数据输出到控制台 使用Flume的关键就是写配置文件 配置source 配置Channel 配置Sink 把以上三个组件链接起来 a1: agent名称r1: source的名称k1: sink的名称c1: channel的名称 单一节点 Flume 配置 # example.conf: A single-node Flume configuration # Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = netcat a1.sources.r1.bind = localhost a1.sources.r1.port = 44444 # Describe the sink a1.sinks.k1.type = logger # Use a channel which buffers events in memory a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # Bind the source and sink to the channel a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1 启动Flume agent flume-ng agent \ --name a1 \ --conf $FLUME_HOME/conf \ --conf-file $FLUME_HOME/conf/example.conf \ -Dflume.root.logger=INFO,console 使用telnet或者nc进行测试 telnet [hostname] [port] 或者 nc [hostname] [port] Event = 可选的headers + byte array Event: { headers:{} body: 74 68 69 73 20 69 73 20 61 20 74 65 73 74 20 70 this is a test p } 需求2:监控一个文件实时采集新增的数据输出到控制台技术(Agent)选型:exec source + memory channel + logger sink # example.conf: A single-node Flume configuration # Name the components on this agent a1.sources = r1 a1.sinks = k1 a1.channels = c1 # Describe/configure the source a1.sources.r1.type = exec a1.sources.r1.command = tail -f /root/data/data.log a1.sources.r1.shell = /bin/bash -c # Describe the sink a1.sinks.k1.type = logger # Use a channel which buffers events in memory a1.channels.c1.type = memory a1.channels.c1.capacity = 1000 a1.channels.c1.transactionCapacity = 100 # Bind the source and sink to the channel a1.sources.r1.channels = c1 a1.sinks.k1.channel = c1 启动Flume agent flume-ng agent \ --name a1 \ --conf $FLUME_HOME/conf \ --conf-file $FLUME_HOME/conf/example.conf \ -Dflume.root.logger=INFO,console 修改data.log文件,监测是否数据是否输出到控制台 echo hello >> data.log echo world >> data.log echo welcome >> data.log 控制台输出 2018-09-02 03:55:00,672 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 68 65 6C 6C 6F hello } 2018-09-02 03:55:06,748 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 77 6F 72 6C 64 world } 2018-09-02 03:55:22,280 (SinkRunner-PollingRunner-DefaultSinkProcessor) [INFO - org.apache.flume.sink.LoggerSink.process(LoggerSink.java:95)] Event: { headers:{} body: 77 65 6C 63 6F 6D 65 welcome } 至此,需求2成功实现。 需求3(*):将A服务器上的日志实时采集到B服务器上(重点掌握)技术(Agent)选型: exec source + memory channel + avro sink avro source + memory channel + logger sink # exec-memory-avro.conf: A single-node Flume configuration # Name the components on this agent exec-memory-avro.sources = exec-source exec-memory-avro.sinks = avro-sink exec-memory-avro.channels = memory-channel # Describe/configure the source exec-memory-avro.sources.exec-source.type = exec exec-memory-avro.sources.exec-source.command = tail -f /root/data/data.log exec-memory-avro.sources.exec-source.shell = /bin/bash -c # Describe the sink exec-memory-avro.sinks.avro-sink.type = avro exec-memory-avro.sinks.avro-sink.hostname = c7-master exec-memory-avro.sinks.avro-sink.port = 44444 # Use a channel which buffers events in memory exec-memory-avro.channels.memory-channel.type = memory exec-memory-avro.channels.memory-channel.capacity = 1000 exec-memory-avro.channels.memory-channel.transactionCapacity = 100 # Bind the source and sink to the channel exec-memory-avro.sources.exec-source.channels = memory-channel exec-memory-avro.sinks.avro-sink.channel = memory-channel # avro-memory-logger.conf: A single-node Flume configuration # Name the components on this agent avro-memory-logger.sources = avro-source avro-memory-logger.sinks = logger-sink avro-memory-logger.channels = memory-channel # Describe/configure the source avro-memory-logger.sources.avro-source.type = avro avro-memory-logger.sources.avro-source.bind = c7-master avro-memory-logger.sources.avro-source.port = 44444 # Describe the sink avro-memory-logger.sinks.logger-sink.type = logger # Use a channel which buffers events in memory avro-memory-logger.channels.memory-channel.type = memory avro-memory-logger.channels.memory-channel.capacity = 1000 avro-memory-logger.channels.memory-channel.transactionCapacity = 100 # Bind the source and sink to the channel avro-memory-logger.sources.avro-source.channels = memory-channel avro-memory-logger.sinks.logger-sink.channel = memory-channel 优先启动 avro-memory-logger agent flume-ng agent \ --name avro-memory-logger \ --conf $FLUME_HOME/conf \ --conf-file $FLUME_HOME/conf/avro-memory-logger.conf \ -Dflume.root.logger=INFO,console 再启动 exec-memory-avro agent flume-ng agent \ --name exec-memory-avro \ --conf $FLUME_HOME/conf \ --conf-file $FLUME_HOME/conf/exec-memory-avro.conf \ -Dflume.root.logger=INFO,console 日志收集过程:1)机器A上监控一个文件,当我们访问主站时会有用户行为日志记录到access.log中2)avro sink把新产生的日志输出到对应的avro source指定的hostname:port主机上。3)通过avro source对应的agent将我们的日志输出到控制台。

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Nacos

Nacos

Nacos /nɑ:kəʊs/ 是 Dynamic Naming and Configuration Service 的首字母简称,一个易于构建 AI Agent 应用的动态服务发现、配置管理和AI智能体管理平台。Nacos 致力于帮助您发现、配置和管理微服务及AI智能体应用。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据、流量管理。Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

WebStorm

WebStorm

WebStorm 是jetbrains公司旗下一款JavaScript 开发工具。目前已经被广大中国JS开发者誉为“Web前端开发神器”、“最强大的HTML5编辑器”、“最智能的JavaScript IDE”等。与IntelliJ IDEA同源,继承了IntelliJ IDEA强大的JS部分的功能。

用户登录
用户注册