@rg070836rg
2017-11-14T14:08:24.000000Z
字数 5483
阅读 1374
南师大大创中期读书笔记
sudo addgroup hadoop
sudo adduser -ingroup hadoop hadoop
sudo gedit /etc/sudoers
在文件内上述修改以下代码并保存
# User privilege specification
root ALL=(ALL:ALL) ALL
hadoop ALL=(ALL:ALL) ALL
cd usr/lib
sudo mkdir jvm
假设安装文件在下载目录
回到主目录
cd 下载
执行下述代码(注意修改对应版本号)
sudo tar zxvf ./jdk-8u45-linux-x64.tar.gz -C ../../../usr/lib/jvm
进入到该目录下,并进行移动操作
cd usr/lib/jvm
sudo mv jdk1.8.0_45/ java-8u45-sun
//注意版本号
注意!!:这种方式是为当前用户配置的所以,切换到hadoop之后,还需要在配置一遍
使用vim ~/.bashrc命令编辑
在底部加入命令
#######java-8u45-sun
export JAVA_HOME=/usr/lib/jvm/java-8u45-sun
export JRE_HOME=${JAVA_HOME}/jre
export CLASSPATH=.:${JAVA_HOME}/lib:${JRE_HOME}/lib
source ~/.bashrc
//更新文件
使用java -version检查是否成功
sudo gedit /etc/hostname
编辑名字即可(随意,只是为了方便区分)
sudo apt-get install openssh-server
sudo rm /var/lib/dpkg/lock
sudo rm /var/cache/apt/archives/lock
ssh-keygen -t rsa -C "751440280@qq.com"
//邮箱输入自己的,仅作为标识
/home/hadoop/.ssh/id_rsa
成功后如下:
The key fingerprint is:
2f:bb:13:23:66:09:34:29:be:57:db:93:69:f0:71:2a 751440280@qq.com
The key's randomart image is:
cd /home/hadoop/.ssh/
//默认文件夹
cat id_rsa.pub >> authorized_keys
ssh localhost
//输入yes 测试能否登陆。
sudo cp hadoop-2.5.2.tar.gz /usr/local/
sudo tar -zxf hadoop-2.5.2.tar.gz
sudo mv hadoop-2.5.2 hadoop
sudo chmod -R 775 /usr/local/hadoop
sudo chown -R hadoop:hadoop /usr/local/hadoop
sudo gedit ~/.bashrc
在最后增加
#HADOOP VARIABLES START
export JAVA_HOME=/usr/lib/jvm/????
#(看jdk配置//上一行需要保留并设置成本机的路径)
export HADOOP_INSTALL=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_INSTALL/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_INSTALL/lib"
#HADOOP VARIABLES END
然后更新生效
source ~/.bashrc
sudo gedit /usr/local/hadoop/etc/hadoop/hadoop-env.sh
找到JAVA_HOME改为上面的值,如下
#export JAVA_HOME=${JAVA_HOME}
export JAVA_HOME=/usr/lib/jvm/java-8u45-sun
sudo gedit /usr/local/hadoop/etc/hadoop/core-site.xml
<configuration>
<property>
<name>hadoop.tmp.dir</name>
<value>/usr/local/hadoop/tmp</value>
<description>Abase for other temporary directories.</description>
</property>
<property>
<name>fs.defaultFS</name>
<value>hdfs://localhost:9000</value>
</property>
</configuration>
sudo gedit /usr/local/hadoop/etc/hadoop/mapred-site.xml //此项不必要
<configuration>
<property>
<name>mapred.job.tracker</name>
<value>localhost:9001</value>
</property>
</configuration>
sudo gedit /usr/local/hadoop/etc/hadoop/yarn-site.xml
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce_shuffle</value>
</property>
</configuration>
sudo gedit /usr/local/hadoop/etc/hadoop/hdfs-site.xml
<configuration>
<property>
<name>dfs.replication</name>
<value>1</value>
</property>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/usr/local/hadoop/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop/dfs/data</value>
</property>
<property>
<name>dfs.permissions</name>
<value>false</value>
</property>
</configuration>
sudo gedit /usr/local/hadoop/etc/hadoop/masters
sudo gedit /usr/local/hadoop/etc/hadoop/slaves
添加:localhost
cd /usr/local/hadoop
mkdir tmp dfs dfs/name dfs/data
cd /usr/local/hadoop/
bin/hdfs namenode -format
sbin/start-dfs.sh
sbin/start-yarn.sh
Namenode information:
http://localhost:50070
来查看Hadoop的信息。
All Applications:
http://localhost:8088/,
cd /opt/ && sudo tar -zxvf ~/下载/eclipse(根据下载的版本号填写)
gksudo gedit /usr/share/applications/eclipse.desktop
录入下述内容
[Desktop Entry]
Name=Eclipse 4
Type=Application
Exec=/opt/eclipse/eclipse
Terminal=false
Icon=/opt/eclipse/icon.xpm
Comment=Integrated Development Environment
NoDisplay=false
Categories=Development;IDE;
Name[en]=Eclipse
cd /opt/eclipse
ln -sf /usr/lib/jvm/java-8u45-sun/jre
用搜索栏搜索到eclipse,打开即可,可以选择拖拽到左侧快速启动栏
版本号无所谓,把这个文件拷贝到opt/eclipse/plugins中,这里介绍
sudo nautilus
这个命令会给你一个最高权限的资源管理器,可以进行复制
拷贝完之后,打开eclipse
在Window->Preferences->Hadoop Map/Reduce中添加Hadoop的安装目录
在Window-->Show View->other,
在MapReduce Tools中选择Map/Reduce Locations
配置如下:
Scala 官网地址为 http://www.scala-lang.org/。
tar -xzvf scala-2.11.7.tgz
sudo gedit ~/.bashrc
#scala envir
export SCALA_HOME=/xxxxxxxx //写上你的目录比如/opt/scala-2.11.7
export PATH=${SCALA_HOME}/bin:$PATH
source ~/.bashrc
不能使用apt-get install scala 这样安装是基于openjdk,问题很多.
进入官网下载对应 Hadoop 版本的 Spark 程序包
官网地址为 http://spark.apache.org/downloads.html。
这边下载最新版本1.41,2015年08月15日
tar -xzvf spark-1.4.1-bin-hadoop2.6.tgz
//为了方便,移动后改名为spark
sudo gedit ~/.bashrc
#spark
export SPARK_HOME=$HOME/opt/spark
export PATH=$PATH:$SPARK_HOME/bin
source ~/.bashrc
加上 export JAVA_HOME=/usr/lib/jvm/java-8u45-sun