首页 文章 精选 留言 我的

精选列表

搜索[弹性 MapReduce],共10000篇文章
优秀的个人博客,低调大师

mapreduce出现大量task被KILLED_UNCLEAN的3个原因

Request received to kill task 'attempt_201411191723_2827635_r_000009_0' by user ------- Task has been KILLED_UNCLEAN by the user 原因如下: 1.An impatient user (armed with "mapred job -kill-task" command) 2.JobTracker (to kill a speculative duplicate, or when a whole job fails) 3.Fair Scheduler (but diplomatically, it calls it “preemption”) 一篇老外的文章说的更详细: This is one of the most bloodcurling (and my favorites) stories, that we have recently seen in our 190-square-meter Hadoopland. In a nutshell, some jobs were surprisingly running extremely long, because thousands of their tasks were constantly being killed for some unknown reasons by someone (or something). For example, a photo, taken by our detectives, shows a job running for 12hrs:20min that spawned around 13,000 tasks until that moment. However (only) 4,118 of map tasks had finished successfully, while 8,708 were killed (!) and … surprisingly only 1 task failed (?) – obviously spreading panic in the Hadoopland. When murdering, the killer was leaving the same message each time: "KILLED_UNCLEAN by the user" (however, even our uncle competitor Google does not know too much what it exactly means ;)). Who is “the user”? Does the killer want to impersonate someone? More Traces Of Crime The detectives started looking for more traces of crime. They have noticed the killed tasks belong to ad-hoc Hive queries which are quite resource-intensive. When looking at timestamps in log files from JobTracker, TaskTracker and map tasks, they figured out that JobTracker got a request to murder the tasks… They have also noticed that tasks were usually killed young, quickly after the start (within 6-16 minutes), while the surviving tasks are running fine long hours.. The killer is unscrupulous! Killer’s Identity Who can actually send a kill request to JobTracker to murder thousands of tasks? Detectives quickly selected there main candidates: An impatient user (armed with "mapred job -kill-task" command) JobTracker (to kill a speculative duplicate, or when a whole job fails) Fair Scheduler (but diplomatically, it calls it “preemption”) When looking at log messages saying that a task is "KILLED UNCLEAN by the user", one could think that some user is a prime candidate to be the serial killer. However, the citizens of our Hadoopland are friendly, patient and respective to others, so that it would be unfair to assume that somebody killed, in cold blood, 8,708 tasks from a single jobs. JobTracker also seems to have a good alibi, because the job itself had not failed yet and the speculative execution was disabled (surprisingly Hive has own setting, hive.mapred.reduce.tasks.speculative.execution, for disabling speculative execution for reduce tasks, which is not overwritten by Hadoop’s mapred.reduce.tasks.speculative.execution). FairScheduler Accused For some company-specific reasons, the ad-hoc Hive queries are running as hive user in our Hadoopland. Moreover FairScheduler is configured with the default value of mapred.fairscheduler.poolnameproperty (which is user.name), so that the pools are created dynamically based on the username of user submitting the job to the cluster (“hive” in case of our ad-hoc Hive queries). When browsing one presentation about Hadoop 2 years ago, one of the detectives just remembered that FairScheduler is usually preempting the newest tasks in an over-share pool to forcibly make some room for starved pools. Eureka! ;) At this movement everything became clear and a quick look at FairScheduler webpage confirmed it. “Hive” pool was running over its minimum and fair shares for a long time, while the other pools are constantly running under their minimum and fair shares. In such a case, Fair Scheduler was killing Hive tasks from time to time to reassign slots to tasks from other pools. Less Violence, More Peace Having the evidence, we could put Fair Scheduler in prison, and use Capacity Scheduler instead. Maybe in the future, we will do that! Today, we believe that Fair Scheduler has not committed the crimes really intentionally – we feel that we have educated it badly and gave it too much power. Today, Fair Scheduler gets the suspended sentence – we want to give it a chance to rehabilitate and become more friendly and less aggressive… How to dignify the personality of Fair Scheduler? Obviously tuning settings like minSharePreemptionTimeout, fairSharePreemptionTimeout, minMaps and minReduces based on the current workload could be a good way to control the aggressiveness of the preemption of Fair Scheduler. Easier said, than done, because it requires a deep understanding of and knowledge about your workload (which later may change or not). There is a setting called mapred.fairscheduler.preemption that disables or enables preemption. However disabling preemption (or rather killing, to be precise), in our case, would just partially solve the problem. Only partially, because this issue exposed another problem in the Hadoopland – ad-hoc Hive queries are overloading the cluster.. Finally, we have not disabled preemption, because we were worrying a bit about SLA not being enforced without “any” preemption. Having this said, the two problems to solve are: stop mass killing Hive tasks stop overloading the cluster by ad-hoc Hive queries We simply limited the number of map and reduce tasks that Fair Scheduler can run in Hive pool (by setting maxMaps and maxReduces for that pool). In consequence, Hive pool could not contain too many task, so that Fair Scheduler could not kill too many of them ;) (because Hive pool’s will not be operating (too much) above its min and fair share level). Limiting the number of tasks prevents also from overloading the cluster by Hive queries (additionally one could also set the maximum number of concurrent jobs running in Hive pool using maxRunningJobs). A nice thing to say is that Fair Scheduler is eager to cooperate, because changing the FairScheduler’s allocation file, does not require restarting of JobTracker. This file is automatically polled for changes every 10 seconds and if it has changed, it is reloaded and the pool configurations are updated on the fly. Thanks to that you can easily learn and change the personality of Fair Scheduler better. ;) No related posts found.

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

