El tutorial de construcción de entornos completamente distribuidos de Hadoop + Hbase + Hive más detallado (2)

Continúe con el último tutorial, esta vez instale hbase y hive. Anteriormente, algunos estudiantes informaron que no hay un paquete de instalación de hbase en el disco de red de Baidu. Esta vez lo agregué. Ya está en el enlace del disco de red del blog anterior. El tutorial de construcción de entornos completamente distribuido de Hadoop + Hbase + Hive más detallado ( 1) .

Uno, instalación de hbase2.1.1

En el nodo principal:

$ tar -zxvf hbase-2.1.1-bin.tar.gz -C /opt
$ cd /opt/hbase-2.1.1/conf/
$ vi hbase-env.sh 

Agregue la siguiente oración al final del archivo
export JAVA_HOME=/opt/jdk1.8.0_102

$ vi hbase-site.xml

enmendar de la siguiente manera:

<configuration>
<property>
  <name>hbase.rootdir</name>
  <value>hdfs://master:9000/hbase</value>
</property>
<property>
  <name>hbase.zookeeper.quorum</name>
  <value>master,slave1,slave2</value>
</property>
<property>
  <name>hbase.cluster.distributed</name>
  <value>true</value>
</property>
<property>
  <name>hbase.zookeeper.property.dataDir</name>
  <value>/home/fay/zookeeper</value>
</property>
</configuration>

$ vi regionservers
enmendar de la siguiente manera:

# 删掉localhost
slave1
slave2

$ vi backup-masters
Este archivo es de nueva creación, agregue la siguiente oración

slave1

Luego es configurar las variables de entorno:
$ vi ~/.bashrc

export JAVA_HOME=/opt/jdk1.8.0_102
export HADOOP_HOME=/opt/hadoop-2.8.5
export HBASE_HOME=/opt/hbase-2.1.1
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin:

$ source ~/.bashrc
Luego, dé el archivo de configuración y el directorio completo a los otros dos nodos:

$ scp -r hbase-2.1.1/ fay@slave1:/opt
$ scp -r hbase-2.1.1/ fay@slave2:/opt
$ scp ~/.bashrc fay@slave1:/home/fay
$ scp ~/.bashrc fay@slave1:/home/fay


$ source ~/.bashrc
Obtenga los otros dos nodos y luego inicie hbase cuando Hadoop esté activo

# 启动hadoop
$ start-dfs.sh
$ start-yarn.sh
# 启动hbase
$ start-hbase.sh

Entonces el nodo maestro:

[fay@master opt]$ jps
39825 Jps
38898 ResourceManager
39398 HQuorumPeer #hbase的zookeeper实例
38487 NameNode
39495 HMaster # hbase master
38702 SecondaryNameNode

nodo esclavo:

[fay@slave1 ~]$ jps
16481 DataNode
16598 NodeManager
16886 HRegionServer # hbase regionserver
16775 HQuorumPeer 
17003 HMaster # 这个是slave1,因为前面配置了backup-masters,slave2没有这个
17278 Jps

Preste atención al problema de sincronización de tiempo aquí. El inicio puede llevar mucho tiempo. No cancele con ctrl + c, ya que puede ser anormal. Está bien, pruébalo

[fay@master opt]$ hbase shell
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hadoop-2.8.5/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hbase-2.1.1/lib/client-facing-thirdparty/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
HBase Shell
Use "help" to get list of supported commands.
Use "exit" to quit this interactive shell.
For Reference, please visit: http://hbase.apache.org/2.0/book.html#shell
Version 2.1.1, rb60a92d6864ef27295027f5961cb46f9162d7637, Fri Oct 26 19:27:03 PDT 2018
Took 0.0047 seconds                                                                                                                                               
hbase(main):001:0> list
TABLE                                                                                                                                                             
wuxia                                                                                                                                                             
1 row(s) # 这里我之前创建了表,初始状态应该是0
Took 1.8662 seconds                                                                                                                                               
=> ["wuxia"]
hbase(main):002:0> create 'hello','world'
Created table hello
Took 3.1974 seconds                                                                                                                                               
=> Hbase::Table - hello

Sin excepción, básicamente hbase está configurado

Dos, construcción de colmena2.3.4

1. Instale mysql 8.0.13 (puede usar el derby incorporado sin instalación)

Desinstale mariadb-lib que viene con el sistema para
ver la versión de mariadb
rpm -qa|grep mariadb

La desinstalación de mariadb
rpm -e mariadb-libs-5.5.56-2.el7.x86_64 --nodeps
mysql tiene dependencias, el orden de instalación es común, lib, cliente, servidor

sudo  rpm -ivh mysql-community-common-8.0.13-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-libs-8.0.13-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-client-8.0.13-1.el7.x86_64.rpm
sudo rpm -ivh mysql-community-server-8.0.13-1.el7.x86_64.rpm

Inicie mysql:

sudo systemctl start mysqld
Establezca la contraseña de root:

 [fay@master ~]$ cat /var/log/mysqld.log
2018-11-11T09:12:06.253251Z 0 [System] [MY-013169] [Server] /usr/sbin/mysqld (mysqld 8.0.13) initializing of server in progress as process 20113
2018-11-11T09:12:09.192846Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: pR+ndHtvO6#d

