hadoop伪分的搭建
配置免密
配置映射,并在最后一行添加“ip地址+主机名(或者是localhost)”
vim /etc/hosts
生成密钥
ssh-keygen
ssh-copy-id 主机名(localhost)
安装jdk,hadoop
注意:/apps是文件的解目录,/data是文件的下载目录
将下好的jdk,hadoop解压至/apps
tar -zxf jdk的包 -C /apps
tar -zxf hadoop的包 -C /apps
切换至/apps下,并给文件重命名(方便后续的操作)
cd /apps
mv jdk的包 java
mv hadoop的包 hadoop
添加环境变量
vim /etc/profile(也可以是vim ~/.bashrc)
添加以下内容
#java
export JAVA_HOME=/apps/java #java的安装目录
export PATH=$PATH:$JAVA_HOME/bin
#hadoop
export HADOOP_HOME=/apps/hadoop #hadoopp安装目录
export PATH=$PATH:$HADOOP_HOME/bin
刷新环境变量
source /etc/profile
验证
java -version
hadoop version
对hadoop进行配置
创建文件夹
mkdir -p /data/tmp/hadoop/tmp
mkdir -p /data/tmp/hadoop/hdfs
切换目录,配置文件
cd /apps/hadoop/etc/hadoop
进入vim hadoop-env.sh修改以下内容
export JAVA_HOME=/apps/java
进入vim core-site.xml添加以下内容,在
<configuratuion>
<property>
<name>hadoop.tmp.dir</name>
<value>/data/tmp/hadoop/tmp</value>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
进入vim hdfs-site.xml添加以下内容,在
<configuratuion>
<property>
<name>dfs.namenode.name.dir</name>
<value>/data/tmp/hadoop/hdfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>/data/tmp/hadoop/hdfs/data</value>
</property>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.permissions.enabled</name>
<value>false</value>
</property>
</configuration>
进入vim yarn-site.xml添加以下内容,在
<configuratuion>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
先重命名
mv mapred-site.xml.tm mapred-site.xml
进入vim mapred-site.xml添加以下内容
<configuratuion>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
</configuration>
格式化
hadoop namenode -format
启动
cd /apps/hadoop/sbin
./start-all.sh
査看6个进程是成
jps
Zookeeper
zookeeper单个安装
解压
tar -zxf zookeeper-3.4.8.tar.gz -C /usr/local/src
改名
cd /usr/local/src
mv zookeeper-3.4.8/ zookeeper
修改配置文件vim ~/.bashrc
export ZOOKEEPER_HOME=/usr/local/src/zookeeper
export PATH=$PATH:$ZOOKEEPER_HOME/bin
刷新环境变量
source ~/.bashrc
进入到zookeeper的conf目录下:
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
修改:
启动:
cd ../bin
./zkServer.sh start
验证:
./zkServer.sh status
zookeeper集群安装(三台)
解压
tar -zxf zookeeper-3.4.8.tar.gz -C /usr/local/src
改名
cd /usr/local/src
mv zookeeper-3.4.8/ zookeeper1
修改配置文件:
cd zookeeper1/conf
mv zoo_sample.cfg zoo.cfg
vim zoo.cfg
cd ..
mkdir tmp
复制文件:
cp -r zookeeper1/ zookeeper2
cp -r zookeeper1/ zookeeper3
添加myid
vim /usr/local/src/zookeeper1/tmp/myid
vim /usr/local/src/zookeeper2/tmp/myid
vim /usr/local/src/zookeeper3/tmp/myid
修改zookeeper2,zookeeper3的配置文件
vim /usr/local/src/zookeeper2/conf/zoo.cfg
vim /usr/local/src/zookeeper3/conf/zoo.cfg
zookeeper启动
/usr/local/src/zookeeper1/bin/zkServer.sh start
/usr/local/src/zookeeper2/bin/zkServer.sh start
/usr/local/src/zookeeper3/bin/zkServer.sh start
SQOOP
解压,改名
cd /h3cu/
tar -zxf sqoop-1.4.7.bin__hadoop-2.6.0.tar.gz -C /usr/local/src
cd /usr/local/src
mv sqoop-1.4.7.bin__hadoop-2.6.0/ sqoop
配置环境变量vim ~/.bashrc
export SQOOP_HOME=/usr/local/src/sqoop
export PATH=$PATH:$SQOOP_HOME/bin
刷新环境变量
source ~/.bashrc
将驱动复制到sqoop的lib下
cp mysql-connector-java-5.1.45-bin.jar /usr/local/src/sqoop/lib
修改sqoop下的conf:
mv sqoop-env-template.sh sqoop-env.sh
vim sqoop-env.sh
验证:
cd ../bin
sqoop list-databases --connect jdbc:mysql://localhost:3306/ --username root --password 123456