1. 程式人生 > >【hadoop】知識積累

【hadoop】知識積累

1、單位運算

1T = 1024G
1P = 1024T
1E = 1024P
1Z = 1024E
1Y = 1024Z
1N = 1024Y

2、四個模組
1.common
2.hdfs
3.hadoop yarn
4.hadooop mapreduce(mr)

3、安裝jdk

a)下載jdk-8u65-linux-x64.tar.gz
		b)tar開
			$>su centos ; cd ~
			$>mkdir downloads
			$>cp /mnt/hdfs/downloads/bigdata/jdk-8u65-linux-x64.tar.gz ~/downlooads
			$>tar -xzvf jdk-8u65-linux-x64.tar.gz
		c)建立/soft資料夾
			$>sudo mkdir /soft
			$>sudo chown centos:centos /soft
		d)移動tar開的檔案到/soft下
			$>mv ~/downloads/jdk-1.8.0_65 /soft/
		e)建立符號連線
			$>ln -s /soft/jdk-1.8.0_65 /soft/jdk
		f)驗證jdk安裝是否成功
			$>cd /soft/jdk/bin
			$>./java -version

4、配置環境變數

1.編輯/etc/profile
		$>sudo nano /etc/profile
		...
		export JAVA_HOME=/soft/jdk
		exprot PATH=$PATH:$JAVA_HOME/bin
	2.使環境變數即刻生效
		$>source /etc/profile
	
	3.進入任意目錄下,測試是否ok
		$>cd ~
		$>java -version

5、安裝hadoop

1.安裝hadoop
		a)下載hadoop-2.7.3.tar.gz
		b)tar開
			$>su centos ; cd ~
			$>cp /mnt/hdfs/downloads/bigdata/hadoop-2.7.3.tar.gz ~/downloads
			$>tar -xzvf hadoop-2.7.3.tar.gz
		c)無
		d)移動tar開的檔案到/soft下
			$>mv ~/downloads/hadoop-2.7.3 /soft/
		e)建立符號連線
			$>ln -s /soft/hadoop-2.7.3 /soft/hadoop
		f)驗證jdk安裝是否成功
			$>cd /soft/hadoop/bin
			$>./hadoop version	
	2.配置hadoop環境變數
		$>sudo nano /etc/profile
		...
		export JAVA_HOME=/soft/jdk
		exprot PATH=$PATH:$JAVA_HOME/bin

		export HADOOP_HOME=/soft/hadoop
		export PATH=$PATH:$HADOOP_HOME/bin:$HADOOP_HOME/sbin	
	3.生效
		$>source /etc/profile

6、配置hadoop

1.standalone(local)
		nothing !
		不需要啟用單獨的hadoop程序。
	
2.Pseudodistributed mode
	偽分佈模式。
	a)進入${HADOOP_HOME}/etc/hadoop目錄
	b)編輯core-site.xml
		<?xml version="1.0"?>
		<configuration>
			<property>
				<name>fs.defaultFS</name>
				<value>hdfs://localhost/</value>
			</property>
		</configuration>
	c)編輯hdfs-site.xml
		<?xml version="1.0"?>
		<configuration>
			<property>
				<name>dfs.replication</name>
				<value>1</value>
			</property>
		</configuration>
	d)編輯mapred-site.xml
		注意:cp mapred-site.xml.template mapred-site.xml
		<?xml version="1.0"?>
		<configuration>
			<property>
				<name>mapreduce.framework.name</name>
				<value>yarn</value>
			</property>
		</configuration>
	e)編輯yarn-site.xml
		<?xml version="1.0"?>
		<configuration>
			<property>
				<name>yarn.resourcemanager.hostname</name>
				<value>localhost</value>
			</property>
			<property>
				<name>yarn.nodemanager.aux-services</name>
				<value>mapreduce_shuffle</value>
			</property>
		</configuration>

	f)配置SSH
		1)檢查是否安裝了ssh相關軟體包(openssh-server + openssh-clients + openssh)
			$yum list installed | grep ssh

		2)檢查是否啟動了sshd程序
			$>ps -Af | grep sshd
		
		3)在client側生成公私祕鑰對。
			$>ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
		
		4)生成~/.ssh資料夾,裡面有id_rsa(私鑰) + id_rsa.pub(公鑰)

		5)追加公鑰到~/.ssh/authorized_keys檔案中(檔名、位置固定)
			$>cd ~/.ssh
			$>cat id_rsa.pub >> authorized_keys
		
		6)修改authorized_keys的許可權為644.
			$>chmod 644 authorized_keys
		
		7)測試
			$>ssh localhost