新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

hadoopha集群搭建(5台)-创新互联

yum install ntpdate lrzsz -y

创新互联主营天坛街道网站建设的网络公司,主营网站建设方案,成都app软件开发,天坛街道h5微信小程序定制开发搭建,天坛街道网站营销推广欢迎天坛街道等地区企业咨询

systemctl stop firewalld
systemctl disable firewalld
systemctl stop NetworkManager
systemctl disable NetworkManager
setenforce 0

mkdir /home/myapps && cd /home/myapps

hosts文件配置:
cat >> /etc/hosts << EOF
192.168.163.129 node1
192.168.163.131 node2
192.168.163.132 node3
192.168.163.133 node4
192.168.163.128 node5
EOF

时间同步配置:
/usr/sbin/ntpdate ntp1.aliyun.com
crontab -e
/30 * /usr/sbin/ntpdate ntp1.aliyun.com

互信配置:
ssh-keygen
for ip in 132 129 131 133 128;do ssh-copy-id -i ~/.ssh/id_rsa.pub root@192.168.163.$ip ;done

java环境变量配置:
java -version
vim /etc/profile
export JAVA_HOME=/home/myapp/java
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

source /etc/profile

zookeeper集群搭建:
vim /etc/profile

export ZOOKEEPER_HOME=/usr/local/zookeeper-3.4.11
export PATH=$PATH:$ZOOKEEPER_HOME/bin

cd /home/myapps/zookeeper-3.4.11/
mkdir data
mkdir log
vim conf/zoo.cfg

dataDir=/home/myapps/zookeeper-3.4.11/data
    dataLogDir=/home/myapps/zookeeper-3.4.11/log
    server.1=node1:2888:3888
    server.2=node2:2888:3888
    server.3=node3:2888:3888
将修改配置文件推送到各个节点:
scp -r zookeeper-3.4.11 root@node2:/home/myapps/
scp -r zookeeper-3.4.11 root@node3:/home/myapps/

设置myid
在我们配置的dataDir指定的目录下面,创建一个myid文件,里面内容为一个数字,用来标识当前主机
[root@node1 zookeeper-3.4.11]# echo "1" > /home/myapps/zookeeper-3.4.11/data/myid
[root@node2 zookeeper-3.4.11]# echo "2" > /home/myapps/zookeeper-3.4.11/data/myid
[root@node3 zookeeper-3.4.11]# echo "3" > /home/myapps/zookeeper-3.4.11/data/myid
启动集群:
[root@node1 zookeeper-3.4.11]# /home/myapps/zookeeper-3.4.11/bin/zkServer.sh start
[root@node2 zookeeper-3.4.11]# /home/myapps/zookeeper-3.4.11/bin/zkServer.sh start
[root@node3 zookeeper-3.4.11]# /home/myapps/zookeeper-3.4.11/bin/zkServer.sh start

hadoop集群搭建:
cd /home/myapps/hadoop/hadoop-2.7.5/etc/hadoop

vim hadoop-env.sh

25 export JAVA_HOME=/home/myapp/java

vim yarn-env.sh

23 export JAVA_HOME=/home/myapp/java

vim hdfs-site.xml



  dfs.nameservices
  mycluster


  dfs.ha.namenodes.mycluster
  nn1,nn2


  dfs.namenode.rpc-address.mycluster.nn1
  node1:8020


  dfs.namenode.rpc-address.mycluster.nn2
  node2:8020


  dfs.namenode.http-address.mycluster.nn1
  node1:50070


  dfs.namenode.http-address.mycluster.nn2
  node2:50070


  dfs.namenode.shared.edits.dir
 qjournal://node3:8485;node4:8485;node5:8485/mycluster


  dfs.client.failover.proxy.provider.mycluster
  org.apache.hadoop.hdfs.server.namenode.ha.ConfiguredFailoverProxyProvider


      dfs.ha.fencing.methods
      sshfence
    
    
      dfs.ha.fencing.ssh.private-key-files
      /root/.ssh/id_dsa
    

  dfs.journalnode.edits.dir
  /home/myapps/hadoop/node/local/data


   dfs.ha.automatic-failover.enabled
   true
 
 