La anterior pR+ndHtvO6#des la contraseña de root inicial, use esta contraseña para iniciar sesión en mysql

[fay@master ~]$ mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 19
Server version: 8.0.13 MySQL Community Server - GPL

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> 

Luego crea un usuario fay y dale permisos

mysql> CREATE USER 'fay'@'master' IDENTIFIED BY '你的密码';
mysql> create database hive_metedata
mysql> grant all privileges on *.* to 'fay'@'master';
mysql> flush privileges;

2. Instalar colmena

Descomprimir en la /optcarpeta:
$ tar -zxvf apache-hive-2.3.4-bin.tar.gz -C /opt
$ cd /opt/apache-hive-2.3.4-bin/conf/
modificar hive-env.sh para
configurar hadoop_home y otras variables de entorno, están al final del archivo

[fay@master conf]$ cp hive-env.sh.template hive-env.sh
[fay@master conf]$ vi hive-env.sh
...
# HADOOP_HOME=${bin}/../../hadoop
export HADOOP_HOME=/opt/hadoop-2.8.5

# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/opt/apache-hive-2.3.4-bin/conf

# Folder containing extra libraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/opt/apache-hive-2.3.4-bin/lib
export JAVA_HOME=/opt/jdk1.8.0_102

Modificar hive-site.xml

[fay@master conf]$ cp hive-default.xml.template hive-site.xml 
[fay@master conf]$ vi hive-site.xml 
# 文件太长了,就copy几个重要需要改的地方,找到这些配置项改
<property>
    <name>hive.exec.local.scratchdir</name>
    <value>/home/fay/hive/tmp/fay</value>
    <description>Local scratch space for Hive jobs</description>
  </property>
<property>
    <name>hive.downloaded.resources.dir</name>
    <value>/home/fay/hive/tmp/${hive.session.id}_resources</value>
    <description>Temporary local directory for added resources in the remote file system.</description>
</property>
 <property>
    <name>javax.jdo.option.ConnectionPassword</name>
    <value>你的密码</value>
    <description>password to use against metastore database</description>
  </property>
  <property>
    <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://master:3306/hive_metedata?createDatabaseIfNotExist=true</value>
    <description>
      JDBC connect string for a JDBC metastore.
      To use SSL to encrypt/authenticate the connection, provide database-specific SSL flag in the connection URL.
      For example, jdbc:postgresql://myhost/db?ssl=true for postgres database.
    </description>
  </property>
<property>
    <name>javax.jdo.option.ConnectionDriverName</name>
    <value>com.mysql.cj.jdbc.Driver</value>    
    <description>Driver class name for a JDBC metastore</description>
  </property>

Nota : Si javax.jdo.option.ConnectionDriverName es com.mysql.jdbc.Driver, coloque el paquete jar mysql-connector en la carpeta $ {hive_home} / lib, de modo que el paquete jar mysql-connector pueda tener Opcional

Entonces todo el archivo de configuración ${system:java.io.tmpdir}se cambia a /home/fay/hive/tmp(si no se crea el archivo), y da lectura y acceso de escritura a esta carpeta ${system:user.name}cambiarfay

Luego agregue variables de entorno:

[fay@master lib]$ vi ~/.bashrc

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

# Uncomment the following line if you don't like systemctl's auto-paging feature:
# export SYSTEMD_PAGER=

# User specific aliases and functions

export JAVA_HOME=/opt/jdk1.8.0_102
export HADOOP_HOME=/opt/hadoop-2.8.5
export HBASE_HOME=/opt/hbase-2.1.1
export HADOOP_COMMON_LIB_NATIVE_DIR=$HADOOP_HOME/lib/native
export HADOOP_OPTS="-Djava.library.path=$HADOOP_HOME/lib/native"
export HIVE_HOME=/opt/apache-hive-2.3.4-bin
export PATH=$PATH:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HADOOP_HOME/sbin:$HBASE_HOME/bin:$HIVE_HOME/bin

source ~/.bashrc
Cree la carpeta hdfs y otorgue permisos

$ hadoop fs -mkdir -p /user/hive/
$ hadoop fs -mkdir -p /user/hive/warehouse
$ hadoop fs -chmod 777 /user/hive/
$ hadoop fs -chmod 777 /user/hive/warehouse

Inicialice Hive y luego inicie Hive:

[fay@master conf]$ schematool -dbType mysql -initSchema
[fay@master conf]$ hive
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/apache-hive-2.3.4-bin/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.8.5/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]

Logging initialized using configuration in jar:file:/opt/apache-hive-2.3.4-bin/lib/hive-common-2.3.4.jar!/hive-log4j2.properties Async: true
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> 

Luego pruebe la función de hive, que es similar a sql. No necesito introducir más aquí. Hasta ahora, todo el entorno está configurado. Si encuentra un problema a mitad de camino, todavía hay muchas soluciones en Internet. Si presiono esta vez, lo ajustaré nuevamente si el entorno falla. El entorno es más familiar, también he construido el entorno casi 10 veces, solía usar la misma versión, esta vez planeo usar la última versión, todavía hay muchas trampas en el medio.

Supongo que te gusta

Origin blog.csdn.net/Fei20140908/article/details/84036524
Recomendado
Clasificación