windows下使用Eclipse编译运行MapReduce程序 Hadoop2.6.0/Ubuntu

一、环境介绍 宿主机:windows8 虚拟机:Ubuntu14.04 hadoop2.6伪分布:搭建教程http://blog.csdn.net/gamer_gyt/article/details/46793731 Eclipse:eclipse-jee-luna-SR2-win32-x86_64 二、准备阶段 网上下载hadoop-eclipse-plugin-2.6.0.jar (点击下载) 也可以自行编译(网上教程挺多的,可以自己百度 or Google) 三、begin 复制编译好的jar到eclipse插件目录(如果是从ubuntu自带的软件中心安装elcipse的话,则安装目录为:/usr/share/eclipse/dropins/sdk/plugins/不是在/usr/share/eclipse/plugin),进入eclipse目录,执行sudo chmod 777 * -R,重启eclipse 这一步特别重要网上好多资料都不是这样写的,所以配置一直不成功。 配置 hadoop 安装目录 window ->preference -> hadoop Map/Reduce -> Hadoop installation directory 配置Map/Reduce 视图 window ->Open Perspective -> other->Map/Reduce -> 点击“OK” windows →show view →other->Map/Reduce Locations-> 点击“OK” 控制台会多出一个“Map/Reduce Locations”的Tab页 在“Map/Reduce Locations” Tab页 点击图标<大象+>或者在空白的地方右键,选择“New Hadoop location…”,弹出对话框“New hadoop location…”,配置如下内容:将ha1改为自己的hadoop用户 接着再切换到 Advanced parameters 选项面板,这边有详细的配置,切记需要与 Hadoop 的配置(/usr/local/hadoop/etc/hadoop中的配置文件)一致,如我配置了 hadoop.tmp.dir ,就要进行修改。 网上几乎所有的教程都是如此,的确按这个教程配置完成后会在eclipse左上角出现DFS Locations,如下图 但其实还会碰见各种各样的问题,小编只将本人遇到的和解决办法呈现 (1)注意:将虚拟机的hadoop下修改的配置文件(core-site.xml hdfs-site.xml log4j.properties复制到程序的src目录下) (2)DFS下一些文件加载不出来,提示 permission denied错误 解决办法:给HDFS目录文件添加权限,hdfs dfs -chmod -R 777 / 附:推荐一篇不错的文章http://www.aboutyun.com/thread-8780-1-1.html 参考:www.tuicool.com/articles/BRBzquj www.cnblogs.com/aijianiula/p/4546021.html 常见错误和解决办法参考:http://blog.csdn.net/gamer_gyt/article/details/47252671

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

