linux环境 ubun16 或者CentOS6.5
1:jdk配置
//jdk包解压并复制到指定路径
tar -zxf ~/Downloads/jdk-8u121-linux-x64.tar.gz -C /usr/local/hadoop
//在/etc/profile配置环境变量
export JAVA_HOME=/usr/local/hadoop/jdk1.8.0_121
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
2:hadoop
//同上将hadoop包解压到指定路径
tar -zxf ~/Downloads/hadoop-2.6.0.tar.gz -C /usr/local/hadoop
//伪分布式配置需要配置两个文件
core-site.xml 和 hdfs-site.xml
/etc/hadoop/core-site.xml
gedit编辑 加入如下内容
<configuration> <property> <name>hadoop.tmp.dir</name> <value>file:/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>
/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/tmp/dfs/name</value>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/usr/local/hadoop/tmp/dfs/data</value>
</property>
</configuration>
export HADOOP_HOME=/usr/local/hadoop export HADOOP_INSTALL=$HADOOP_HOME export HADOOP_MAPRED_HOME=$HADOOP_HOME export HADOOP_COMMON_HOME=$HADOOP_HOME export HADOOP_HDFS_HOME=$HADOOP_HOME export YARN_HOME=$HADOOP_HOME export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native export PATH=$PATH:$HADOOP_HOME/sbin:$HADOOP_HOME/bin //在hadoop相关目录下执行start-all.sh,也可以在/etc/profile中配置hadoop路径,使得hadoop命令全局可用
配置完成后需要
- ./bin/hdfs namenode -format 格式化一下
3:hbase配置
1:同上解压并复制到相关目录
tar -zxf ~/Downloads/hbase-1.0.1.1-bin.tar.gz -C /usr/local/hadoop
2:修改配置文件
export HBASE_HOME=/home/hadoop/hbase-1.0.1.1 export PATH=$PATH:$HBASE_HOME/bin
export JAVA_HOME=/usr/local/hadoop/jdk1.8.0_121 export HBASE_MANAGES_ZK=true//此配置信息,设置由hbase自己管理zookeeper,不需要单独的zookeeper。
<configuration> <property> <name>hbase.rootdir</name> <value>file:///home/testuser/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/home/testuser/zookeeper</value> </property> </configuration>
(伪分布模式)
<configuration> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> <property> <name>hbase.rootdir</name> <value>hdfs://localhost:9000/hbase</value> </property> <property> <name>hbase.zookeeper.property.dataDir</name> <value>/home/hadoop/appdata/zookeeper</value> </property> </configuration>
//hbase启动
start-hbase.sh
使用 hbase shell 命令进入hbase(hbase是非关系型数据库,查询使用get 和scan相关过滤器)
4:hive配置
//解压文件到指定目录
tar -zxf ~/Downloads/apache-hive-1.2.1-bin.tar.gz -C /usr/local/hadoop
//配置环境变量
export HIVE_HOME=/usr/local/hadoop/hive
export PATH=$PATH:$HIVE_HOME/bin
//修改配置文件
hive-site.xml(将hive-default.xml.template重命名为hive-default.xml,或者说新建一个hive-site.xml文件,它的内容如下)
<?xml version="1.0" encoding="UTF-8" standalone="no"?> <?xml-stylesheet type="text/xsl" href="configuration.xsl"?> <configuration> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value> <description>JDBC connect string for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> <description>Driver class name for a JDBC metastore</description> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hive</value> <description>username to use against metastore database</description> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hive</value> <description>password to use against metastore database</description> </property> </configuration>
关于环境变量配置,/etc/profile和~/.bashrc 文件代表不同的指向,前者代表更广,后者更加倾向于单个用户,但是linux启动时系统首先启动的是/etc/profile 因此在配置是需要格外注意,不然会遭成系统无法启动等原因。