vim core-site.xml



       fs.defaultFS
       hdfs://mycluster
   
   
        hadoop.tmp.dir
       /home/myapps/hadoop/data/hadoop/temp
       Abase for other temporarydirectories.
   
 
       ha.zookeeper.quorum
       node1:2181,node2:2181,node3:2181

vim yarn-site.xml




  yarn.resourcemanager.hostname
  node1


    yarn.nodemanager.aux-services
    mapreduce_shuffle


        yarn.nodemanager.aux-services.mapreduce_shuffle.class
        org.apache.hadoop.mapred.ShuffleHandler

vim mapred-site.xml


    
        mapreduce.framework.name
        yarn
        Execution framework set to Hadoop YARN.
    

vim slaves
node3
node4
node5

将修改后的hadoop拷贝到各个节点:
for ip in 2 3 4 5 ;do scp -r /home/myapps/hadoop root@node${ip}:/home/myapps/ ;done

首先启动zookeeper:
验证:jps查看进程 QuorumPeerMain
hadoop集群启动:

1、在node3,node4,node5分别执行:
    cd /home/myapps/hadoop/hadoop-2.7.5/sbin/
    ./hadoop-daemon.sh start journalnode
    验证:jps 查看结果,如果出现JournalNode,预示着初步成功
2、在其中一个namenode上执行格式化:
    cd /home/myapps/hadoop/hadoop-2.7.5/bin
    ./hdfs namenode -format
    将执行成功后生成的dir拷贝到另一个namenode上面:
    scp -r /home/myapps/hadoop/data root@node2:/home/myapps/hadoop/
    成功后执行node1执行    hdfs zkfc -formatZK

3、启动
    cd /home/myapps/hadoop/hadoop-2.7.5/sbin/
    ./start-all.sh
    jps 查看进程验证结果
    可以统计浏览器访问:      
        http://node1:50070
        NameNode 'node1:9000' (active)
        http://node2:50070
        NameNode 'node2:9000' (standby)

zookeeper启动脚本:

#!/bin/bash

# chkconfig: 2345 20 80
# description: zk 集群 启动停止

case $1 in
"start")
    cat /root/myapps/onekey/zk/slave | while read line
    do
    {
     echo $line
     ssh $line "source /etc/profile;nohup zkServer.sh start >/dev/null 2>&1 &"
    }&
   wait
    done 
;;
"stop")
    cat /root/myapps/onekey/zk/slave | while read line
    do
    {
     echo $line
     ssh $line "source /etc/profile;jps |grep QuorumPeerMain |cut -c 1-5 |xargs kill -s 9"
    }&
   wait
    done 

;;
"status")
jps
;;
*)
echo "用法:/etc/init.d/zkd {start|stop|status}"
;;
esac

hadoop启动脚本

#!/bin/bash

# chkconfig: 2345 20 80
# description: hadoop 集群 启动停止

case $1 in
"start")
/root/myapps/hadoop/hadoop-2.7.4/sbin/start-all.sh
;;
"stop")
/root/myapps/hadoop/hadoop-2.7.4/sbin/stop-all.sh
;;
"status")
jps
;;
*)
echo "用法:/etc/init.d/hadoopd {start|stop|status}"
;;
esac

另外有需要云服务器可以了解下创新互联scvps.cn,海内外云服务器15元起步,三天无理由+7*72小时售后在线,公司持有idc许可证,提供“云服务器、裸金属服务器、高防服务器、香港服务器、美国服务器、虚拟主机、免备案服务器”等云主机租用服务以及企业上云的综合解决方案,具有“安全稳定、简单易用、服务可用性高、性价比高”等特点与优势,专为企业上云打造定制,能够满足用户丰富、多元化的应用场景需求。


分享标题:hadoopha集群搭建(5台)-创新互联
路径分享:http://wjwzjz.com/article/phjhs.html
在线咨询
服务热线
服务热线:028-86922220
TOP