Reprinted from http://blog.csdn.net/yfkiss/article/details/7715476 and http://blog.csdn.net/yfkiss/article/details/7721329
Download Hadoop
Hadoop:
Http://www.apache.org/dyn/closer.cgi/hadoop/core/
The version downloaded here is 1.0.3
$ mkdir Hadoop
$ wget http://www.fayea.com/apache-mirror/hadoop/core/stable/hadoop-1.0.3.tar.gz.
Installing Java
First Use "java-version" to see if it is installed, and if the display is similar to Java version "1.7.0_147-icedtea means that it is installed
No installation can be consulted: http://blog.csdn.net/yang_hui1986527/article/details/6677450
Installation must be set Java_home and Classpath
My configuration:
Export Path=${path}:/usr/lib/jvm/java-6-openjdk-amd64/bin
Export java_home=/usr/lib/jvm/java-6-openjdk-amd64/
Export JRE_HOME=${JAVA_HOME}/JRE
Export Classpath=.:${jre_home}/lib:${java_home}/lib/dt.jar:${java_home}/lib/tools.jar
And put these two lines of statements in: ~/.BASHRC
Installing SSH
$ sudo apt-get install SSH
After the installation is complete, you need to confirm that you can log in to localhost with ssh password
$ ssh localhost
If you need a password to log in, you need to set:
$ ssh-keygen-t Dsa-p "-F ~/.SSH/ID_DSA
$ cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
Installing rsync
Rsync is the software for remote synchronization of Linux
$ sudo apt-get install rsync
Configure startup Hadoop
Extract:
$ TAR-ZXVF hadoop-1.0.3.tar.gz
Set Java_home
Edit conf/hadoop-env.sh file to find:
# Export Java_home=/usr/lib/j2sdk1.5-sun
Modified to:
Export java_home=/usr/lib/jvm/java-6-openjdk-amd64/
To modify a configuration file:
If you do not know where Java is, please use Whereis Java query
Modify Conf/core-site.xml:
[Plain]View Plaincopy
- <configuration>
- <property>
- <name>fs.default.name</name>
- <value>hdfs://localhost:9000</value>
- </property>
- </configuration>
Modify Conf/hdfs-site.xml:
[Plain]View Plaincopy
- <configuration>
- <property>
- <name>dfs.replication</name>
- <value>1</value>
- </property>
- <property>
- <name>hadoop.tmp.dir</name>
- <value>/home/work/hadoop_tmp</value>
- </property>
- </configuration>
Modify Conf/mapred-site.xml:
[Plain]View Plaincopy
- <configuration>
- <property>
- <name>mapred.job.tracker</name>
- <value>localhost:9001</value>
- </property>
- </configuration>
Initialize Hadoop Namenode:
$ bin/hadoop Namenode–format
Start:
$ bin/start-all.sh
Confirm Startup:
$ JPS
5146 Jps
4538 Tasktracker
4312 Jobtracker
4015 DataNode
4228 Secondarynamenode
3789 NameNode
Indicates a successful start
The following content is written to ~/.BASHRC:
[Plain]View Plaincopy
- Alias hadoop= '/home/zxm/hadoop/hadoop-1.0.3/bin/hadoop '
- Alias hls= ' Hadoop fs-ls '
- Alias hlsr= ' Hadoop FS-LSR '
- Alias hcp= ' Hadoop fs-cp '
- Alias hmv= ' Hadoop fs-mv '
- Alias hget= ' Hadoop fs-get '
- Alias hput= ' Hadoop fs-put '
- Alias hrm= ' Hadoop fs-rm '
- Alias hmkdir= ' Hadoop fs-mkdir '
- Alias hcat= ' Hadoop fs-cat '
- Alias hrmr= ' Hadoop fs-rmr '
- Alias hstat= ' Hadoop fs-stat '
- Alias htest= ' Hadoop fs-test '
- Alias htext= ' Hadoop fs-text '
- Alias htouchz= ' Hadoop fs-touchz '
- Alias hdu= ' Hadoop fs-du '
- Alias hdus= ' Hadoop fs-dus '
- Alias hchmod= ' Hadoop fs-chmod '
- Alias hchgrp= ' Hadoop fs-chgrp '
- Alias hchown= ' Hadoop fs-chown '
- Alias htail= ' Hadoop fs-tail ' <span style= "font-family:arial, Helvetica, Sans-serif;" ><span style= "White-space:normal;" >
- </span></span>
Solutions for common problems:
Issue 1: Running the HADOOP command appears "Warning: $HADOOP _home is deprecated." Alarm
FIX: Add export hadoop_home_warn_suppress=true to hadoop-env.sh
Problem 2:namenode cannot start
FIX: Delete/tmp/hadoop* execute Bin/hadoop namenode–format
After the Hadoop stand-alone environment has been successfully built, hive can be built.
To build a directory on HDFs:
[Plain]View Plaincopy
- $ Hadoop fs-mkdir/tmp
- $ Hadoop Fs-mkdir/user/hive/warehouse
Add Permissions:
[Plain]View Plaincopy
- $ Hadoop fs-chmod g+w/tmp
- $ Hadoop fs-chmod G+w/user/hive/warehouse
Download Extract hive:
$ wget http://labs.mop.com/apache-mirror/hive/stable/hive-0.8.1.tar.gz.
$ TAR-ZXVF hive-0.8.1.tar.gz
Set Hadoop_home, Hive_home, and add it to ~/.BASHRC
[Plain]View Plaincopy
- Export hadoop_home=/home/zxm/hadoop/hadoop-1.0.3
- Export hive_home=/home/work/hadoop/hive-0.8.1
Multi-user support
(Verify that MySQL is installed.)
Start MySQL:
$ mysql-u Root-p
Mysql>grant all on hive.* to [e-mail protected] identified by ' 123456 '
Modify the Hive Conf/hive-site.xml as follows:
[Plain]View Plaincopy
- <property>
- <name>javax.jdo.option.ConnectionURL</name>
- <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true<alue>
- <DESCRIPTION>JDBC connect string for a JDBC metastore</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionDriverName</name>
- <value>com.mysql.jdbc.Driver<alue>
- <description>driver class name for a JDBC metastore</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionUserName</name>
- <value>hive<alue>
- <description>username to use against Metastore database</description>
- </property>
- <property>
- <name>javax.jdo.option.ConnectionPassword</name>
- <value>123456<alue>
- <description>password to use against Metastore database</description>
- </property>
Download the MySQL JDBC package:
Wget http://downloads.mysql.com/archives/mysql-connector-java-5.0/mysql-connector-java-5.0.8.tar.gz.
Extract:
TAR-ZXVF mysql-connector-java-5.0.8.tar.gz
Copy the Mysql-connector-java-5.0.8-bin.jar to the hive Lib directory:
CP Mysql-connector-java-5.0.8/mysql-connector-java-5.0.8-bin.jar./lib
To start hive:
$ cd/home/zxm/hadoop/hive-0.8.1;./bin/hive
Test:
$./hive
WARNING:org.apache.hadoop.metrics.jvm.EventCounter is deprecated. Please use org.apache.hadoop.log.metrics.EventCounter the log4j.properties files.
Logging initialized using configuration in jar:file:/home/zxm/hadoop/hive-0.8.1/lib/hive-common-0.8.1.jar!/ Hive-log4j.properties
Hive History File=/tmp/work/hive_job_log_work_201207051945_218572007.txt
Hive> SHOW TABLES;
Ok
Time taken:7.281 seconds
Hive> CREATE TABLE pokes (foo INT, bar STRING);
Ok
Time taken:0.398 seconds
Hive> SHOW TABLES;
Ok
Pokes
Time taken:0.181 seconds
Hive> DESCRIBE pokes;
Ok
Foo INT
Bar string
Time taken:0.58 seconds
Hive>
Reproduced Hadoop and Hive stand-alone environment setup