1. 程式人生 > >hbase 2 + zookeeper 3 + hadoop 3 +elasticsearch 6 研發環境部署(超詳細)

hbase 2 + zookeeper 3 + hadoop 3 +elasticsearch 6 研發環境部署(超詳細)

##################### 環境 ##########################

#OS版本號

[[email protected] softs]$ cat /etc/centos-release
CentOS Linux release 7.5.1804 (Core)

#軟體版本號

hadoop-3.1.1
hbase-2.1.0
jdk1.8.0_191
scala-2.12.7
zookeeper-3.4.10
elasticsearch-6.4.2

###############################################

安裝zookeeper

#解壓安裝包

#解壓zookeeper 
tar -zxvf zookeeper-3.4.10.tar.gz -C ~/softs/

#配置檔案 vi conf/zoo.cfg

################ start ################
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/home/troll/data/tmp/zookeeper/zk1/
# the port at which the clients will connect
clientPort=2181
################ end ################

#建立資料目錄

#建立zookeeper資料目錄
mkdir -p /home/troll/data/tmp/zookeeper/zk1/

#服務啟動和停止

#啟動服務 
bin/zkServer.sh start
#停止服務 
bin/zkServer.sh stop

安裝hadoop

#解壓安裝包

tar -zxvf hadoop-3.1.1.tar.gz -C ~/softs/

#配置檔案 vi core-site.xml

    <!-- 指定HDFS(namenode)的通訊地址 -->
    <property>
        <name>fs.defaultFS</name>
        <value>hdfs://localhost:9000</value>
    </property>
    <!-- 指定hadoop執行時產生檔案的儲存路徑 -->
    <property>
        <name>hadoop.tmp.dir</name>
        <value>/home/troll/data/hadoop/tmp</value>
    </property>

vi hdfs-site.xml

    <!-- hdfs namenode資料目錄 -->
    <property>
    	<name>dfs.name.dir</name>
    	<value>/home/troll/data/hadoop/hdfs/name</value>
    	<description>namenode上儲存hdfs名字空間元資料 </description> 
    </property>
	<!-- hdfs datanode資料目錄 -->
    <property>
        <name>dfs.data.dir</name>
        <value>/home/troll/data/hadoop/hdfs/data</value>
        <description>datanode上資料塊的物理儲存位置</description>
    </property>
    <!-- 設定hdfs副本數量 -->
    <property>
        <name>dfs.replication</name>
        <value>1</value>
    </property>

vi mapred-site.xml

    <!-- 通知框架MR使用YARN -->
    <property>
        <name>mapreduce.framework.name</name>
        <value>yarn</value>
    </property>

vi yarn-site.xml

    <!-- reducer取資料的方式是mapreduce_shuffle -->
    <property>
        <name>yarn.nodemanager.aux-services</name>
        <value>mapreduce_shuffle</value>
    </property>
#設定環境變數
export JAVA_HOME=/home/troll/softs/jdk1.8.0_191

#建立目錄

mkdir -p /home/troll/data/hadoop/hdfs/data
mkdir -p /home/troll/data/hadoop/hdfs/name
mkdir -p /home/troll/data/hadoop/tmp

#生成免祕鑰

ssh-keygen -t dsa -P '' -f ~/.ssh/id_dsa
cat ~/.ssh/id_dsa.pub >> ~/.ssh/authorized_keys
chmod 0600 ~/.ssh/authorized_keys

#格式化hdfs

cd /home/troll/softs/hadoop-3.1.1
./bin/hdfs namenode -format

#服務管理

#啟動 hdfs 服務
cd /home/troll/softs/hadoop-3.1.1
./sbin/start-dfs.sh

#檢視介面 tips:初次需要等待較長時間,3.0以下版本頁面埠為50070
http://standalone.hadoop:9870/dfshealth.html#tab-overview


#停止 hdfs 服務
cd /home/troll/softs/hadoop-3.1.1
./sbin/stop-dfs.sh



#啟動 yarn 服務
cd /home/troll/softs/hadoop-3.1.1
./sbin/start-yarn.sh

#檢視介面
http://standalone.hadoop:8088/cluster

#停止 yarn 服務
cd /home/troll/softs/hadoop-3.1.1
./sbin/stop-yarn.sh



#也可以使用demon來操作服務

./hadoop-daemon.sh start namenode
./hadoop-daemon.sh start secondarynamenode
./hadoop-daemon.sh start jobtracker
./hadoop-daemon.sh start datanode
./hadoop-daemon.sh start tasktracker


./hadoop-daemon.sh stop namenode
./hadoop-daemon.sh stop secondarynamenode
./hadoop-daemon.sh stop jobtracker
./hadoop-daemon.sh stop datanode
./hadoop-daemon.sh stop tasktracker

安裝hbase

#解壓安裝包

tar -zxvf hbase-2.1.0-bin.tar.gz -C ~/softs/

#修改配置 cd ~/softs/hbase-2.1.0/ vi conf/hbase-site.xml

	<property>
		<name>hbase.rootdir</name>
		<value>file:///home/troll/data/hbase</value>
	</property>
  	<property>
		<name>hbase.zookeeper.quorum</name>  
		<value>localhost</value>  
	</property>

	<property>
		<name>hbase.zookeeper.property.clientPort</name>
		<value>2181</value>
	</property>

	<property>
		<name>hbase.zookeeper.property.dataDir</name>  
		<value>/home/troll/data/tmp/zookeeper/zk1/</value>  
	</property>

	<property>
		<name>hbase.cluster.distributed</name>
		<value>true</value>
	</property>

	<property>
		<name>zookeeper.znode.parent</name>
		<value>/hbase</value>
	</property>
export JAVA_HOME=/home/troll/softs/jdk1.8.0_191
export HBASE_MANAGES_ZK=true

#建立資料目錄

mkdir -p /home/troll/data/hbase

#啟動服務

 bin/start-hbase.sh 

elasticsearch 安裝

#解壓安裝包

tar -zxvf elasticsearch-6.4.2.tar.gz -C ~/softs/

#配置檔案 vi config/elasticsearch.yml

cluster.name: my-standalone-cluster
node.name: standalone-node-1
node.attr.rack: r1
path.data: /home/troll/data/data/elasticsearch
path.logs: /var/log/elasticsearch
bootstrap.memory_lock: false
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"

#啟動服務

bin/elasticsearch