Hbase Learning Notes 1 Mui-simple summary of script
Recently, I have learned the relevant knowledge of hbase, and I have also taken a look at the scripts under hbase's bin/ directory. I don't understand many of the details of the scripts. I have an understanding of the general outline. Let's make a summary of the study:
. the "$bin" / hbase-config.sh calling script hbase-config.sh loads the relevant environment variables, and the hbase-config.sh script also calls the conf/hbase-env.sh script.
The script then starts different services by determining whether it is in distributed mode (and invokes the script hbase)
DistMode= `$ bin/hbase--config "$HBASE_CONF_DIR" org.apache.hadoop.hbase.util.HBa
SeConfToolhbase.cluster.distributed | head-n 1`
If ["$distMode" = = 'false']
Then
"$bin" / hbase-daemon.sh-- config "${HBASE_CONF_DIR}" start master / / if not in distributed mode, only start master
Else
"$bin" / hbase-daemons.sh-- config "${HBASE_CONF_DIR}" start zookeeper
"$bin" / hbase-daemon.sh-- config "${HBASE_CONF_DIR}" start master
"$bin" / hbase-daemons.sh-- config "${HBASE_CONF_DIR}"\
-- hosts "${HBASE_REGIONSERVERS}" start regionserver
"$bin" / hbase-daemons.sh-- config "${HBASE_CONF_DIR}"\
-- hosts "${HBASE_BACKUP_MASTERS}" start master-backup
Fi
As can be seen from the above script, starting master calls script hbase-daemon.sh, while starting zookeeper, regionserver, and master-backup services calls script hbase-daemons.sh.
At the same time, you can also see the startup sequence of each service in distributed mode:
(zookeeper,master,regionserver,master-backup)
In the hbase-daemons.sh script, you can see that three zookeepers.sh regionservers.sh master-backup.sh scripts are called to start the three zookeeper,regionserver,master-backup services.
Case $command in
(zookeeper)
Exec "$bin/zookeepers.sh" $args
(master-backup)
Exec "$bin/master-backup.sh" $args
(*)
Exec "$bin/regionservers.sh" $args
Esac
It is very simple and straightforward for hbase to stop the service. Kill-0 `cat $pid`, check the script stop-hbase.sh
You can see that the script hbase is called first:
Nohup nice-n ${HBASE_NICENESS:-0} "$HBASE_HOME" / bin/hbase\
-- config "${HBASE_CONF_DIR}"\
Master stop "$@" > "$logout" 2 > & 1 < / dev/null &
Then determine whether it is in distributed mode, and if so, stop the master-backup and zookeeper services by calling hbase-daemon.sh
If ["$distMode" = = 'true']
Then
# TODO: store backup mastersin ZooKeeper and have the primary send them a shu
Tdown message
# stop any backup masters
"$bin" / hbase-daemons.sh-- config "${HBASE_CONF_DIR}"\
-- hosts "${HBASE_BACKUP_MASTERS}" stop master-backup
"$bin" / hbase-daemons.sh-- config "${HBASE_CONF_DIR}" stop zookeeper
Fi