Impala安装完整版
Cloudera Impala对你存储在Apache Hadoop在HDFS,HBase的数据提供直接查询互动的SQL。除了像Hive使用相同的统一存储平台,Impala也使用相同的元数据,SQL语法(Hive SQL),ODBC驱动程序和用户界面(Hue Beeswax)。Impala还提供了一个熟悉的面向批量或实时查询和统一平台。
l Red Hat Enterprise Linux (RHEL)/CentOS 6.2 (64-bit)
l CDH 4.1.0 or later
l Hive
l MySQL
注意:Impala不支持在Debian/Ubuntu, SuSE, RHEL/CentOS 5.7系统中安装。
在Join查询过程中需要将数据集加载内存中进行计算,因此对安装Impalad的内存要求较高。
>more/etc/issue
CentOSrelease 6.2 (Final)
Kernel \ron an \m
10.28.169.112mr5
10.28.169.113mr6
10.28.169.114mr7
10.28.169.115mr8
各机器安装角色
mr5:NameNode、ResourceManager、SecondaryNameNode、Hive、impala-state-store
mr6、mr7、mr8:DataNode、NodeManager、impalad
在各个机器上新建用户hadoop,并打通ssh
到cloudera官网下载:
Hadoop:
hadoop-2.0.0-cdh4.1.2.tar.gz
hive:
hive-0.9.0-cdh4.1.2.tar.gz
impala:
impala-0.3-1.p0.366.el6.x86_64.rpm
impala-debuginfo-0.3-1.p0.366.el6.x86_64.rpm
impala-server-0.3-1.p0.366.el6.x86_64.rpm
impala-shell-0.3-1.p0.366.el6.x86_64.rpm
impala依赖包下载:
bigtop-utils-0.4(http://beta.cloudera.com/impala/redhat/6/x86_64/impala/0/RPMS/noarch/)
其他依赖包下载地址:http://mirror.bit.edu.cn/centos/6.3/os/x86_64/Packages/
hadoop用户登录到mr5机器,将hadoop-2.0.0-cdh4.1.2.tar.gz上传到/home/hadoop/目录下并解压:
tar zxvf hadoop-2.0.0-cdh4.1.2.tar.gz
修改mr5机器hadoop用户主目录/home/hadoop/下的.bash_profile环境变量:
exportJAVA_HOME=/usr/jdk1.6.0_30
exportJAVA_BIN=${JAVA_HOME}/bin
exportCLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export JAVA_OPTS="-Djava.library.path=/usr/local/lib-server -Xms1024m -Xmx2048m -XX:MaxPermSize=256m -Djava.awt.headless=true-Dsun.net.client.defaultReadTimeout=600
00-Djmagick.systemclassloader=no -Dnetworkaddress.cache.ttl=300-Dsun.net.inetaddr.ttl=300"
exportHADOOP_HOME=/home/hadoop/hadoop-2.0.0-cdh4.1.2
exportHADOOP_PREFIX=$HADOOP_HOME
exportHADOOP_MAPRED_HOME=${HADOOP_HOME}
exportHADOOP_COMMON_HOME=${HADOOP_HOME}
exportHADOOP_HDFS_HOME=${HADOOP_HOME}
exportHADOOP_YARN_HOME=${HADOOP_HOME}
export PATH=$PATH:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin
exportJAVA_HOME JAVA_BIN PATH CLASSPATH JAVA_OPTS
exportHADOOP_LIB=${HADOOP_HOME}/lib
exportHADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
在机器mr5上hadoop用户登录修改hadoop的配置文件(配置文件目录:hadoop-2.0.0-cdh4.1.2/etc/hadoop)
(1)、slaves :
添加以下节点
mr6
mr7
mr8
(2)、hadoop-env.sh :
增加以下环境变量
exportJAVA_HOME=/usr/jdk1.6.0_30
exportHADOOP_HOME=/home/hadoop/hadoop-2.0.0-cdh4.1.2
exportHADOOP_PREFIX=${HADOOP_HOME}
export HADOOP_MAPRED_HOME=${HADOOP_HOME}
exportHADOOP_COMMON_HOME=${HADOOP_HOME}
exportHADOOP_HDFS_HOME=${HADOOP_HOME}
exportHADOOP_YARN_HOME=${HADOOP_HOME}
exportPATH=$PATH:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin
exportJAVA_HOME JAVA_BIN PATH CLASSPATH JAVA_OPTS
exportHADOOP_LIB=${HADOOP_HOME}/lib
exportHADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
(3)、core-site.xml :
<configuration>
<property>
<name>fs.default.name</name>
<value>hdfs://mr5:9000</value>
<description>The name of the defaultfile system.Either the literal string "local" or a host:port forNDFS.</description>
<final>true</final>
</property>
<property>
<name>io.native.lib.available</name>
<value>true</value>
</property>
<property>
<name>hadoop.tmp.dir</name>
<value>/home/hadoop/tmp</value>
<description>A base for other temporarydirectories.</description>
</property>
</configuration>
(4)、hdfs-site.xml :
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>file:/home/hadoop/dfsdata/name</value>
<description>Determines where on thelocal filesystem the DFS name node should store the name table.If this is acomma-delimited list of directories,then name table is replicated in all of thedirectories,for redundancy.</description>
<final>true</final>
</property>
<property>
<name>dfs.datanode.data.dir</name>
<value>file:/home/hadoop/dfsdata/data</value>
<description>Determines where on thelocal filesystem an DFS data node should store its blocks.If this is acomma-delimited list of directories,then data will be stored in all nameddirectories,typically on different devices.Directories that do not exist areignored.
</description>
<final>true</final>
</property>
<property>
<name>dfs.replication</name>
<value>3</value>
</property>
<property>
<name>dfs.permission</name>
<value>false</value>
</property>
</configuration>
(5)、mapred-site.xml:
<configuration>
<property>
<name>mapreduce.framework.name</name>
<value>yarn</value>
</property>
<property>
<name>mapreduce.job.tracker</name>
<value>hdfs://mr5:9001</value>
<final>true</final>
</property>
<property>
<name>mapreduce.task.io.sort.mb</name>
<value>512</value>
</property>
<property>
<name>mapreduce.task.io.sort.factor</name>
<value>100</value>
</property>
<property>
<name>mapreduce.reduce.shuffle.parallelcopies</name>
<value>50</value>
</property>
<property>
<name>mapreduce.cluster.temp.dir</name>
<value>file:/home/hadoop/mapreddata/system</value>
<final>true</final>
</property>
<property>
<name>mapreduce.cluster.local.dir</name>
<value>file:/home/hadoop/mapreddata/local</value>
<final>true</final>
</property>
</configuration>
(6)、yarn-env.sh :
增加以下环境变量
exportJAVA_HOME=/usr/jdk1.6.0_30
exportHADOOP_HOME=/home/hadoop/hadoop-2.0.0-cdh4.1.2
exportHADOOP_PREFIX=${HADOOP_HOME}
exportHADOOP_MAPRED_HOME=${HADOOP_HOME}
exportHADOOP_COMMON_HOME=${HADOOP_HOME}
exportHADOOP_HDFS_HOME=${HADOOP_HOME}
exportHADOOP_YARN_HOME=${HADOOP_HOME}
exportPATH=$PATH:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin
exportJAVA_HOME JAVA_BIN PATH CLASSPATH JAVA_OPTS
exportHADOOP_LIB=${HADOOP_HOME}/lib
exportHADOOP_CONF_DIR=${HADOOP_HOME}/etc/hadoop
(7)、yarn-site.xml:
<configuration>
<!--Site specific YARN configuration properties -->
<property>
<name>yarn.resourcemanager.address</name>
<value>mr5:8080</value>
</property>
<property>
<name>yarn.resourcemanager.scheduler.address</name>
<value>mr5:8081</value>
</property>
<property>
<name>yarn.resourcemanager.resource-tracker.address</name>
<value>mr5:8082</value>
</property>
<property>
<name>yarn.nodemanager.aux-services</name>
<value>mapreduce.shuffle</value>
</property>
<property>
<name>yarn.nodemanager.aux-services.mapreduce.shuffle.class</name>
<value>org.apache.hadoop.mapred.ShuffleHandler</value>
</property>
<property>
<name>yarn.nodemanager.local-dirs</name>
<value>file:/home/hadoop/nmdata/local</value>
<description>thelocal directories used by the nodemanager</description>
</property>
<property>
<name>yarn.nodemanager.log-dirs</name>
<value>file:/home/hadoop/nmdata/log</value>
<description>thedirectories used by Nodemanagers as log directories</description>
</property>
</configuration>
(1)、在mr5上配置完第2步和第3步后,压缩hadoop-2.0.0-cdh4.1.2
rm hadoop-2.0.0-cdh4.1.2.tar.gz
tar zcvf hadoop-2.0.0-cdh4.1.2.tar.gz hadoop-2.0.0-cdh4.1.2
然后将hadoop-2.0.0-cdh4.1.2.tar.gz远程拷贝到mr6、mr7、mr8机器上
scp/home/hadoop/hadoop-2.0.0-cdh4.1.2.tar.gz hadoop@mr6:/home/hadoop/
scp/home/hadoop/hadoop-2.0.0-cdh4.1.2.tar.gz hadoop@mr7:/home/hadoop/
scp/home/hadoop/hadoop-2.0.0-cdh4.1.2.tar.gz hadoop@mr8:/home/hadoop/
(2)、将mr5机器上hadoop用户的配置环境的文件.bash_profile远程拷贝到mr6、mr7、mr8机器上
scp/home/hadoop/.bash_profile hadoop@mr6:/home/hadoop/
scp/home/hadoop/.bash_profile hadoop@mr7:/home/hadoop/
scp/home/hadoop/.bash_profile hadoop@mr8:/home/hadoop/
拷贝完成后,在mr5、mr6、mr7、mr8机器的/home/hadoop/目录下执行
source.bash_profile
使得环境变量生效
以上步骤都执行完成后,用hadoop用户登录到mr5机器依次执行:
hdfsnamenode -format
start-dfs.sh
start-yarn.sh
通过jps命令查看:
mr5成功启动了NameNode、ResourceManager、SecondaryNameNode进程;
mr6、mr7、mr8成功启动了DataNode、NodeManager进程。
通过以下方式查看节点的健康状态和作业的执行情况:
浏览器访问(本地需要配置hosts)
http://mr5:50070/dfshealth.jsp
http://mr5:8088/cluster
使用hadoop用户上传hive-0.9.0-cdh4.1.2到mr5机器的/home/hadoop/目录下并解压:
tar zxvf hive-0.9.0-cdh4.1.2
在.bash_profile添加环境变量:
exportHIVE_HOME=/home/hadoop/hive-0.9.0-cdh4.1.2
exportPATH=$PATH:${JAVA_HOME}/bin:${HADOOP_HOME}/bin:${HADOOP_HOME}/sbin:${HIVE_HOME}/bin
exportHIVE_CONF_DIR=$HIVE_HOME/conf
exportHIVE_LIB=$HIVE_HOME/lib
添加完后执行以下命令使得环境变量生效:
..bash_profile
修改hive配置文件(配置文件目录:hive-0.9.0-cdh4.1.2/conf/)
在hive-0.9.0-cdh4.1.2/conf/目录下新建hive-site.xml文件,并添加以下配置信息:
<configuration>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://10.28.169.61:3306/hive_impala?createDatabaseIfNotExist=true</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hadoop</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>hive.security.authorization.enabled</name>
<value>false</value>
</property>
<property>
<name>hive.security.authorization.createtable.owner.grants</name>
<value>ALL</value>
</property>
<property>
<name>hive.querylog.location</name>
<value>${user.home}/hive-logs/querylog</value>
</property>
</configuration>
完成以上步骤之后,验证hive安装是否成功
在mr5命令行执行hive,并输入”show tables;”,出现以下提示,说明hive安装成功:
>hive
hive>show tables;
OK
Time taken:18.952 seconds
hive>
说明:
(1)、以下1、2、3、4步是在root用户分别在mr5、mr6、mr7、mr8下执行
(2)、以下第5步是在hadoop用户下执行
安装mysql-connector-java:
yum install mysql-connector-java
安装bigtop
rpm -ivh bigtop-utils-0.4+300-1.cdh4.0.1.p0.1.el6.noarch.rpm
安装libevent
rpm -ivhlibevent-1.4.13-4.el6.x86_64.rpm
如存在其他需要安装的依赖包,可以到以下链接:
http://mirror.bit.edu.cn/centos/6.3/os/x86_64/Packages/进行下载。
rpm -ivh impala-0.3-1.p0.366.el6.x86_64.rpm
rpm -ivh impala-server-0.3-1.p0.366.el6.x86_64.rpm
rpm -ivh impala-debuginfo-0.3-1.p0.366.el6.x86_64.rpm
rpm -ivh impala-shell-0.3-1.p0.366.el6.x86_64.rpm
完成第1步和第2步后,通过以下命令:
find / -name impala
输出:
/usr/lib/debug/usr/lib/impala
/usr/lib/impala
/var/run/impala
/var/log/impala
/var/lib/alternatives/impala
/etc/default/impala
/etc/alternatives/impala
找到impala的安装目录:/usr/lib/impala
在Impala安装目录/usr/lib/impala下创建conf,将hadoop中的conf文件夹下的core-site.xml、hdfs-site.xml、hive中的conf文件夹下的hive-site.xml复制到其中。
在core-site.xml文件中添加如下内容:
<property>
<name>dfs.client.read.shortcircuit</name>
<value>true</value>
</property>
<property>
<name>dfs.client.read.shortcircuit.skip.checksum</name>
<value>false</value>
</property>
在hadoop和impala的hdfs-site.xml文件中添加如下内容并重启hadoop和impala:
<property>
<name>dfs.datanode.data.dir.perm</name>
<value>755</value>
</property>
<property>
<name>dfs.block.local-path-access.user</name>
<value>hadoop</value>
</property>
<property>
<name>dfs.datanode.hdfs-blocks-metadata.enabled</name>
<value>true</value>
</property>
(1)、在mr5启动Impala state store,命令如下:
>GLOG_v=1 nohup statestored-state_store_port=24000 &
如果statestore正常启动,可以在/tmp/statestored.INFO查看。如果出现异常,可以查看/tmp/statestored.ERROR定位错误信息。
(2)、在mr6、mr7、mr8启动Impalad,命令如下:
mr6:
>GLOG_v=1 nohup impalad -state_store_host=mr5-nn=mr5 -nn_port=9000 -hostname=mr6 -ipaddress=10.28.169.113 &
mr7:
>GLOG_v=1 nohup impalad -state_store_host=mr5-nn=mr5 -nn_port=9000 -hostname=mr7 -ipaddress=10.28.169.114 &
mr8:
>GLOG_v=1 nohup impalad -state_store_host=mr5-nn=mr5 -nn_port=9000 -hostname=mr8 -ipaddress=10.28.169.115 &
如果impalad正常启动,可以在/tmp/impalad.INFO查看。如果出现异常,可以查看/tmp/ impalad.ERROR定位错误信息。
使用impala-shell启动Impala Shell,分别连接各Impalad主机(mr6、mr7、mr8),刷新元数据,之后就可以执行shell命令。相关的命令如下(可以在任意节点执行):
>impala-shell
[Not connected]> connect mr6:21000
[mr6:21000] >refresh
[mr6:21000]>connectmr7:21000
[mr7:21000]>refresh
[mr7:21000]>connectmr8:21000
[mr8:21000]>refresh
使用impala-shell启动Impala Shell,分别连接各Impalad主机,刷新元数据,之后就可以执行shell命令。相关的命令如下(可以在任意节点执行):
>impala-shell
[Not connected]> connect mr6:21000
[mr6:21000]>refresh
[mr6:21000] >show databases
default
[mr6:21000] >
出现以上提示信息,说明安装成功。
也可以查看我发表在http://yuntai.1kapp.com/?p=904相同的博客。
更多精彩博客请访问:http://yuntai.1kapp.com/