细细品味Hadoop_Hadoop集群(第5期副刊)_JDK和SSH无密码配置
- 格式:pdf
- 大小:224.26 KB
- 文档页数:9
HadoopSSH免密码登录以及失败解决⽅案1. 创建ssh-key这⾥我们采⽤rsa⽅式,使⽤如下命令:xiaosi@xiaosi:~$ ssh-keygen -t rsa -f ~/.ssh/id_rsaGenerating public/private rsa key pair.Created directory '/home/xiaosi/.ssh'.Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/xiaosi/.ssh/id_rsa.Your public key has been saved in /home/xiaosi/.ssh/id_rsa.pub.The key fingerprint is:SHA256:n/sFaAT94A/xxxxxxxxxxxxxxxxxxxxxxx xiaosi@xiaosiThe key's randomart image is:+---[xxxxx]----+| o= .. .. || o.= .. .|| *.* o .|| +.4.=E+..|| .SBo=. h+ || ogo..oo. || or +j..|| ...+o=.|| ... o=+|+----[xxxxx]-----+备注:这⾥会提⽰输⼊pass phrase,⼀定不要输⼊任何字符,回车即可。
2. ⽣成authorized_keys⽂件xiaosi@xiaosi:~$ cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys备注:记得要把authorized_keys⽂件放到.ssh⽬录下,与rsa等⽂件放在⼀起,否则免登录失败,debug如下(ssh -vvv localhost进⾏调试,查找错误原因):xiaosi@xiaosi:~$ ssh -vvv localhostOpenSSH_7.2p2 Ubuntu-4ubuntu1, OpenSSL 1.0.2g-fips 1 Mar 2016debug1: Reading configuration data /etc/ssh/ssh_configdebug1: /etc/ssh/ssh_config line 19: Applying options for *debug2: resolving "localhost" port 22debug2: ssh_connect_direct: needpriv 0debug1: Connecting to localhost [127.0.0.1] port 22.debug1: Connection established.debug1: identity file /home/xiaosi/.ssh/id_rsa type 1debug1: key_load_public: No such file or directorydebug1: identity file /home/xiaosi/.ssh/id_rsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/xiaosi/.ssh/id_dsa type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/xiaosi/.ssh/id_dsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/xiaosi/.ssh/id_ecdsa type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/xiaosi/.ssh/id_ecdsa-cert type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/xiaosi/.ssh/id_ed25519 type -1debug1: key_load_public: No such file or directorydebug1: identity file /home/xiaosi/.ssh/id_ed25519-cert type -1debug1: Enabling compatibility mode for protocol 2.0debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu1debug1: Remote protocol version 2.0, remote software version OpenSSH_7.2p2 Ubuntu-4ubuntu1debug1: match: OpenSSH_7.2p2 Ubuntu-4ubuntu1 pat OpenSSH* compat 0x04000000debug2: fd 3 setting O_NONBLOCKdebug1: Authenticating to localhost:22 as 'xiaosi'debug3: hostkeys_foreach: reading file "/home/xiaosi/.ssh/known_hosts"debug3: record_hostkey: found key type ECDSA in file /home/xiaosi/.ssh/known_hosts:1debug3: load_hostkeys: loaded 1 keys from localhostdebug3: order_hostkeyalgs: prefer hostkeyalgs: ecdsa-sha2-nistp256-cert-v01@,ecdsa-sha2-nistp384-cert-v01@,ecdsa-sha2-nistp521-cert-v01@,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521debug3: send packet: type 20debug1: SSH2_MSG_KEXINIT sentdebug3: receive packet: type 20debug1: SSH2_MSG_KEXINIT receiveddebug2: local client KEXINIT proposaldebug2: KEX algorithms: curve25519-sha256@,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1,ext-info-cdebug2: host key algorithms: ecdsa-sha2-nistp256-cert-v01@,ecdsa-sha2-nistp384-cert-v01@,ecdsa-sha2-nistp521-cert-v01@,ecdsa-sha2-nistp256,ecdsa-sha2-nistp384,ecdsa-sha2-nistp521,ssh-ed25519-cert-v01@open debug2: ciphers ctos: chacha20-poly1305@,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@,aes256-gcm@,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbcdebug2: ciphers stoc: chacha20-poly1305@,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@,aes256-gcm@,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbcdebug2: MACs ctos: umac-64-etm@,umac-128-etm@,hmac-sha2-256-etm@,hmac-sha2-512-etm@,hmac-sha1-etm@,umac-64@,umac-128@,hmac-sha2-256,hmac-debug2: MACs stoc: umac-64-etm@,umac-128-etm@,hmac-sha2-256-etm@,hmac-sha2-512-etm@,hmac-sha1-etm@,umac-64@,umac-128@,hmac-sha2-256,hmac-debug2: compression ctos: none,zlib@,zlibdebug2: compression stoc: none,zlib@,zlibdebug2: languages ctos:debug2: languages stoc:debug2: first_kex_follows 0debug2: reserved 0debug2: peer server KEXINIT proposaldebug2: KEX algorithms: curve25519-sha256@,ecdh-sha2-nistp256,ecdh-sha2-nistp384,ecdh-sha2-nistp521,diffie-hellman-group-exchange-sha256,diffie-hellman-group14-sha1debug2: host key algorithms: ssh-rsa,rsa-sha2-512,rsa-sha2-256,ecdsa-sha2-nistp256,ssh-ed25519debug2: ciphers ctos: chacha20-poly1305@,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@,aes256-gcm@debug2: ciphers stoc: chacha20-poly1305@,aes128-ctr,aes192-ctr,aes256-ctr,aes128-gcm@,aes256-gcm@debug2: MACs ctos: umac-64-etm@,umac-128-etm@,hmac-sha2-256-etm@,hmac-sha2-512-etm@,hmac-sha1-etm@,umac-64@,umac-128@,hmac-sha2-256,hmac-debug2: MACs stoc: umac-64-etm@,umac-128-etm@,hmac-sha2-256-etm@,hmac-sha2-512-etm@,hmac-sha1-etm@,umac-64@,umac-128@,hmac-sha2-256,hmac-debug2: compression ctos: none,zlib@debug2: compression stoc: none,zlib@debug2: languages ctos:debug2: languages stoc:debug2: first_kex_follows 0debug2: reserved 0debug1: kex: algorithm: curve25519-sha256@debug1: kex: host key algorithm: ecdsa-sha2-nistp256debug1: kex: server->client cipher: chacha20-poly1305@ MAC: <implicit> compression: nonedebug1: kex: client->server cipher: chacha20-poly1305@ MAC: <implicit> compression: nonedebug3: send packet: type 30debug1: expecting SSH2_MSG_KEX_ECDH_REPLYdebug3: receive packet: type 31debug1: Server host key: ecdsa-sha2-nistp256 SHA256:378enl3ckhdpObP8fnsHr1EXz4d1q2Jde+jUplkub/Ydebug3: hostkeys_foreach: reading file "/home/xiaosi/.ssh/known_hosts"debug3: record_hostkey: found key type ECDSA in file /home/xiaosi/.ssh/known_hosts:1debug3: load_hostkeys: loaded 1 keys from localhostdebug1: Host 'localhost' is known and matches the ECDSA host key.debug1: Found key in /home/xiaosi/.ssh/known_hosts:1debug3: send packet: type 21debug2: set_newkeys: mode 1debug1: rekey after 134217728 blocksdebug1: SSH2_MSG_NEWKEYS sentdebug1: expecting SSH2_MSG_NEWKEYSdebug3: receive packet: type 21debug2: set_newkeys: mode 0debug1: rekey after 134217728 blocksdebug1: SSH2_MSG_NEWKEYS receiveddebug2: key: /home/xiaosi/.ssh/id_rsa (0x5602df5e80c0)debug2: key: /home/xiaosi/.ssh/id_dsa ((nil))debug2: key: /home/xiaosi/.ssh/id_ecdsa ((nil))debug2: key: /home/xiaosi/.ssh/id_ed25519 ((nil))debug3: send packet: type 5debug3: receive packet: type 7debug1: SSH2_MSG_EXT_INFO receiveddebug1: kex_input_ext_info: server-sig-algs=<rsa-sha2-256,rsa-sha2-512>debug3: receive packet: type 6debug2: service_accept: ssh-userauthdebug1: SSH2_MSG_SERVICE_ACCEPT receiveddebug3: send packet: type 50debug3: receive packet: type 51debug1: Authentications that can continue: publickey,passworddebug3: start over, passed a different list publickey,passworddebug3: preferred gssapi-keyex,gssapi-with-mic,publickey,keyboard-interactive,passworddebug3: authmethod_lookup publickeydebug3: remaining preferred: keyboard-interactive,passworddebug3: authmethod_is_enabled publickeydebug1: Next authentication method: publickeydebug1: Offering RSA public key: /home/xiaosi/.ssh/id_rsadebug3: send_pubkey_testdebug3: send packet: type 50debug2: we sent a publickey packet, wait for replydebug3: receive packet: type 51debug1: Authentications that can continue: publickey,passworddebug1: Trying private key: /home/xiaosi/.ssh/id_dsadebug3: no such identity: /home/xiaosi/.ssh/id_dsa: No such file or directorydebug1: Trying private key: /home/xiaosi/.ssh/id_ecdsadebug3: no such identity: /home/xiaosi/.ssh/id_ecdsa: No such file or directorydebug1: Trying private key: /home/xiaosi/.ssh/id_ed25519debug3: no such identity: /home/xiaosi/.ssh/id_ed25519: No such file or directorydebug2: we did not send a packet, disable methoddebug3: authmethod_lookup passworddebug3: remaining preferred: ,passworddebug3: authmethod_is_enabled passworddebug1: Next authentication method: passwordxiaosi@localhost's password:3. 验证xiaosi@xiaosi:~$ ssh localhostThe authenticity of host 'localhost (127.0.0.1)' can't be established.ECDSA key fingerprint is SHA256:378enl3ckhdpObP8fnsHr1EXz4d1q2Jde+jUplkub/Y.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added 'localhost' (ECDSA) to the list of known hosts.sign_and_send_pubkey: signing failed: agent refused operationxiaosi@localhost's password:4. authorized_keys权限我们可以看到还是让我输⼊密码,很⼤可能是authorized_keys⽂件权限的问题,我们给该⽂件赋予⼀定权限:xiaosi@xiaosi:~$ chmod 600 ~/.ssh/authorized_keys再次验证:xiaosi@xiaosi:~$ ssh localhostWelcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-24-generic x86_64)* Documentation: https:///0 个可升级软件包。
安装hadoop集群应使所有节点使用同一用户名(先设置ssh免密码访问localhost,再安装jdk,在安装hadoop)sudo apt-get update安装ssh sudo apt-get install ssh(hadoop02ubuntuserver2中hadoop02代表用户名;ubuntuserver2代表机器名)1、hadoop02ubuntuserver2:/root$ ssh-keygen -t rsa命令,出现一下结果,我一直按Enter,按到最后,Generating public/private rsa key pair.Enter file in which to save the key (/home/hadoop02/.ssh/id_rsa):Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /home/hadoop02/.ssh/id_rsa.Your public key has been saved in /home/hadoop02/.ssh/id_rsa.pub.The key fingerprint is:0f:7e:45:6c:40:7c:9d:46:c5:12:31:09:5c:2c:4a:aa hadoop02ubuntuserver2The key's randomart image is:+--[ RSA 2048]----+| oo..**B.|| oo+ B..|| o o+o . || . .o || .S . || E. o . || . o || . || |+-----------------+2、hadoop02ubuntuserver2:/root$ cat .ssh/id_rsa.pub >> .ssh/authorized_keys注意:cat 与.ssh之间有空格,id_rsa.pub与>>之间有空格3、hadoop02ubuntuserver2:~$ cd .ssh4、hadoop02ubuntuserver2:~$ ls -aauthorized_keys id_rsa id_rsa.pub(ls出来的结果)5、hadoop02ubuntuserver2:~/.ssh$ ssh localhost (进行检测,是否可以访问本机无密码登录,本机无密码登录就做到这一步就可以了,下面的是两台电脑之间的无密码登录,先不用做)6、把hadoop02中的id_rsa.pub拷贝到hadoop01中(注意将目录切换到.ssh目录下)hadoop02ubuntuserver2:~/.ssh$ scp id_rsa.pub hadoop01192.168.1.135:/home/hadoop01 注意:hadoop01192.168.1.135在ubuntu操作系统中必须这样写,否则就会出现错误。
Hadoop集群配置免密SSH登录⽅法Hadoop集群配置免密SSH登录⽅法Hadoop集群包含1个主节点和3个从节点,需要实现各节点之间的免密码登录,下⾯介绍具体的实现⽅法。
⼀、Hadoop集群环境⼆、免密登录原理每台主机authorized_keys⽂件⾥⾯包含的主机(ssh密钥),该主机都能⽆密码登录,所以只要每台主机的authorized_keys⽂件⾥⾯都放⼊其他主机(需要⽆密码登录的主机)的ssh密钥就⾏了。
三、实现⽅法1. 配置每个节点的hosts⽂件#vim /etc/hosts1 192.168.44.3 hadoop012 192.168.44.4 hadoop023 192.168.44.5 hadoop034 192.168.44.6 hadoop042. 每个节点⽣成ssh密钥[root@hadoop01 ~]# ssh-keygen -t rsaGenerating public/private rsa key pair.Enter file in which to save the key (/root/.ssh/id_rsa):Created directory '/root/.ssh'.Enter passphrase (empty for no passphrase):Enter same passphrase again:Your identification has been saved in /root/.ssh/id_rsa.Your public key has been saved in /root/.ssh/id_rsa.pub......................[root@hadoop01 .ssh]# lsid_rsa id_rsa.pub执⾏命令后会在~⽬录下⽣成.ssh⽂件夹,⾥⾯包含id_rsa和id_rsa.pub两个⽂件。
Hadoop集群安装与配置及其示例程序的运行(虚拟机下实现)系统:Ubuntu 12.04虚拟机软件:VMware WorkstationHadoop2.6.0【特别声明:安装的Ubuntu虚拟机操作系统的位数一定要和Hadoop的位数一致!!建议都装64位的。
】单机情况下安装:一、安装jdk 【我下载的jdk版本是:jdk-7u51-linux-i586.tar.gz。
安装后的版本号是:jdk1.7.0_75】去下载jdk-***.tar.gz文件,下载完得到压缩包,解压到要安装的目录下。
(例如解压到/etc下)命令:tar -zxvf jdk-***.tar.gz -C ~/etc 【将jdk压缩包解压到/etc目录下】设置坏境变量:修改用户目录下的.bashrc文件【命令是$ gedit ~/.bashrc】,在文件末尾加入:set JAVA_HOME=/home/becy/etc/jdk1.7.0_75export JAVA_HOMEset JRE_HOME=/home/becy/etc/jdk1.7.0_75/jreExport JRE_HOMEset PATH=$JAVA_HOME/bin:$PATHexport PATHset CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jarexport CLASSPATH保存文件后退出。
然后再命令行输入$ source ~/.bashrc使刚才设置的环境变量生效。
接着输入命令$ java -version会弹出以下窗口:然后按照提示,在命令行输入$ sudo apt-get install openjdk-7-jre-headles s完成jdk 的安装工作【安装过程约20分钟】。
接着测试是否安装成功输入命令:$ java –version以上显示则安装成功。
二、添加专用的Hadoop系统用户我们将利用专用用户来运行Hadoop,这不是必须的,但是建议这么做,主要考虑安全,权限等问题。
通过前面的操作,已经完成了三台虚拟机Hadoop01、Hadoop02和Hadoop03的和网络配置,虽然这些虚拟机已经可以正常使用了,但依然存在下列问题。
(1)实际工作中,器被放置在机房中,同时受到地域和管理的限制,发人员通常不会进入机房操作直接上机操作,而通过远程连接器,进行相关操作。
(2)在集群发中,主节通常会对集群中各个节频繁的访问,就需要不断输入目标器的用户名和密码,这种操作非常麻烦并且还会影响集群的连续运行。
为了解决上述问题,可以通过配置SSH来分别实现远程登录和SSH免密登录功能。
接下来,就分别对这两种配置和说明进行详细讲解。
1.SSH远程登录功能配置SSH为SecureShell的缩写,它一种网络协议,专为远程登录会话和其他网络性的协议。
通过使用SSH,可以把传输的数据进行加密,有效防止远程管理过程中的信息泄露问题。
为了使用SSH,器首先必须并启相应的SSH。
在CentOS系统下,可以先执行“rpm-qa|grepssh”指令查看当前机器否SSH,同时使用“ps-e|grepsshd”指令查看SSH否启动,如图1所示。
图1查看否和启SSH从图1可以看出,CentOS虚拟机已经默认并启了SSH,所以不需要进行额外,就可以进行远程连接访问(如果没有,CentOS系统下可以执行“yuminstallopenssh-server”指令进行)。
在目标器已经SSH,并且支持远程连接访问后,在实际发中,发人员通常会通过一个远程连接工具来连接访问目标器。
本教材就介绍一个实际发中常用的SecureCRT远程连接工具来演示远程器的连接和使用。
SecureCRT一款支持SSH的终端仿真程序,它能够在Windows操作系统上远程连接Linux器执行操作。
本书采用SecureCRT7.2版本进行介绍说明,读者可以通过https://www.vandyke./download/securecrt/7.2/index.html,自行下载。
简述启动和关闭hadoop集群的方式以及使用的相关指令。
Hadoop是一个开源的分布式数据处理框架,通常用于存储和处理大规模的数据集。
启动和关闭Hadoop集群是使用Hadoop框架的关键步骤。
本文将一步一步回答如何启动和关闭Hadoop集群,以及使用的相关指令。
一、Hadoop集群启动方式Hadoop集群可以通过两种方式进行启动:单节点启动和多节点启动。
1. 单节点启动单节点启动适用于在本地主机运行Hadoop的开发和测试环境。
在单节点启动方式下,所有Hadoop的组件都运行在一台主机上。
以下是单节点启动Hadoop集群的步骤:1. 安装Java开发环境在启动Hadoop之前,首先需要在机器上安装Java开发环境。
Hadoop依赖于Java来运行。
可以从Oracle官方网站下载并安装Java Development Kit(JDK)。
2. 配置Hadoop环境下载Hadoop的最新版本,并解压到本地目录。
接下来,需要配置Hadoop的环境变量。
打开Hadoop的安装目录,在conf目录下找到hadoop-env.sh文件。
通过编辑这个文件,设置正确的JAVA_HOME 路径。
3. 配置Hadoop集群在启动单节点Hadoop集群之前,需要配置Hadoop集群的相关参数。
打开conf目录下的core-site.xml和hdfs-site.xml文件,分别进行配置。
主要包括配置Hadoop文件系统的URL,配置Hadoop的本地文件夹路径,以及配置Hadoop的端口号等。
4. 格式化Hadoop文件系统在单节点模式下,需要手动初始化Hadoop文件系统。
在Hadoop 的安装目录下,使用命令`bin/hdfs namenode -format` 来格式化文件系统。
5. 启动Hadoop集群在Hadoop的安装目录下,使用命令`sbin/start-all.sh`来启动Hadoop集群。
这个命令会启动Hadoop的所有组件,包括NameNode,DataNode,SecondaryNameNode,以及JobTracker 等。
出于安全性考虑,将这个授权key文件赋予600权限:3.将这个包含了所有互信机器认证key的认证文件,分发到各个机器中去4.验证互信,各节点执行下面命令,能不输入密码显示时间,配置成功5.配置完互信,在各节点上配置(1)/etc/ssh/sshd_config:RSAAuthentication yesPubkeyAuthentication yes(2)/etc/hosts127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 172.16.81.131 master172.16.81.132 slave1172.16.81.133 slave2(3)把master的known_hosts复制到slave:scp known_hosts hadoop@172.16.81.132:~/.ssh/scp known_hosts hadoop@172.16.81.133:~/.ssh/(4)权限设置:chmod go-w ~/chmod 755 ~/.sshchmod 600 ~/.ssh/authorized_keys各节点用root登录重启ssh:/etc/init.d/sshd restart完毕注意事项:上面做完,maste登录到slave1和slave2,还是要输入密码,最后,没办法,把master机上的id_rsa.pub的内容直接复制到slave1和slave2的authorized_keys的第一行,重启ssh,得到解决。
下面是另一种方法:Ø创建或者修改密钥目录权限假设本机的IP为“172.16.81.129”,配置免登录的操作步骤如下:1. 以hadoop用户登录各服务器。
Hadoop集群配置⼼得(低配置集群+⾃动同步配置)本⽂为本⼈原创,⾸发到炼数成⾦。
情况是这样的,我没有⼀个⾮常强劲的电脑来搞出⼀个性能⾮常NB的服务器集群,相信很多⼈也跟我差不多,所以现在把我的低配置集群经验拿出来写⼀下好了。
我的配备:1)五六年前的赛扬单核处理器2G内存笔记本 2)公司给配的ThinkpadT420,i5双核处理器4G内存(可⽤内存只有3.4G,是因为装的是32位系统的缘故吧。
)就算是⽤公司配置的电脑,做出来三台1G内存的虚拟机也显然是不现实的。
企业笔记本运⾏的软件多啊,什么都不做空余内存也才不到3G。
所以呢,我的想法就是:⽤我⾃⼰的笔记本(简称PC1)做Master节点,⽤来跑Jobtracker,Namenode 和SecondaryNamenode;⽤公司的笔记本跑两个虚拟机(简称VM1和VM2),⽤来做Slave节点,跑Tasktracker和Datanode。
这么做的话,就需要让PC1,VM1和VM2处于同⼀个⽹段⾥,保证他们之间可以互相连通。
⽹络环境:我的两台电脑都是通过⼀个⽆线路由上⽹。
构建跟外部的电脑同⼀⽹段的虚拟机配置过程:准备⼯作:构建⼀个集群,⾸先前提条件是每台服务器都要有⼀个固定的IP地址,然后才可能进⾏后续的操作。
所以呢,先把我的两台笔记本电脑全部设置成固定IP(注意,如果像我⼀样使⽤⽆线路由上⽹,那就要把⽆线⽹卡的IP设置成固定IP)。
⽤来做Master节点的PC1:192.168.33.150,⽤来跑虚拟机的宿主笔记本:192.168.33.157。
⽬标:VM1和VM2的IP地址分别设置成192.168.33.151和152。
步骤:1)新建VM1虚拟机。
2)打开VM1的⽹卡设置界⾯,连接⽅式选Bridge。
(桥接)关于桥接的具体信息,可以百度⼀下。
我们需要知道的,就是⽤桥接的⽅式,可以让虚拟机通过本机的⽹关来上⽹,所以就可以跟本机处于同⼀个⽹段,互相之间可以进⾏通信。
Hadoop详细安装过程一、本文思路1、安装虚拟化PC工具VMware,用于支撑Linux系统。
2、在VMware上安装Ubuntu系统。
3、安装Hadoop前的准备工作:安装JDK和SSH服务。
4、配置Hadoop。
5、为了方便开发过程,需安装eclipse。
6、运行一个简单的Hadoop程序:WordCount.java注:在win7系统上,利用虚拟工具VMware建立若干个Linux系统,每个系统为一个节点,构建Hadoop集群。
先在一个虚拟机上将所有需要配置的东西全部完成,然后再利用VMware 的克隆功能,直接生成其他虚拟机,这样做的目的是简单。
二、所需软件1、VMware:VMware Workstation,直接百度下载(在百度软件中心下载即可)。
2、Ubuntu系统:ubuntu-15.04-desktop-amd64.iso,百度网盘:/s/1qWxfxso注:使用15.04版本的Ubuntu(其他版本也可以),是64位系统。
3、jdk:jdk-8u60-linux-x64.tar.gz,网址:/technetwork/java/javase/downloads/jdk8-downloads-2133151.html注:下载64位的Linux版本的jdk。
4、Hadoop:hadoop-1.2.1-bin.tar.gz,网址:/apache/hadoop/common/hadoop-1.2.1/注:选择1.2.1版本的Hadoop。
5、eclipse:eclipse-java-mars-1-linux-gtk-x86_64.tar.gz,网址:/downloads/?osType=linux注:要选择Linux版本的,64位,如下:6、hadoop-eclipse-plugin-1.2.1.jar,这是eclipse的一个插件,用于Hadoop的开发,直接百度下载即可。
三、安装过程1、安装VMware。
细细品味Hadoop——Hadoop集群(第5期副刊)精华集锦csAxp虾皮工作室/xia520pi/2012年5月8日Hadoop集群(第5期副刊)——JDK和SSH无密码配置1、Linux配置java环境变量1.1 原文出处地址:/jiedushi/article/details/66728941.2 解压安装jdk在shell终端下进入jdk-6u14-linux-i586.bin文件所在目录,执行命令 ./jdk-6u14-linux-i586.bin 这时会出现一段协议,连继敲回车,当询问是否同意的时候,输入yes,回车。
之后会在当前目录下生成一个jdk1.6.0_14目录,你可以将它复制到任何一个目录下。
1.3 需要配置的环境变量1)PATH环境变量作用是指定命令搜索路径,在shell下面执行命令时,它会到PATH变量所指定的路径中查找看是否能找到相应的命令程序。
我们需要把 jdk安装目录下的bin目录增加到现有的PATH变量中,bin目录中包含经常要用到的可执行文件如javac/java/javadoc等待,设置好PATH变量后,就可以在任何目录下执行javac/java等工具了。
2)CLASSPATH环境变量作用是指定类搜索路径,要使用已经编写好的类,前提当然是能够找到它们了,JVM 就是通过CLASSPTH来寻找类的。
我们需要把jdk安装目录下的lib子目录中的dt.jar和tools.jar设置到CLASSPATH中,当然,当前目录“.”也必须加入到该变量中。
3)JA V A_HOME环境变量它指向jdk的安装目录,Eclipse/NetBeans/Tomcat等软件就是通过搜索JA V A_HOME变量来找到并使用安装好的jdk。
1.4 三种配置环境变量的方法1)修改/etc/profile文件如果你的计算机仅仅作为开发使用时推荐使用这种方法,因为所有用户的shell都有权使用这些环境变量,可能会给系统带来安全性问题。
●用文本编辑器打开/etc/profile●在profile文件末尾加入:export JA V A_HOME=/usr/share/jdk1.6.0_14export PATH=$JA V A_HOME/bin:$PATHexport CLASSPATH=.:$JA V A_HOME/lib/dt.jar:$JA V A_HOME/lib/tools.jar●重新登录●注解a. 你要将 /usr/share/jdk1.6.0_14改为你的jdk安装目录b. linux下用冒号“:”来分隔路径c. $PATH / $CLASSPATH / $JA V A_HOME 是用来引用原来的环境变量的值在设置环境变量时特别要注意不能把原来的值给覆盖掉了,这是一种常见的错误。
d. CLASSPATH中当前目录“.”不能丢,把当前目录丢掉也是常见的错误。
e. export是把这三个变量导出为全局变量。
f. 大小写必须严格区分。
2)修改.bash_profile文件这种方法更为安全,它可以把使用这些环境变量的权限控制到用户级别,如果你需要给某个用户权限使用这些环境变量,你只需要修改其个人用户主目录下的.bash_profile文件就可以了。
●用文本编辑器打开用户目录下的.bash_profile文件●在.bash_profile文件末尾加入:export JA V A_HOME=/usr/share/jdk1.6.0_14export PATH=$JA V A_HOME/bin:$PATHexport CLASSPATH=.:$JA V A_HOME/lib/dt.jar:$JA V A_HOME/lib/tools.jar●重新登录3)直接在shell下设置变量不赞成使用这种方法,因为换个shell,你的设置就无效了,因此这种方法仅仅是临时使用,以后要使用的时候又要重新设置,比较麻烦。
只需在shell终端执行下列命令:export JA V A_HOME=/usr/share/jdk1.6.0_14export PATH=$JA V A_HOME/bin:$PATHexport CLASSPATH=.:$JA V A_HOME/lib/dt.jar:$JA V A_HOME/lib/tools.jar1.5 测试jdk1)用文本编辑器新建一个Test.java文件,在其中输入以下代码并保存:public class test {public static void main(String args[]) {System.out.println("A new jdk test !");}}2)编译:在shell终端执行命令 javac Test.java3)运行:在shell终端执行命令 java Test当shell下出现“A new jdk test !”字样则jdk运行正常。
1.6 卸载jdk●找到jdk安装目录的_uninst子目录●在shell终端执行命令./uninstall.sh即可卸载jdk。
2、配置OpenSSH无密码登陆2.1 原文出处地址:/topic/4216082.2 文章序言最近在搭建Hadoop环境需要设置无密码登陆,所谓无密码登陆其实是指通过证书认证的方式登陆,使用一种被称为"公私钥"认证的方式来进行ssh登录。
在linux系统中,ssh是远程登录的默认工具,因为该工具的协议使用了RSA/DSA的加密算法.该工具做linux系统的远程管理是非常安全的。
telnet,因为其不安全性,在linux系统中被搁置使用了。
" 公私钥"认证方式简单的解释:首先在客户端上创建一对公私钥(公钥文件:~/.ssh/id_rsa.pub;私钥文件:~/.ssh/id_rsa)。
然后把公钥放到服务器上(~/.ssh/authorized_keys), 自己保留好私钥.在使用ssh登录时,ssh程序会发送私钥去和服务器上的公钥做匹配.如果匹配成功就可以登录了。
在Ubuntu和Cygwin 配置都很顺利,而在Centos系统中配置时遇到了很多问题。
故此文以Centos(Centos5 )为例详细讲解如何配置证书验证登陆,具体操作步骤如下:2.3 确认系统已经安装好OpenSSH的server 和client安装步骤这里不再讲述,不是本文的重点。
2.4 确认本机sshd的配置文件(root)$ vi /etc/ssh/sshd_config找到以下内容,并去掉注释符”#“RSAAuthentication yesPubkeyAuthentication yesAuthorizedKeysFile .ssh/authorized_keys2.5 如果修改了配置文件需要重启sshd服务(root)$ vi /sbin/service sshd restart2.6 ssh登陆系统后执行测试命令$ ssh localhost回车会提示你输入密码,因为此时我们还没有生成证书。
2.7 生成证书公私钥的步骤$ ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys2.8 测试登陆 ssh localhost$ ssh localhost正常情况下会登陆成功,显示一些成功登陆信息,如果失败请看下面的“一般调试步骤”。
2.9 一般调试步骤本人在配置时就失败了,按照以上步骤依旧提示要输入密码。
于是用ssh -v 显示详细的登陆信息查找原因:$ ssh -v localhost回车显示了详细的登陆信息如下:。
省略debug1: Authentications that can continue: publickey,gssapi-with-mic,passworddebug1: Next authentication method: gssapi-with-micdebug1: Unspecified GSS failure. Minor code may provide more informationUnknown code krb5 195debug1: Unspecified GSS failure. Minor code may provide more informationUnknown code krb5 195debug1: Unspecified GSS failure. Minor code may provide more informationUnknown code krb5 195debug1: Next authentication method: publickeydebug1: Trying private key: /home/huaxia/.ssh/identitydebug1: Trying private key: /home/huaxia/.ssh/id_rsadebug1: Offering public key: /home/huaxia/.ssh/id_dsadebug1: Authentications that can continue: publickey,gssapi-with-mic,passworddebug1: Next authentication method: passwordhuaxia@localhost's password:同时用root用户登陆查看系统的日志文件:$tail /var/log/secure -n 20。
省略Jul 13 11:21:05 shnap sshd[3955]: Accepted password for huaxia from 192.168.8.253 port 51837 ssh2Jul 13 11:21:05 shnap sshd[3955]: pam_unix(sshd:session): session opened for user huaxia by (uid=0)Jul 13 11:21:47 shnap sshd[4024]: Connection closed by 127.0.0.1Jul 13 11:25:28 shnap sshd[4150]: Authentication refused: bad ownership or modes for file /home/huaxia/.ssh/authorized_keysJul 13 11:25:28 shnap sshd[4150]: Authentication refused: bad ownership or modes for file /home/huaxia/.ssh/authorized_keysJul 13 11:26:30 shnap sshd[4151]: Connection closed by 127.0.0.1。