--hadoop文件位置:
log目錄 :html
/var/log/hadoop-hdfs /var/log/hadoop-mapreduce /var/log/hbase /var/log/hive /var/log/hive /var/log/impala
安裝目錄:java
/usr/lib
啓動命令目錄:node
/etc/init.d/
配置文件目錄:mysql
/etc/hadoop/conf /etc/hbase/conf /etc/hive/conf /etc/impala/conf
環境變量:linux
/etc/profile
讓/etc/profile文件修改後當即生效 ,能夠使用以下命令:
sql
source /etc/profile
node配置:shell
/etc/hosts
資源庫位置 : vim
/etc/yum.repos.d/
1.本地cdh4 搭建/
一、安裝httpd服務,做用:用browser查看本地庫
--安裝httpd
瀏覽器
yum install httpd
--啓動httpd
vi /etctpdtpd.conf (配置文件)
服務器
service httpd start service httpd stop service httpd restart
--關閉防火牆
service iptables status service iptables stop
--瀏覽器查看
http://ip地址
二、安裝createrepo
--Createrepo用於建立本地源。
sudo yum install yum-utils createrepo
三、搭建本地源
--下載cloudera-manager.repo,cloudera-cdh4.repo到/etc/yum.repos.d/目錄下
cd /etc/yum.repos.d/ wget http://archive.cloudera.com/cm4/redhat/6/x86_64/cm/cloudera-manager.repo wget http://archive.cloudera.com/cdh4/redhat/6/x86_64/cdh/cloudera-cdh4.repo
--將遠程源的RPM包同步到本地的httpd服務目錄
cd /var/www/html/ reposync -r cloudera-manager reposync -r cloudera-cdh4
--生成或刷新:RPMS,和一個放依賴關係等信息的文件夾repodata。
cd /var/www/html/cloudera-manager createrepo . cd /var/www/html/cloudera-cdh4 createrepo .
至此,CDH4本地源搭建完成。
4:本地源的使用
--修改cloudera-manager.repo中的baseurl修改指向本地局域網的服務器
將baseurl=http://archive.cloudera.com/cm4/redhat/6/x86_64/cm/4/ 改成:
baseurl=http://172.16.2.52/cloudera-manager/
--修改cloudera-cdh4.repo中的baseurl修改指向本地局域網的服務器
將baseurl=http://archive.cloudera.com/cdh4/redhat/6/x86_64/cdh/4/ 改成:
baseurl=http://172.16.2.52/cloudera-cdh4/
baseurl的地址是服務器地址+放置RPM包的目錄名,結構以下圖:裏面有一個放RPM包的文件夾RPMS,和一個放依賴關係等信息的文件夾repodata。
2.cloudera manager安裝
--安裝
sudo yum install cloudera-manager-daemons sudo yum install cloudera-manager-server sudo yum install cloudera-manager-server-db sudo yum install cloudera-manager-agent
--啓動
service cloudera-scm-server start service cloudera-manager-server-db start service cloudera-scm-agent start
3.cdh4 安裝
//安裝 裝CDH4
yum install hadoop-0.20-mapreduce-jobtracker hadoop-0.20-mapreduce-tasktracker yum install hadoop-hdfs-namenode yum install hadoop-hdfs-datanode yum install hadoop-0.20-conf-pseudo sudo -u hdfs hdfs namenode -format
--啓動hdfs
for x in `cd /etc/init.d ; ls hadoop-hdfs-*` ; do sudo service $x start ; done
4..安裝 hive
參考資料:http://heylinux.com/archives/2456.html
--安裝hive
sudo yum install hive hive-metastore hive-server
--安裝mysql
sudo yum install mysql mysql-server mysql-devel service mysqld start
--安裝mysql鏈接驅動
sudo yum install mysql-connector-java ln -s /usr/share/java/mysql-connector-java.jar /usr/lib/hive/lib/mysql-connector-java.jar
--設置root密碼
sudo /usr/bin/mysql_secure_installation
根據提示輸入密碼
01 [...] 02 Enter current password for root (enter for none): 03 OK, successfully used password, moving on... 04 [...] 05 Set root password? [Y/n] y 06 New password:hadoophive 07 Re-enter new password:hadoophive 08 Remove anonymous users? [Y/n] Y 09 [...] 10 Disallow root login remotely? [Y/n] N 11 [...] 12 Remove test database and access to it [Y/n] Y 13 [...] 14 Reload privilege tables now? [Y/n] Y 15 All done!
--進入mysql 依次執行
mysql -u root -p hadoophive CREATE DATABASE metastore; USE metastore; SOURCE /usr/lib/hive/scripts/metastore/upgrade/mysql/hive-schema-0.10.0.mysql.sql; CREATE USER 'hive'@'%' IDENTIFIED BY 'hadoophive'; CREATE USER 'hive'@'localhost' IDENTIFIED BY 'hadoophive'; GRANT ALL PRIVILEGES ON metastore.* TO 'hive'@'%'; GRANT ALL PRIVILEGES ON metastore.* TO 'hive'@'localhost'; FLUSH PRIVILEGES; quit;
--啓動hive
--修改配置文件hive-site.xml
sudo vim /etc/hive/conf/hive-site.xml參考 hive 配置
<configuration> <!-- Hive Configuration can either be stored in this file or in the hadoop configuration files --> <!-- that are implied by Hadoop setup variables. --> <!-- Aside from Hadoop setup variables - this file is provided as a convenience so that Hive --> <!-- users do not have to edit hadoop configuration files (that may be managed as a centralized --> <!-- resource). --> <!-- Hive Execution Parameters --> <property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost:3306/metastore</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> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>hadoophive</value> </property> <property> <name>hive.metastore.uris</name> <value>thrift://127.0.0.1:9083</value> <description>IP address (or fully-qualified domain name) and port of the metastore host</description> </property> </configuration>
--啓動hive
service hive-metastore start service hive-server start
--依次執行
$ sudo -u hdfs hadoop fs -mkdir /user/hive $ sudo -u hdfs hadoop fs -chown hive /user/hive $ sudo -u hdfs hadoop fs -mkdir /tmp $ sudo -u hdfs hadoop fs -chmod 777 /tmp $ sudo -u hdfs hadoop fs -chmod o+t /tmp $ sudo -u hdfs hadoop fs -mkdir /data $ sudo -u hdfs hadoop fs -chown hdfs /data $ sudo -u hdfs hadoop fs -chmod 777 /data $ sudo -u hdfs hadoop fs -chmod o+t /data $ sudo chown -R hive:hive /var/lib/hive
$ sudo vim /tmp/kv1.txt
1,www.baidu.com 2,wwww.google.com 3,wwww.sina.com.cn 4,wwww.163.com 5,wheylinx.com
CREATE TABLE IF NOT EXISTS pokes ( foo INT,bar STRING ) ROW FORMAT DELIMITED FIELDS TERMINATED BY "," LINES TERMINATED BY "\n"; show tables; desc formatted pokes; LOAD DATA LOCAL INPATH '/tmp/kv1.txt' OVERWRITE INTO TABLE pokes; select * from pokes;
5.安裝impala
參考資料:http://heylinux.com/archives/2456.html
--下載資源包
sudo wget http://archive.cloudera.com/impala/redhat/6/x86_64/impala/cloudera-impala.repo
--同步資源庫
cd /var/www/html/ reposync -r cloudera-impala cd /var/www/html/cloudera-impala createrepo .
--修改cloudera-impala.repo
將baseurl=http://archive.cloudera.com/impala/redhat/6/x86_64/impala/1/改成:
baseurl=http://172.16.2.52/cloudera-impala/
--安裝
sudo yum install impala sudo yum install impala-shell sudo yum install impala-server sudo yum install impala-state-store
--添加配置/etc/hadoop/conf/hdfs-site.xml以下
sudo vim /etc/hadoop/conf/hdfs-site.xml
<property> <name>dfs.client.read.shortcircuit</name> <value>true</value> </property> <property> <name>dfs.domain.socket.path</name> <value>/var/run/hadoop-hdfs/dn._PORT</value> </property> <property> <name>dfs.client.file-block-storage-locations.timeout</name> <value>3000</value> </property> <property> <name>dfs.datanode.hdfs-blocks-metadata.enabled</name> <value>true</value> </property>
--複製文件到/etc/impala/conf/
sudo cp -rpa /etc/hadoop/conf/core-site.xml /etc/impala/conf/ sudo cp -rpa /etc/hadoop/conf/hdfs-site.xml /etc/impala/conf/ sudo cp -rpa /etc/hive/conf/hive-site.xml /etc/impala/conf/
--從新啓動datanode 及 impala
sudo service hadoop-hdfs-datanode restart sudo service impala-state-store restart sudo service impala-server restart
--進入impala命令行
impala-shell
5.安裝hbase(僞分佈)
--安裝zookper
yum install zookeeper-server
--啓動zookper
service zookeeper-server start
--安裝hbase,hbase-master,hbase-regionserver
sudo yum install hbase sudo yum install hbase-master sudo yum install hbase-regionserver
--修改配置
sudo vim /etc/security/limits.conf
hdfs - nofile 32768 hbase - nofile 32768
--修改配置
$sudo vim /etc/pam.d/common-session
session required pam_limits.so
--修改hadoop配置
sudo vim /etc/hadoop/conf/hdfs-site.xml
<property> <name>dfs.datanode.max.xcievers</name> <value>4096</value> </property>
--修改hbase配置/etc/hbase/conf/hbase-site.xml
<configuration> <property> <name>hbase.rootdir</name> <value>hdfs://myhost:8020/hbase</value> </property> <property> <name>hbase.cluster.distributed</name> <value>true</value> </property> </configuration>
--建立hbase工做目錄
sudo -u hdfs hadoop fs -mkdir /hbase sudo -u hdfs hadoop fs -chown hbase /hbase
--hdfs重啓
sudo /etc/init.d/hadoop-hdfs-namenode restart sudo /etc/init.d/hadoop-hdfs-datanode restart
--啓動
sudo service hbase-master start sudo service hbase-regionserver start
--進入hbase
hbase shell