This blog is about different trends in the Data Management ecosphere. Master data (Reference data, Meta data), Big Data, Data Science - R, IoT, Container (Docker), AWS
Tuesday, September 6, 2016
Installing Hadoop, Hive and HBase
Intention:
At the end of this exercise you will have Hadoop, Hive & HBase installed on your Mac and you will be ready to start implementing some BigData projects
Installing - Apache Hadoop 2.7.2 on macOS Sierra
This is my step by step guide to installing Hadoop on macOS Sierra.
Prerequisites
Hardware
Model Name:MacBook Pro
Model Identifier:MacBookPro12,1
Processor Name:Intel Core i7
Processor Speed:3.1 GHz
Number of Processors:1
Total Number of Cores:2
L2 Cache (per Core):256 KB
L3 Cache:4 MB
Memory:16 GB
Software
OS: macOS Sierra - OS X 10.12. - pre-release version
Package Manager: Home Brew - 1.18
Big Data: Hadoop
Installation
SET JAVA_HOME ON MAC OS X
Open Terminal
Confirm you have JDK by typing “which java”. It should show something like /usr/bin/java.
$ which java
/usr/local/bin/java
Check you have the needed version of Java, by typing “java -version”.
OpenJDK 64-Bit Server VM (build 25.71-b00, mixed mode)
JAVA_HOME is essentially the full path of the directory that contains a sub-directory named bin which in turn contains the java.
For Mac OSX – it is /Library/Java/Home
Set JAVA_HOME using this command in Terminal: export JAVA_HOME=/Library/Java/Home
echo $JAVA_HOME on Terminal to confirm the path
You should now be able to run your application
Note that this sets JAVA_HOME only for this session. If you want it to persist, you will have to add the command to your ~/.profile file. Below are instructions on how to accomplish this instead:
Open up Terminal.app (Applications >> Utilities >> Terminal)
Type: emacs .profile
add this to the end of the .profile file:
JAVA_HOME=/Library/Java/Home export JAVA_HOME;
Save and exit emacs (ctrl-x, ctrl-s; ctrl-x, ctrl-c)
Open a new Terminal window (cmd-n) and type: $JAVA_HOME/bin/java -version
If you see something like: java version “1.5.0_16″ Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_16-b06-284) Java HotSpot(TM) Client VM (build 1.5.0_16-133, mixed mode, sharing)
Then you’ve successfully set your JAVA_HOME environment variable to the binary stored in /Library/Java/Home/bin/java
Install Home Brew
Open a terminal in MAC. CMD + Space & type Terminal or open terminal from launcher
🍺 /usr/local/Cellar/hadoop/2.7.2: 6,304 files, 310M, built in 1 minute 5 seconds
Configuration
Configuring Hadoop
Edit hadoop-env.sh
The file can be located at /usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/hadoop-env.shwhere 2.7.0 is the hadoop version.
One can open and edit the file in the terminal alternatively can also open the file from finder. In order to do so. You need to activate the finder to show all hidden folders.
Show/Hide Hidden Files
Open Terminal found in Finder > Applications > Utilities
In Terminal, paste the following:defaults write com.apple.finder AppleShowAllFiles YES
Press return
Hold the ‘Option/alt’ key, then right click on the Finder icon in the dock and click Relaunch.
Relaunch Finder by right clicking the Finder Icon whilst holding the ‘Option/alt’ key
This will show all hidden files.
To hide them again, follow the same steps but replace the Terminal command with: defaults write com.apple.finder AppleShowAllFiles NO
I used text wrangler to edit the file. Alternatively you can edit it on terminal:
# Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License.
# Set Hadoop-specific environment variables here.
# The only required environment variable is JAVA_HOME. All others are # optional. When running a distributed configuration it is best to # set JAVA_HOME in this file, so that it is correctly defined on # remote nodes.
# The java implementation to use. export JAVA_HOME="$(/usr/libexec/java_home)"
# The jsvc implementation to use. Jsvc is required to run secure datanodes # that bind to privileged ports to provide authentication of data transfer # protocol. Jsvc is not required if SASL is configured for authentication of # data transfer protocol using non-privileged ports. #export JSVC_HOME=${JSVC_HOME}
# Extra Java CLASSPATH elements. Automatically insert capacity-scheduler. for f in $HADOOP_HOME/contrib/capacity-scheduler/*.jar; do if [ "$HADOOP_CLASSPATH" ]; then export HADOOP_CLASSPATH=$HADOOP_CLASSPATH:$f else export HADOOP_CLASSPATH=$f fi done
# The maximum amount of heap to use, in MB. Default is 1000. #export HADOOP_HEAPSIZE= #export HADOOP_NAMENODE_INIT_HEAPSIZE=""
# Extra Java runtime options. Empty by default. export HADOOP_OPTS="$HADOOP_OPTS -Djava.net.preferIPv4Stack=true"
# Command specific options appended to HADOOP_OPTS when specified export HADOOP_NAMENODE_OPTS="-Dhadoop.security.logger=${HADOOP_SECURITY_LOGGER:-INFO,RFAS} -Dhdfs.audit.logger=${HDFS_AUDIT_LOGGER:-INFO,NullAppender} $HADOOP_NAMENODE_OPTS"
# The following applies to multiple commands (fs, dfs, fsck, distcp etc)
export HADOOP_CLIENT_OPTS="-Xmx512m $HADOOP_CLIENT_OPTS" #HADOOP_JAVA_PLATFORM_OPTS="-XX:-UsePerfData $HADOOP_JAVA_PLATFORM_OPTS" # On secure datanodes, user to run the datanode as after dropping privileges. # This **MUST** be uncommented to enable secure HDFS if using privileged ports # to provide authentication of data transfer protocol. This **MUST NOT** be # defined if SASL is configured for authentication of data transfer protocol # using non-privileged ports. export HADOOP_SECURE_DN_USER=${HADOOP_SECURE_DN_USER} # Where log files are stored. $HADOOP_HOME/logs by default. #export HADOOP_LOG_DIR=${HADOOP_LOG_DIR}/$USER # Where log files are stored in the secure data environment. export HADOOP_SECURE_DN_LOG_DIR=${HADOOP_LOG_DIR}/${HADOOP_HDFS_USER}
### # HDFS Mover specific parameters ### # Specify the JVM options to be used when starting the HDFS Mover. # These options will be appended to the options specified as HADOOP_OPTS # and therefore may override any similar flags set in HADOOP_OPTS # # export HADOOP_MOVER_OPTS=""
### # Advanced Users Only! ###
# The directory where pid files are stored. /tmp by default. # NOTE: this should be set to a directory that can only be written to by # the user that will run the hadoop daemons. Otherwise there is the # potential for a symlink attack. export HADOOP_PID_DIR=${HADOOP_PID_DIR} export HADOOP_SECURE_DN_PID_DIR=${HADOOP_PID_DIR}
# A string representing this instance of hadoop. $USER by default export HADOOP_IDENT_STRING=$USER
The file can be located at/usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/core-site.xml
from:
to:
hadoop.tmp.dir/usr/local/Cellar/hadoop/hdfs/tmpA base for other temporary directories.fs.default.namehdfs://localhost:9000
Edit mapred-site.xml
The file can be located at /usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/mapred-site.xml The file doesn't exist by default. Need to create it from mapred-site.xml.template
mapred.job.trackerlocalhost:9010
Edit hdfs-site.xml
The file can be located at /usr/local/Cellar/hadoop/2.7.2/libexec/etc/hadoop/hdfs-site.xml.
dfs.replication1
Create and edit your ~/.profile
The .profile file in MacOSX works exactly how you would expect. Simply create the .profile file in your user directory if it doesn't exist.
There is no ~/.profile by default.
When you start your Terminal.app, it loads a shell – in your case Bash. Shells can have configuration files, and .profile is one of these. They are read when the shell starts up, in a specific order. You can read man bash, section "Invocation", for more details.*
touch ~/.profile
open -e !$
Save it, and the next time you start a new instance of Bash (e.g. by opening a new Terminal window), your ~/.profile will be read and all commands therein will be executed.
* Note that once you create a file called ~/.bash_profile, your ~/.profile will not be read anymore.
.profile works with sh or bash. However .bash_profile is bash-specific and will override .profile if present.
In macOS Sierra the .bash_profile exists in the home directory (its empty by default)
Add the following two commands.
alias hstart="/usr/local/Cellar/hadoop/2.6.0/sbin/start-dfs.sh;/usr/local/Cellar/hadoop/2.7.2/sbin/start-yarn.sh"
alias hstop="/usr/local/Cellar/hadoop/2.6.0/sbin/stop-yarn.sh;/usr/local/Cellar/hadoop/2.7.2/sbin/stop-dfs.sh"
. ~/.bash_profile to reload the bash profile.
Format the hdfs file before executing Hadoop
$ hdfs namenode -format
16/09/06 13:20:22 INFO namenode.NameNode: STARTUP_MSG:
Command
$ jps
7379 DataNode
7459 SecondaryNameNode
7316 NameNode
7636 NodeManager
7562 ResourceManager
7676 Jps
$ yarn // For resource management more information than the web interface.
$ mapred // Detailed information about jobs
MySQL 5.6.22 is already installed. Versions (2018/03/14) Hadoop 3.0.0 (Since my earlier installed version of Hadoop was 2.7 , I upgraded it to 3.0.0 using brew)
$ tar zxvf mysql-connector-java-5.1.35.tar.gz $ sudo cp mysql-connector-java-5.1.35/mysql-connector-java-5.1.35-bin.jar /usr/local/Cellar/hive/2.7.1/libexec/lib/
Setup MySQL database
$ mysql mysql> CREATE DATABASE metastore; mysql> USE metastore; mysql> CREATE USER 'hiveuser'@'localhost' IDENTIFIED BY 'password'; mysql> GRANT SELECT,INSERT,UPDATE,DELETE,ALTER,CREATE ON metastore.* TO 'hiveuser'@'localhost';
Copy hive-default-xml to hive-site.xml
$ cd /usr/local/Cellar/hive/2.7.1/libexec/conf $ cp hive-default.xml.template hive-site.xml
Edit following lines in hive-site.xml
<property> <name>javax.jdo.option.ConnectionURL</name> <value>jdbc:mysql://localhost/metastore</value> </property> <property> <name>javax.jdo.option.ConnectionDriverName</name> <value>com.mysql.jdbc.Driver</value> </property> <property> <name>javax.jdo.option.ConnectionUserName</name> <value>hiveuser</value> </property> <property> <name>javax.jdo.option.ConnectionPassword</name> <value>password</value> </property> <property> <name>datanucleus.fixedDatastore</name> <value>false</value> </property> <property> <name>hive.exec.local.scratchdir</name> <value>/tmp/hive</value> <description>Local scratch space for Hive jobs</description> </property> <property> <name>hive.downloaded.resources.dir</name> <value>/tmp/hive</value> <description>Temporary local directory for added resources in the remote file system.</description> </property> <property> <name>hive.querylog.location</name> <value>/tmp/hive</value> <description>Location of Hive run time structured log file</description> </property>
Run hive
$ hive hive > show tables;
Install Apache HBase on Mac
Prerequisite
Zookeeper: brew install zookeeper
To have launchd start zookeeper now and restart at login:
brew services start zookeeper
Or, if you don't want/need a background service you can just run:
==>Downloading from https://d29vzk4ow07wi7.cloudfront.net/c640eade77c3ad69fef4d66872bbccc2e8782fcd5beee84ecb6c5b7dbb28081b?response-content-disposition=attachment%3Bfilename%3D%22openjdk%4011-11.
==>Downloading from https://d29vzk4ow07wi7.cloudfront.net/b18c993c5f4bffe90725bec08d91869878ade5c407d51d93567fbbbd5a1754da?response-content-disposition=attachment%3Bfilename%3D%22hbase-2.3.2.cata
==>Successfully started `hbase` (label: homebrew.mxcl.hbase)
Validating Install
hbase shell
OpenJDK 64-Bit Server VM warning: Option UseConcMarkSweepGC was deprecated in version 9.0 and will likely be removed in a future release.
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hadoop/3.3.0/libexec/share/hadoop/common/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/Cellar/hbase/2.3.2/libexec/lib/client-facing-thirdparty/slf4j-log4j12-1.7.30.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]
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by org.apache.hadoop.hbase.util.UnsafeAvailChecker (file:/usr/local/Cellar/hbase/2.3.2/libexec/lib/hbase-common-2.3.2.jar) to method java.nio.Bits.unaligned()
WARNING: Please consider reporting this to the maintainers of org.apache.hadoop.hbase.util.UnsafeAvailChecker
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
2020-11-04 15:48:11,821 WARN[main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable
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.3.2, r8dc7de1c75ab615b8992b928150e8b476cb053e3, Sun Sep 20 13:28:26 UTC 2020
No comments:
Post a Comment