軟件
hadoop-2.7.5.tar.gz
jdk-8u171-linux-x64.tar.gz
系統(tǒng)
CentOS Linux release 7.4.1708 (Core)
1.安裝 java 和 hadoop
? tar -zxvf jdk-8u171-linux-x64.tar.gz
?? mv jdk1.8.0_171/ /opt/jdk
? tar -zxvf hadoop-2.7.5.tar.gz
? mv hadoop-2.7.5/ /opt/hadoop
2.編輯環(huán)境變量
vi ~/.bashrc
export JAVA_HOME=/opt/jdk
export HADOOP_HOME=/opt/hadoop
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin
3.使環(huán)境變量生效
source ~/.bashrc
4.修改 core-site
vi /opt/hadoop/etc/hadoop/core-site.xml
<property>
? ? ? ? <name>fs.defaultFS</name>
? ? ? ? <value>hdfs://192.168.14.7:9000</value>
? ? </property>
5.修改hdfs-site.xml
vi /opt/hadoop/etc/hadoop/hdfs-site.xml
<property>
? ? ? ? <name>dfs.replication</name>
? ? ? ? <value>1</value>
? ? </property>
? ? <property>
? ? ? ? <name>dfs.namenode.name.dir</name>
? ? ? ? <value>file:///opt/namenode</value>
? ? </property>
? ? <property>
? ? ? ? <name>dfs.datanode.data.dir</name>
? ? ? ? <value>file:///opt/datanode</value>
? ? </property>
6.修改 hadoop-metrics2.properties
vi /opt/hadoop/etc/hadoop/hadoop-metrics2.properties
namenode.sink.file.filename=namenode-metrics.out
datanode.sink.file.filename=datanode-metrics.out
7.新建目錄
mkdir /opt/namenode
mkdir /opt/datanode
8.格式化
? hdfs namenode -format
9.啟動守護進程
hadoop-daemon.sh start namenode
hadoop-daemon.sh start datanode
10.檢查
[root@localhost ~]# ll /opt/hadoop/*out
-rw-r--r-- 1 root root 210996 Apr? 1 17:34 /opt/hadoop/datanode-metrics.out
-rw-r--r-- 1 root root 320536 Apr? 1 17:34 /opt/hadoop/namenode-metrics.out
[root@localhost ~]# cat /opt/hadoop/namenode-metrics.out |grep -i jvm|tail -n 1
1585733696289 jvm.JvmMetrics: Context=jvm, ProcessName=NameNode, SessionId=null, Hostname=localhost, MemNonHeapUsedM=39.97262, MemNonHeapCommittedM=40.6875, MemNonHeapMaxM=-9.536743E-7, MemHeapUsedM=32.27114, MemHeapCommittedM=58.0625, MemHeapMaxM=966.6875, MemMaxM=966.6875, GcCountCopy=16, GcTimeMillisCopy=93, GcCountMarkSweepCompact=1, GcTimeMillisMarkSweepCompact=39, GcCount=17, GcTimeMillis=132, GcNumWarnThresholdExceeded=0, GcNumInfoThresholdExceeded=0, GcTotalExtraSleepTime=135, ThreadsNew=0, ThreadsRunnable=6, ThreadsBlocked=0, ThreadsWaiting=5, ThreadsTimedWaiting=24, ThreadsTerminated=0, LogFatal=0, LogError=0, LogWarn=2, LogInfo=571
可以看到 jvm 相關(guān)的度量值塞琼,堆內(nèi)存,GC等信息