互联网架构:从碎片化到弹性世界的演进逻辑

> 当你在手机上下单一杯咖啡,背后是数百项服务、数千台服务器、跨越多个数据中心的协同舞蹈——这就是互联网架构的日常。 --- ## 一、架构是什么,为什么它如此重要? 互联网架构不是一套固定的技术栈,而是一组不断演化的**设计原则、模式与权衡**。它回答的是三个根本问题: - **如何拆分**:把庞大的系统拆成可管理的模块(服务、数据、流量) - **如何连接**:让拆分后的模块高效、可靠地通信 - **如何演进**:在流量增长、业务变更、故障发生时,系统仍能持续工作 好的架构让系统“活”起来——它能随着业务一起成长,而不是在第一次流量洪峰时就倒下。 --- ## 二、分层视角:从物理到用户 现代互联网系统通常可映射为六层逻辑视图: |层级|职责|典型组件| | --- | --- | --- | |用户端|交互与体验|App / Web / 小程序| |接入层|流量入口、安全防护|DNS、CDN、负载均衡、WAF| |网关层|路由、认证、限流、熔断|API Gateway(Nginx/Kong/Spring Cloud Gateway)| |业务层|核心业务逻辑|微服务集群(订单、用户、库存、推荐)| |数据层|持久化与缓存|关系库、NoSQL、缓存(Redis)、搜索引擎| |基础设施|计算、网络、存储|容器(K8s)、虚拟机、云服务| 每一层都是下一层的“用户”,也是上一层的“支撑”。层与层之间通过定义良好的接口(REST/gRPC/消息队列)解耦。 --- ## 三、核心架构范式速览 ### 1. 单体 → 微服务 → 服务网格 - **单体**:早期快速验证,但部署绑定、技术锁定、故障扩散严重。 - **微服务**:按业务边界拆分,独立部署与扩展,但引入了分布式复杂性(网络延迟、事务、服务发现)。 - **服务网格**:将通信、重试、监控下沉至基础设施层(如 Istio),业务代码无感。 ``` # 服务网格中的一种典型流量控制规则(少量代码示例) apiVersion: networking.istio.io/v1beta1 kind: VirtualService metadata: name: order-routing spec: hosts: - order-service http: - match: - headers: user-tier: exact: vip route: - destination: host: order-service subset: v2 # VIP用户路由到新版本 - route: - destination: host: order-service subset: v1 ``` ### 2. 分层缓存体系 缓存是互联网架构的“止痛药”,从浏览器缓存、CDN、边缘缓存,到分布式缓存(Redis Cluster)和数据库内部缓存,构成多级缓冲。**缓存设计三要诀**:命中率、失效策略、穿透防护。 ``` # 典型的缓存旁路模式(Cache-Aside)伪代码 def get_user_profile(user_id): key = f"user:{user_id}" cached = redis.get(key) if cached: return cached db_result = db.query("SELECT * FROM users WHERE id = ?", user_id) redis.setex(key, 3600, db_result) # TTL 1小时 return db_result ``` ### 3. 异步与最终一致性 分布式事务无法做到完美 ACID,于是业界采用**事件驱动 + 本地事务 + 消息表**或**发件箱模式**,用最终一致性换取高可用。消息队列(Kafka/RocketMQ)充当柔性的“事务协调器”。 --- ## 四、支撑海量流量的关键机制 |机制|解决的问题|常见实现| | --- | --- | --- | |限流|保护系统不被突发流量压垮|令牌桶、漏桶、滑动窗口(Sentinel、Guava RateLimiter)| |熔断|避免故障级联扩散|断路器模式(Hystrix、Resilience4j)| |降级|非核心功能在资源紧张时暂时关闭|动态配置开关(Apollo、Nacos)| |重试与超时|应对瞬时网络抖动|指数退避 + 抖动(Exponential Backoff + Jitter)| |隔离|资源池隔离,避免“噪声邻居”|线程池隔离、集群隔离、机房隔离| 这些机制不是独立的,它们共同构成**韧性工程**(Resilience Engineering)的基础。 --- ## 五、数据架构:分库分表与读写分离 当单表数据量超过千万级,单库连接数达到瓶颈,就需要水平扩展: - **读写分离**:主库写入,从库读取(需容忍复制延迟) - **分库分表**:按用户 ID、订单 ID 取模或范围分区(ShardingSphere、Vitess) ``` -- 分片键选择的示例规则(逻辑视图) -- 用户表按 user_id % 16 分库,按 order_date 分月表 SELECT * FROM order_db_{shard}.order_table_202601 WHERE user_id = 12345 AND order_date BETWEEN '2026-01-01' AND '2026-01-31' ``` 分库后面临的最大挑战是**跨分片查询**与**分布式 ID 生成**(雪花算法、Leaf)。 --- ## 六、可观测性:让系统“开口说话” 没有可观测性的架构如同盲飞。三大支柱: - **日志(Logging)**:结构化日志(JSON),集中采集(ELK/Loki) - **指标(Metrics)**:Prometheus + Grafana,记录 QPS、延迟分位数、错误率 - **链路追踪(Tracing)**:分布式追踪(Jaeger/Zipkin),还原一次请求的完整旅程 关键原则:**每个请求进入系统时生成全局 TraceID,透传所有下游**,这样在排查慢请求时能一键串联所有调用链。 --- ## 七、架构演进的真实驱动力 技术方案的选择从来不是纯技术问题,而是**成本、效率、稳定性、团队能力**的四方博弈。 - **初创期**:单体 + 单库 + 缓存,快速迭代 - **成长期**:微服务拆分 + 消息队列 + CDN,应对增长 - **成熟期**:多机房容灾、单元化、Service Mesh、混沌工程 - **超大规模**:自研数据库、定制硬件、架构“去中心化” 每一步演进都伴随**技术债**的偿还与新债的产生。没有“终极架构”,只有“当下最合适的架构”。 --- ## 八、未来趋势:架构正在“隐形化” 1. **Serverless / FaaS**:开发者不再关心机器,只关心函数和事件 1. **平台工程**:将基础设施能力封装为内部开发者平台(IDP),降低认知负担 1. **AI 辅助架构**:基于流量预测的自动扩缩容、异常根因定位、混沌实验生成 1. **边缘计算**:计算向用户靠近,架构从“中心辐射”走向“网状边缘” 1. **安全内建**:零信任网络、机密计算融入架构设计阶段 --- ## 九、架构师的思考框架(而非清单) 架构决策时,我经常自问三个问题: 1. **如果这个组件宕机,用户会感知到什么程度?** —— 帮助判断冗余等级 1. **团队现有能力能否维护这套方案 18 个月?** —— 避免过度设计 1. **我们是在解决今天的真实瓶颈,还是臆想的未来问题?** —— 保持务实 --- ## 结语 互联网架构的本质,是在**不确定性中构建确定性**——不确定的流量、不确定的硬件故障、不确定的业务需求,通过分层、冗余、异步、容错等模式,转化成可预测的系统行为。 架构不是一份静态的文档,也不是一套开源项目的堆砌。它是团队对世界的假设、对效率的追求、对失败的敬畏,最终凝结成一行行配置、一次次部署和一个个监控大盘。**好的架构让业务跑得更快,而伟大的架构让业务跑得更稳、更远。**

资源下载

更多资源
优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

腾讯云软件源

腾讯云软件源

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

Nacos

Nacos

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

Rocky Linux

Rocky Linux

Rocky Linux(中文名:洛基)是由Gregory Kurtzer于2020年12月发起的企业级Linux发行版,作为CentOS稳定版停止维护后与RHEL(Red Hat Enterprise Linux)完全兼容的开源替代方案,由社区拥有并管理,支持x86_64、aarch64等架构。其通过重新编译RHEL源代码提供长期稳定性,采用模块化包装和SELinux安全架构,默认包含GNOME桌面环境及XFS文件系统,支持十年生命周期更新。

用户登录
用户注册
修改密码
忘记密码