Hadoop自学笔记(五)配置分布式Hadoop环境
上一课讲了如何在一台机器上建立Hadoop环境,我们只配置了一个NHName Node, 这个Name Node里面包含了我们所有Hadoop的东西,包括Name Node, Secondary Name Node, Job Tracker, Task Tracker,这一课讲解如何把上述配置放到不同机器上,从而构建一个分布式的
上一课讲了如何在一台机器上建立Hadoop环境,我们只配置了一个NHName Node, 这个Name Node里面包含了我们所有Hadoop的东西,包括Name Node, Secondary Name Node, Job Tracker, Task Tracker,这一课讲解如何把上述配置放到不同机器上,从而构建一个分布式的hadoop配置。
1. hadoop分布式安装概览
a) 2-10个nodes:Name Node, Job Tracker, Secondary Name Node都可以放在一台机器上,所有的Data Node和Task Tracker放在其他机器上
b) 10-40个nodes: 可以把Secondary Name Node分开来
c) 100+ nodes: 所有的Node和Trackers都分开放,并且添加rack awareness支持,同时需要各类优化设置。
本课的流程:
配置好ssh到所有的机器上,使其可以免输入密码连接(如同上一课所述)
配置好masters和slaves
配置好所有的*-site文件
学习使用命令来启动,控制和关闭Hadoop(常用脚本说明如下图)。

2. 配置Hadoop到2-10个节点上
这个图很帅,我们在HN Client机器上来控制所有的Hadoop机器,每个机器给一个窗口(下图已经通过ssh链接到每台机器了,链接方式见上一课)。
第一步:取消所有机器上面的ssh密码访问
ssh-copy-id -i $HOME/.ssh/id-rsa.pub nuggetuser@HNData1
把这个文件拷贝到所有的HNData和Secondary Name Node上面。这样就可以无密码登陆了。

第二步:配置Master和Slaves
所有的配置文件都在/usr/local/hadoop/conf文件夹下面
配置好masters来指向Secondary Name Node, 然后配置slaves文件指向所有的HNData Node
Master文件默认的是localhost
用任何编辑器打开masters文件,删除localhost, 输入HN2ndName (就是你Secondary Name Node 的名称)
同样,编辑slaves文件,把所有的HNData Node名称输入

第三步:配置所有的Data Node,让它们指向Name Node,所有的Task Tracker指向Job Tracker
通过core-site.xml配置前者,通过mapred-site.xml配置后者
在HNData Node配置core-site.xml如下(因为我们是直接把上次的机器配置拷贝进来的,所以可以发现这个文件已经配置过了,如下:)

配置mapred-site.xml如下:

上面的配置应该已经是这样了,不过最好还是检查好每一个Data Node中的配置是不是这样
第四步:重新格式化Name Node
hadoop namenode -format
第五步:配置完成了,可以试着看看能否启动
start-dfs.sh 这个命令启动所有的Name Nodes和Data Nodes,可以使用jps命令来查看是否成功启动了。

start-mapred.sh 这个命令启动所有的Job Trackers和Task Trackers, 同样使用jps来检测是否启动了,如果没有成功,可以去看看logs文件
3. 启动和关闭Hadoop各部分的命令
如果要删除一个node,可以建立一个excludes文件,在里面输入你不想要的node名称,比如HNData3.
然后配置HN Name Node中core-site.xml如下(在最后添加一个property)

同样可以建立一个includes文件来指定包含哪些节点
配置完成后,启用配置:
hadoop dfsadmin -refreshNodes
我们可以在hnname:50070上面看到被排除的Node

运行rebalancer命令
start-balancer.sh
关闭Job Tracker, Task Tracker:
stop-mapred.sh
关闭Name Node, Data Nodes:
stop-dfs.sh

如果要同时启动HNName Node, Data Node, Job Tracker, Task Tracker,则直接输入:
start-all.sh

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

ToaddauserremotelytoMySQL,followthesesteps:1)ConnecttoMySQLasroot,2)Createanewuserwithremoteaccess,3)Grantnecessaryprivileges,and4)Flushprivileges.BecautiousofsecurityrisksbylimitingprivilegesandaccesstospecificIPs,ensuringstrongpasswords,andmonitori

TostorestringsefficientlyinMySQL,choosetherightdatatypebasedonyourneeds:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseTEXTforlong-formtextcontent.4)UseBLOBforbinarydatalikeimages.Considerstorageov

When selecting MySQL's BLOB and TEXT data types, BLOB is suitable for storing binary data, and TEXT is suitable for storing text data. 1) BLOB is suitable for binary data such as pictures and audio, 2) TEXT is suitable for text data such as articles and comments. When choosing, data properties and performance optimization must be considered.

No,youshouldnotusetherootuserinMySQLforyourproduct.Instead,createspecificuserswithlimitedprivilegestoenhancesecurityandperformance:1)Createanewuserwithastrongpassword,2)Grantonlynecessarypermissionstothisuser,3)Regularlyreviewandupdateuserpermissions

MySQLstringdatatypesshouldbechosenbasedondatacharacteristicsandusecases:1)UseCHARforfixed-lengthstringslikecountrycodes.2)UseVARCHARforvariable-lengthstringslikenames.3)UseBINARYorVARBINARYforbinarydatalikecryptographickeys.4)UseBLOBorTEXTforlargeuns


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

SecLists
SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Atom editor mac version download
The most popular open source editor
