Configure hadoop 2.6.0 pseudo-distributed in CentOS 6.5
Operating System: CentOS 6.5 32-bit
Java environment: jdk 1.7.0 _ 71
Hadoop: http://apache.fayea.com/hadoop/common/stable/hadoop-2.6.0.tar.gz
1. create user groups and users
Use the su command to switch the user to root.
[Html] view plaincopyprint?
- Groupaddhadoop
- Useraddhadoophadoop
- Passwdhadoop # You can add a password to a user without setting a password.
2. Install ssh
[Plain] view plaincopyprint?
- Rpm-qa | grepssh # Check whether an SSH package is installed
- Yuminstallopenssh-server # Install ssh
- Chkconfig -- listsshd # Check whether SSHD is set to start upon startup
- Chkconfig -- level2345sshdon # Set it if startup is not set.
- Servicesshdrestart # restart
3. Configure ssh login without a password
Switch to hadoop user
[Html] view plaincopyprint?
- Suhadoop
Generate key
[Html] view plaincopyprint?
- Ssh-keygen-trsa-P ""
The id_rsa and id_rsa.pub files are generated under the. ssh directory.
Enter the. ssh directory and append id_rsa.pub to the authorized_keys file.
[Html] view plaincopyprint?
- Cd./. ssh
- Catid_rsa.pub> authorized_keys
- Chmod600authorized_keys # modify user permissions
Test whether logon is allowed
[Html] view plaincopyprint?
- Sshlocalhost # After the command is executed, a prompt is displayed, indicating that yesorno. If yes is entered, the last logon time indicates that the command is successful.
4. Install hadoop
Decompress the downloaded hadoop file and move it to the desired installation directory to modify its access permissions.
[Html] view plaincopyprint?
- Tar-xvfhadoop-2.6.0.tar.gz
- Mvhadoop-2.6.0/usr/opt/hadoop
- Chmod-R775/usr/opt/hadoop
- Chown-Rhadoop: hadoop/usr/opt/hadoop
Configure hadoop environment variables (all environment variables are required)
[Html] view plaincopyprint?
- Su
- Vim/etc/profile
- ExportHADOOP_INSTALL =/usr/opt/hadoop
- ExportPATH =$ {HADOOP_INSTALL}/bin: $ {HADOOP_INSTALL}/sbin $ {PATH}
- ExportHADOOP_MAPRED_HOME =$ {HADOOP_INSTALL}
- ExportHADOOP_COMMON_HOME =$ {HADOOP_INSTALL}
- ExportHADOOP_HDFS_HOME =$ {HADOOP_INSTALL}
- ExportYARN_HOME =$ {HADOOP_INSTALLL}
- ExportHADOOP_COMMON_LIB_NATIVE_DIR =$ {HADOOP_INSTALL}/lib/natvie
- ExportHADOOP_OPTS = "-Djava. library. path =$ {HADOOP_INSTALL}/lib :$ {HADOOP_INSTALL}/lib/native"
Set java environment variables in hadoop-env.sh
[Html] view plaincopyprint?
- Cd/usr/opt/hadoop
- Vim ../etc/hadoop/hadoop-env.sh
[Html] view plaincopyprint?
- ExportJAVA_HOME = {your java environment variable}
5. Configure pseudo-distributed
Hadoop configuration files mainly include core-site.xml, hdfs-site.xml, yarn-site.xml three files.
[Html] view plaincopyprint?
- Cd/usr/opt/hadoop/etc/hadoop
Core-site.xml
[Html] view plaincopyprint?
- <Configuration>
- <Property>
- <Name> hadoop. tmp. dir </name>
- <Value>/usr/opt/hadoop/tmp </value> <! -- Make sure to configure the default cache folder of the system. It will be deleted after each restart. -->
- </Property>
- <Property>
- <Name> fs. defaultFS </name>
- <Value> hdfs :/// localhost: 9000 </value>
- </Property>
- </Configuration>
Hdfs. xml
[Html] view plaincopyprint?
- <Configuration>
- <Property>
- <Name> dfs. replication </name>
- <Value> 1 </value>
- </Property>
- <Property>
- <Name> dfs. namenode. name. dir </name>
- <Value> file:/usr/opt/hadoop/dfs/name </value>
- </Property>
- <Property>
- <Name> dfs. datanode. data. dir </name>
- <Value> file:/usr/opt/hadoop/dfs/data </value>
- </Property>
- <Property> <! -- This attribute node is used to prevent the following eclipse from rejecting read/write settings -->
- <Name> dfs. permissions </name>
- <Value> false </value>
- </Property>
- </Configuration>
Yarn-site.xml
[Html] view plaincopyprint?
- <Configuration>
- <Property>
- <Name> mapreduce. framework. name </name>
- <Value> yarn </value>
- </Property>
- <Property>
- <Name> yarn. nodemanager. aux-services </name>
- <Value> mapreduce_shuffle </value>
- </Property>
- </Configuration>
Next, create the required folder.
[Html] view plaincopyprint?
- Cd/usr/local/hadoop
- Mkdirtmpdfsdfs/namedfs/data
All configurations have been completed so far.
6. Run
First, format the file system.
[Html] view plaincopyprint?
- . Bin/hdfsnamenode-format
Start
[Html] view plaincopyprint?
- ../Sbin/start-dfs.sh
- ../Sbin/start-yarn.sh
If the following prompt is displayed, the operation is successful.
[Html] view plaincopyprint?
- Startingnamenodeson [localhost]
- Localhost: startingnamenode, loggingto/usr/opt/hadoop-2.6.0/logs/hadoop-namenode-. out
- Localhost: startingdatanode, loggingto/usr/opt/hadoop-2.6.0/logs/hadoop-datanode-. out
- Startingsecondarynamenodes [0.0.0.0]
- 0.0.0.0: startingsecondarynamenode, loggingto/usr/opt/hadoop-2.6.0/logs/hadoop-secondarynamenode-. out
Enter 127.0.0.1: 50070 to view the hadoop webpage.
PS: If a warning is displayed:
[Html] view plaincopyprint?
- Unabletoloadnative-hadooplibraryforyourplatform
You can also see the webpage, but hadoop is not fully installed.
There are two problems:
1. The environment variable HADOOP_OPTS is not set.
2. This is caused by incompatibility between the operating system and hadoop. so files.
Hadoop 2.5 and later versions of release are 64-bit compiled. If your computer is 32-bit, incompatibility may occur. At this time, you need to re-compile the hadoop source code (when compiling the hadoop source code, do not use jdk1.8.0, use 1.6 and 1.7. Otherwise, this ERROR [ERROR] Failed to execute goal org. apache. maven. plugins: maven-javadoc-plugin: 2.8.1: jar (module-javadocs) on project hadoop-annotations: MavenReportException: Error while creating archive ):