開始進行雲計算部分的學習,爲了存檔,寫下如今進行過的步驟java
須要用到的主要版本:node
虛擬機:Vmware Workstation pro 12.5linux
Linux系統:CentOS6.4 64bitweb
jdk版本:jdk1.8.0_111編程
hadoop版本:hadoop-2.5.2vim
全部的包都可以在官網下載centos
在這次搭建環境中,主要是搭建了一個主節點,兩個從節點,hostname分別是master,slave1,slave2bash
地址設置爲靜態ip.圖形化處理只須要改變右上角網絡,網絡
192.168.66.111 masterapp
192.168.66.112 slave1
192.168.66.113 slave2
1、Vmware Workstation+Centos6.5的安裝
1.官網選擇,安裝版本12.5,輸入序列號。
2.安裝好虛擬機後,安裝centos6.5版本的Linux系統。進行相關的環境設置。主要設置以下:
①須要將網絡鏈接NAT,改爲host-only模式,右鍵centos系統,進行編輯。
②將網絡設置成靜態IP,以便後來進行相關的編程。
③設置DNS解析:
使用 vim /etc/sysconfig/network 命令,進行相關更改。 將HOSTNAME的變量給成master
設置節點映射,vim /etc/hosts.在文本的最後一行追加內容:192.168.66.111 master
驗證配置,執行ping master,若是可以ping經過。則表示,這個配置正確。(須要保證網絡連通)
同理,須要在其餘節點設置相同。
這一步能夠顛倒順序,先配置單機,再配置集羣。或者先配置集羣在配置單機。只須要注意克隆的順序便可。可是均須要在hosts文件中,添加節點IP
④關閉防火牆
命令setup ,選擇firewall configuration,回車,以後進入設置按鍵,將*中按空格,取消。而後保存退出。
命令service iptables status 驗證防火牆是否關閉,若是提示not running則表示已經關閉。——這一步須要在root權限下進行,不然會沒有提示
⑤設置SSH自動登陸
驗證是否安裝了SSH。命令 rpm -qa |grep ssh 若沒有安裝,則命令 yum install openssh-server
配置SSH免密登陸(在這個過程花費了不少時間,在這裏寫出來):
ssh-keygen -t rsa 如有提示信息,直接進行回車,最後生成.ssh文件, 進入密鑰目錄,~/.ssh,命令:cp id_rsa.pub anthorized_keys 這個命令會生成受權文件:authorized_keys,而後使用 ls 命令,進行查看。
同時,命令 vi /etc/ssh/sshd_config 刪除下列文字:
命令 service sshd restart 對其進行從新啓動,以上的命令須要分別在三個機器中都實現
而後輸入命令: cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh slave1 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
ssh slave2 cat ~/.ssh/id_rsa.pub >>~/.ssh/authorized_keys
咱們須要在ssh目錄中查看是否已經配置完成,每一個主機上面的公鑰和密鑰都存放在一個文件夾中,這個很重要,會致使後面的配置是否須要密碼。(注:全部的操做均在root權限下進行,也能夠新建一個hadoop用戶)
cd ~/.ssh
cat authorized_keys
scp authorized_keys root@slave1:/root/.ssh/
scp known_hosts root@slave1:/root/.ssh/
scp known_hosts root@slave2:/root/.ssh/
scp authorized_keys root@slave2:/root/.ssh/
須要將全部的文件拷貝到每一個須要配置的節點主機上。
驗證SSH無密碼登陸:
執行命令 ssh slave1 後面不須要確認,若登陸了,須要用命令:exit 進行退出。 再次使用命令ssh slave1以後能夠看到登陸信息。
2、JDK的安裝
安裝jdk文件。
主要須要注意權限問題,以及目錄問題。
主要命令是
1.改變文件的位置:mv,
2.用命令chmod 777 jdk-8u111-linux-x64.rpm修改文件權限,雙擊它就自動解壓安裝了,安裝完成後,在/usr目錄下產生一個新的 java 文件夾
3.設置環境變量
vi打開文件命令:vi /etc/profile
移至文件末尾插入一個空行:輸入字母o
輸入如下配置信息:(注:這裏的分隔符是冒號不是分號)
JAVA_HOME=/usr/java/jdk1.8.0_111
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_HOME
export PATH
export CLASSPATH
先按Esc退出編輯模式,再保存退出輸入 :wq ! (冒號也要輸入)
至此,新的JDK環境設置完畢。
4.卸載原JDK
終端輸入,查看gcj的版本號:rpm -qa|grep jdk
獲得結果:
jdk-1.7.0_04-fcs.x86_64
java-1.6.0-openjdk-1.6.0.0-1.49.1.11.4.el6_3.x86_64
終端輸入,卸載:yum -y remove java java-1.6.0-openjdk-1.6.0.0-1.49.1.11.4.el6_3.x86_64
等待系統自動卸載,最終終端顯示 Complete,卸載完成
5.讓系統配置當即生效,不用重啓系統
終端輸入命令:source /etc/profile
6.驗證是否安裝無缺
輸入命令java -version
注意:若是出現如下錯誤信息
3、安裝Hadoop
1.安裝版本2.5.2版本,必定要下載rpm結尾的版本,進行相關的配置,也許其餘也能夠,可是沒有找到配置文件
2.解壓文件。命令:tar -xzvf 文件名
3.設置文件環境變量。 命令 vim /etc/profile 在文件的最後一行,命令 O 換行插入,增長如下內容:
export HADOOP_HOME=/usr/program/hadoop-2.5.2
export HADOOP_COMMON_HOME=$HADOOP_HOME
export HADOOP_HDFS_HOME=$HADOOP_HOME
export HADOOP_MAPRED_HOME=$HADOOP_HOME
export HADOOP_YARN_HOME=$HADOOP_HOME
export HADOOP_CONF_DIR=$HADOOP_HOME/etc/hadoop
export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HADOOP_HOME/lib
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib"
執行命令 source /etc/profile
4.驗證Hadoop是否安裝無缺。
命令 hadoop version 若出現以下語句,則說明安裝成功。
5.進行修改Hadoop的配置文件————有一點須要注意,Hadoop2.5.2與Hadoop1.0其餘的版本不一樣地方在於,2.5的配置文件都在etc/hadoop文件中,而1.0版本的Hadoop的配置文件是在conf中。同時,後面須要改進的的mapred-site.xml.template文件,就是原來的mapred-site.xml文件。其餘的地方就是後面的包的位置不一樣,之後用到的時候再說。
①.修改hadoop-env.sh及yarn-env.sh中的JAVA_HOME,與環境變量中的路徑相同便可
②. cd /usr/program/hadoop-2.5.2/etc/hadoop
進入配置路徑,進行文件的配置 文件的打開方式 均用vi ,cat查看。並且首先須要在hadoop-2.5.2文件下建立一個目錄,tmp,hdfs/data,hdfs/name,用來存儲臨時文件數據,和計算路徑
core-site.xml
<configuration> <property> <name>fs.defaultFS</name> <value>hdfs://master:9000</value> <description>The name of the default file system. A URI whose scheme and authority determine the FileSystem implementation. The uri's scheme determines the config property (fs.SCHEME.impl) naming the FileSystem implementation class. The uri's authority is used to determine the host, port, etc. for a filesystem.</description> </property> <property> <name>hadoop.tmp.dir</name> <value>/usr/program/hadoop-2.5.2/tmp</value> <description>A base for other temporary directories.</description> </property> <!-- i/o properties --> <property> <name>io.file.buffer.size</name> <value>131072</value> <description>The size of buffer for use in sequence files. The size of this buffer should probably be a multiple of hardware page size (4096 on Intel x86), and it determines how much data is buffered during read and write operations.</description> </property> </configuration>
hdfs-site.xml
<configuration> <property> <name>dfs.namenode.name.dir</name> <value>/usr/program/hadoop-2.5.2/hdfs/name</value> <description>Determines where on the local filesystem the DFS name node should store the name table(fsimage). If this is a comma-delimited list of directories then the name table is replicated in all of the directories, for redundancy. </description> </property> <property> <name>dfs.datanode.data.dir</name> <value>/usr/program/hadoop-2.5.2/hdfs/data</value> <description>Determines where on the local filesystem an DFS data node should store its blocks. If this is a comma-delimited list of directories, then data will be stored in all named directories, typically on different devices. Directories that do not exist are ignored. </description> </property> <property> <name>dfs.replication</name> <value>2</value> <description>Default block replication. The actual number of replications can be specified when the file is created. The default is used if replication is not specified in create time. </description> </property> <property> <name>dfs.blocksize</name> <value>134217728</value> <description> The default block size for new files, in bytes. You can use the following suffix (case insensitive): k(kilo), m(mega), g(giga), t(tera), p(peta), e(exa) to specify the size (such as 128k, 512m, 1g, etc.), Or provide complete size in bytes (such as 134217728 for 128 MB). </description> </property> <property> <name>dfs.namenode.handler.count</name> <value>10</value> <description>The number of server threads for the namenode.</description> </property> </configuration>
mapred-site.xml.template
<configuration> <property> <name>mapreduce.framework.name</name> <value>yarn</value> <description>The runtime framework for executing MapReduce jobs. Can be one of local, classic or yarn. </description> </property> <!-- jobhistory properties --> <property> <name>mapreduce.jobhistory.address</name> <value>master:10020</value> <description>MapReduce JobHistory Server IPC host:port</description> </property> <property> <name>mapreduce.jobhistory.webapp.address</name> <value>master:19888</value> <description>MapReduce JobHistory Server Web UI host:port</description> </property> </configuration>
yarn-site.xml
configuration> <!-- Site specific YARN configuration properties --> <property> <description>The hostname of the RM.</description> <name>yarn.resourcemanager.hostname</name> <value>master</value> </property> <property> <name>yarn.resourcemanager.address</name> <value>${yarn.resourcemanager.hostname}:8032</value> <description>The address of the applications manager interface in the RM.</description> </property> <property> <description>The address of the scheduler interface.</description> <name>yarn.resourcemanager.scheduler.address</name> <value>${yarn.resourcemanager.hostname}:8030</value> </property> <property> <name>yarn.resourcemanager.resource-tracker.address</name> <value>${yarn.resourcemanager.hostname}:8031</value> </property> <property> <description>The address of the RM admin interface.</description> <name>yarn.resourcemanager.admin.address</name> <value>${yarn.resourcemanager.hostname}:8033</value> </property> <property> <description>The http address of the RM web application.</description> <name>yarn.resourcemanager.webapp.address</name> <value>${yarn.resourcemanager.hostname}:8088</value> </property> <property> <description>The minimum allocation for every container request at the RM, in MBs. Memory requests lower than this won't take effect, and the specified value will get allocated at minimum. default is 1024 </description> <name>yarn.scheduler.minimum-allocation-mb</name> <value>512</value> </property> <property> <description>The maximum allocation for every container request at the RM, in MBs. Memory requests higher than this won't take effect, and will get capped to this value. default value is 8192</description> <name>yarn.scheduler.maximum-allocation-mb</name> <value>2048</value> </property> <property> <description>Amount of physical memory, in MB, that can be allocated for containers.default value is 8192</description> <name>yarn.nodemanager.resource.memory-mb</name> <value>2048</value> </property> <property> <description>Whether to enable log aggregation. Log aggregation collects each container's logs and moves these logs onto a file-system, for e.g. HDFS, after the application completes. Users can configure the "yarn.nodemanager.remote-app-log-dir" and "yarn.nodemanager.remote-app-log-dir-suffix" properties to determine where these logs are moved to. Users can access the logs via the Application Timeline Server. </description> <name>yarn.log-aggregation-enable</name> <value>true</value> </property> </configuration>
vi slaves 編輯從節點,能夠將主節點也做爲從節點進行編輯。
輸入:master,slave1,slave2
在保存完全部的設置後,咱們須要一樣配置其餘從節點。能夠硬複製,也能夠將文件進行拷貝,從master到slave1,slave2
輸入命令:scp -r /usr/program/hadoop-2.5.2/etc/hadoop/ root@slave1:~/hadoop/hadoop-2.5.2/etc/
scp -r /usr/program/hadoop-2.5.2/etc/hadoop/ root@slave2:~/hadoop/hadoop-2.5.2/etc/
scp -r /etc/profile root@slave1:/etc/profile
scp -r /etc/profile root@slave2:/etc/profile
完成狀況以下所示:
全部的狀況都已經配置完畢
如今首先須要對Hadoop進行系列的格式化:
hadoop namenode -format 格式化namenode,
start-dfs.sh
start-yarn.sh
成功搭建單機模式
Daemon | Web Interface | Notes |
---|---|---|
NameNode | http://nn_host:port/ | Default HTTP port is 50070. |
ResourceManager | http://rm_host:port/ | Default HTTP port is 8088. |
MapReduce JobHistory Server | http://jhs_host:port/ | Default HTTP port is 19888. |
這樣基本搭建已經完成,造成節點之間的鏈接。接下來開始配置hadoop和eclipse之間的聯繫,同時會解決遇到的困難。進行相關的配置問題