You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@bigtop.apache.org by co...@apache.org on 2014/04/25 01:05:15 UTC
[06/50] git commit: HAD-619. SecondaryNameNode checkpoint deamon
installed as an RPM
HAD-619. SecondaryNameNode checkpoint deamon installed as an RPM
Project: http://git-wip-us.apache.org/repos/asf/bigtop/repo
Commit: http://git-wip-us.apache.org/repos/asf/bigtop/commit/4e74d706
Tree: http://git-wip-us.apache.org/repos/asf/bigtop/tree/4e74d706
Diff: http://git-wip-us.apache.org/repos/asf/bigtop/diff/4e74d706
Branch: refs/heads/master
Commit: 4e74d706a5743e90a86b3d26de34fe3edd768944
Parents: c7a1abc
Author: Konstantin Boudnik <co...@wandisco.com>
Authored: Thu Oct 24 17:58:14 2013 -0700
Committer: Konstantin Boudnik <co...@wandisco.com>
Committed: Mon Oct 28 19:23:54 2013 -0700
----------------------------------------------------------------------
.../hadoop-hdfs-nonstop-checkpoints.default | 30 ++++++
.../hadoop-hdfs-nonstop-checkpoints.svc | 24 +++++
.../secondary-nonstop-daemon.sh | 107 +++++++++++++++++++
.../secondary-nonstop-loop.sh | 36 +++++++
.../SPECS/wdd-namenode-nonstop.spec | 54 +++++++++-
5 files changed, 247 insertions(+), 4 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/bigtop/blob/4e74d706/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.default
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.default b/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.default
new file mode 100644
index 0000000..93b8e9e
--- /dev/null
+++ b/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.default
@@ -0,0 +1,30 @@
+# 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.
+export HADOOP_HOME_WARN_SUPPRESS=true
+export HADOOP_HOME=/usr/lib/hadoop
+export HADOOP_PREFIX=/usr/lib/hadoop
+export HADOOP_LIBEXEC_DIR=/usr/lib/hadoop/libexec
+
+export HADOOP_COMMON_HOME=/usr/lib/hadoop
+export HADOOP_HDFS_HOME=/usr/lib/hadoop-hdfs
+
+export HADOOP_CONF_DIR=/etc/hadoop/conf
+export HADOOP_CHECKPOINTS_CONFIGS=/etc/hadoop/checkpoints.nonstop
+export HADOOP_PID_DIR=/var/run/hadoop-hdfs
+export HADOOP_LOG_DIR=/var/log/hadoop-hdfs
+export HADOOP_NAMENODE_USER=hdfs
+export HADOOP_SECONDARYNAMENODE_USER=hdfs
+export HADOOP_DATANODE_USER=hdfs
+export HADOOP_IDENT_STRING=hdfs
http://git-wip-us.apache.org/repos/asf/bigtop/blob/4e74d706/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.svc
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.svc b/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.svc
new file mode 100644
index 0000000..5b7b7de
--- /dev/null
+++ b/bigtop-packages/src/common/wdd-namenode-nonstop/hadoop-hdfs-nonstop-checkpoints.svc
@@ -0,0 +1,24 @@
+# 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.
+HADOOP_NAME="nonstop-checkpoints"
+DAEMON="hadoop-hdfs-$HADOOP_NAME"
+DESC="Hadoop namenode $HADOOP_NAME "
+EXEC_PATH="/usr/lib/hadoop/sbin/secondary-nonstop-daemon.sh"
+SVC_USER="hdfs"
+DAEMON_FLAGS=""
+CONF_DIR="/etc/hadoop/checkpoints.nonstop"
+PIDFILE="/var/run/hadoop-hdfs/hadoop-$SVC_USER-$HADOOP_NAME.pid"
+LOCKDIR="/var/lock/subsys"
+LOCKFILE="hadoop-$HADOOP_NAME"
http://git-wip-us.apache.org/repos/asf/bigtop/blob/4e74d706/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-daemon.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-daemon.sh b/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-daemon.sh
new file mode 100755
index 0000000..52cdb04
--- /dev/null
+++ b/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-daemon.sh
@@ -0,0 +1,107 @@
+#!/bin/bash
+# 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.
+
+usage="Usage: secondary-nonstop-daemon.sh --config CONF_DIR (start|stop)"
+
+# if no args specified, show usage
+if [ $# -le 1 ]; then
+ echo $usage
+ exit 1
+fi
+
+if [ -f /etc/default/hadoop-hdfs-nonstop-checkpoints ] ; then
+ . /etc/default/hadoop-hdfs-nonstop-checkpoints
+fi
+
+if [ -f "${HADOOP_CONF_DIR}/hadoop-env.sh" ]; then
+ . "${HADOOP_CONF_DIR}/hadoop-env.sh"
+fi
+
+if [ "$HADOOP_IDENT_STRING" = "" ]; then
+ export HADOOP_IDENT_STRING="$USER"
+fi
+
+#HADOOP_CHECKPOINTS_CONFIGS is coming from the default above
+STOP_TIMEOUT=5
+command=nonstop-checkpoints
+log=$HADOOP_LOG_DIR/hadoop-$HADOOP_IDENT_STRING-$command-$HOSTNAME.out
+pid=$HADOOP_PID_DIR/hadoop-$HADOOP_IDENT_STRING-$command.pid
+
+if [ "--config" = "$1" ]
+ then
+ shift
+ config=$1
+ shift
+fi
+startStop=$1
+
+rotate_log ()
+{
+ log=$1;
+ num=5;
+ if [ -n "$2" ]; then
+ num=$2
+ fi
+ if [ -f "$log" ]; then # rotate logs
+ while [ $num -gt 1 ]; do
+ prev=`expr $num - 1`
+ [ -f "$log.$prev" ] && mv "$log.$prev" "$log.$num"
+ num=$prev
+ done
+ mv "$log" "$log.$num";
+ fi
+}
+
+case $startStop in
+
+ (start)
+ rotate_log $log
+ echo starting $command, logging to $log
+ nohup $HADOOP_HOME/sbin/secondary-nonstop-loop.sh > "$log" 2>&1 < /dev/null &
+ echo $! > $pid
+ sleep 1
+ head "$log"
+ if ! ps -p $! > /dev/null ; then
+ exit 1
+ fi
+ ;;
+
+ (stop)
+ if [ -f $pid ]; then
+ TARGET_PID=`cat $pid`
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ echo stopping $command
+ kill $TARGET_PID
+ sleep $STOP_TIMEOUT
+ if kill -0 $TARGET_PID > /dev/null 2>&1; then
+ echo "$command did not stop gracefully after $STOP_TIMEOUT seconds: killing with kill -9"
+ kill -9 $TARGET_PID
+ fi
+ else
+ echo no $command to stop
+ fi
+ else
+ echo no $command to stop
+ fi
+ ;;
+
+ (*)
+ echo $usage
+ exit 1
+ ;;
+
+esac
+
http://git-wip-us.apache.org/repos/asf/bigtop/blob/4e74d706/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-loop.sh
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-loop.sh b/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-loop.sh
new file mode 100644
index 0000000..e18c18a
--- /dev/null
+++ b/bigtop-packages/src/common/wdd-namenode-nonstop/secondary-nonstop-loop.sh
@@ -0,0 +1,36 @@
+#!/bin/bash
+# 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.
+
+## This script isn't supposed to be called without secondary-nonstop-daemon service
+while true; do
+ NNLIST=$(find ${HADOOP_CHECKPOINTS_CONFIGS} -mindepth 1 -type d | sort)
+
+ for nsnode in ${NNLIST[@]}; do
+ FSIMAGEDIR=$(hdfs --config $nsnode getconf -confKey dfs.namenode.checkpoint.dir)
+ echo Removing previous FSImage and Editlogs from ${FSIMAGEDIR}
+ if [ "x$FSIMAGEDIR" != "x" ]; then
+ rm -rf ${FSIMAGEDIR}/*
+ else
+ echo "FSIMAGEDIR couldn't be determined"
+ exit 1
+ fi
+ echo Checkpointing against ConsensusNode configured in $nsnode
+ hdfs --config $nsnode secondarynamenode -checkpoint force
+ PERIOD=$(hdfs --config $nsnode getconf -confKey dfs.namenode.checkpoint.period)
+ echo Sleeping for dfs.namenode.checkpoint.period set in $nsnode: ${PERIOD}s
+ sleep ${PERIOD}s
+ done
+done
http://git-wip-us.apache.org/repos/asf/bigtop/blob/4e74d706/bigtop-packages/src/rpm/wdd-namenode-nonstop/SPECS/wdd-namenode-nonstop.spec
----------------------------------------------------------------------
diff --git a/bigtop-packages/src/rpm/wdd-namenode-nonstop/SPECS/wdd-namenode-nonstop.spec b/bigtop-packages/src/rpm/wdd-namenode-nonstop/SPECS/wdd-namenode-nonstop.spec
index a75ce99..8d2cc27 100644
--- a/bigtop-packages/src/rpm/wdd-namenode-nonstop/SPECS/wdd-namenode-nonstop.spec
+++ b/bigtop-packages/src/rpm/wdd-namenode-nonstop/SPECS/wdd-namenode-nonstop.spec
@@ -11,6 +11,8 @@ Source1: do-component-build
Source3: hadoop-hdfs-nonstop.default
Source11: init.d.tmpl
Source12: hadoop-hdfs-nonstop.svc
+Source14: secondary-nonstop-daemon.sh
+Source15: secondary-nonstop-loop.sh
Source22: nonstop
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
@@ -28,9 +30,10 @@ AutoReq: no
%define lib_hadoop %{lib_hadoop_dirname}/hadoop
%define lib_hdfs %{lib_hadoop_dirname}/hadoop-hdfs
%define hadoop_name nonstop
-%define hadoop_services hadoop-hdfs-nonstop
+%define hadoop_services hadoop-hdfs-nonstop hadoop-hdfs-nonstop-checkpoints
%define extra_libs DConE-*.jar DConE_Platform-*.jar
%define extra_deps_libs java-uuid-generator*.jar prevayler-*.jar xstream-*.jar bcprov*.jar xmlpull-*.jar
+%define conf_checkpoints %{etc_hadoop}/checkpoints.nonstop
%global initd_dir %{_sysconfdir}/rc.d/init.d
@@ -38,6 +41,14 @@ AutoReq: no
WANdisco Non-Stop namenode with full replication for hdfs via our patented
Dcone PAXOS replication technology.
+%package checkpoints
+Summary: Non-Stop HDFS namenode checkpoint daemon
+Group: System/Daemons
+Requires: hadoop-hdfs-secondarynamenode, /sbin/chkconfig, /sbin/service
+
+%description checkpoints
+A service daemon for check-pointing of all instances of WANdisco Non-Stop namenode
+
%prep
%setup -n %{artifactname}-%{wdd_namenode_nonstop_base_version}
@@ -55,6 +66,9 @@ rm -rf $RPM_BUILD_ROOT
%__install -m 0644 $RPM_SOURCE_DIR/conf.nonstop/* $RPM_BUILD_ROOT/%{conf_nonstop}/
%__install -d -m 0755 $RPM_BUILD_ROOT/%{conf_dcone}/
%__install -m 0644 $RPM_SOURCE_DIR/wandisco/* $RPM_BUILD_ROOT/%{conf_dcone}/
+## secondary check-pointing
+%__install -m 0755 %{SOURCE14} $RPM_BUILD_ROOT/%{lib_hadoop}/sbin
+%__install -m 0755 %{SOURCE15} $RPM_BUILD_ROOT/%{lib_hadoop}/sbin
## Product specific lib
%__install -m 0644 target/%{artifactname}-%{wdd_namenode_nonstop_base_version}.jar $RPM_BUILD_ROOT/%{lib_hdfs}
@@ -73,6 +87,9 @@ done
# Install top level /etc/default files
%__install -d -m 0755 $RPM_BUILD_ROOT/etc/default
%__cp $RPM_SOURCE_DIR/hadoop-hdfs-nonstop.default $RPM_BUILD_ROOT/etc/default/hadoop-hdfs-nonstop
+## secondary check-pointing
+%__install -d -m 0755 $RPM_BUILD_ROOT/%{conf_checkpoints}
+%__cp $RPM_SOURCE_DIR/hadoop-hdfs-nonstop-checkpoints.default $RPM_BUILD_ROOT/etc/default/hadoop-hdfs-nonstop-checkpoints
# Generate the init.d scripts
for service in %{hadoop_services}
@@ -96,7 +113,7 @@ rm -rf $RPM_BUILD_ROOT
sed -e 's#namenode|secondarynamenode|datanode|journalnode|dfs|dfsadmin|fsck|balancer|zkfc)#nonstop|wan)#' -e 's#hdfsScript="$HADOOP_PREFIX"/bin/hdfs#hdfsScript="$HADOOP_PREFIX"/bin/nonstop#' -e 's#hdfsScript="$HADOOP_HDFS_HOME"/bin/hdfs#hdfsScript="$HADOOP_HDFS_HOME"/bin/nonstop#' %{lib_hadoop}/sbin/hadoop-daemon.sh > %{lib_hadoop}/sbin/hadoop-nonstop-daemon.sh
%__chmod 755 %{lib_hadoop}/sbin/hadoop-nonstop-daemon.sh
-for service in %{hadoop_services}
+for service in hadoop-hdfs-nonstop
do
if [ $1 -ge 1 ]; then
chkconfig --add ${service}
@@ -105,7 +122,7 @@ do
done
%preun
-for service in %{hadoop_services}
+for service in hadoop-hdfs-nonstop
do
if [ $1 -eq 0 ]; then
service ${service} stop > /dev/null 2>&1
@@ -114,6 +131,26 @@ do
fi
done
+%post checkpoints
+for service in hadoop-hdfs-nonstop-checkpoints
+do
+ if [ $1 -ge 1 ]; then
+ chkconfig --add ${service}
+ chkconfig hadoop-hdfs-secondarynamenode off
+ fi
+done
+
+%preun checkpoints
+## Removing the link setup in the %post phase and moving HDFS NN script back
+for service in hadoop-hdfs-nonstop-checkpoints
+do
+ if [ $1 -eq 0 ]; then
+ service ${service} stop > /dev/null 2>&1
+ chkconfig --del ${service}
+ chkconfig hadoop-hdfs-secondarynamenode on
+ fi
+done
+
%postun
for service in %{hadoop_services}
do
@@ -125,7 +162,6 @@ done
%files
%defattr(-,root,root)
%{lib_hdfs}
-%{initd_dir}
%{initd_dir}/hadoop-hdfs-nonstop
/etc/default/hadoop-hdfs-nonstop
%attr(0755,root,root)
@@ -137,7 +173,17 @@ done
%config(noreplace) %{etc_hadoop}/conf.nonstop/log4j.properties
+%files checkpoints
+%{lib_hadoop}/sbin/secondary-nonstop-daemon.sh
+%{lib_hadoop}/sbin/secondary-nonstop-loop.sh
+%{initd_dir}/hadoop-hdfs-nonstop-checkpoints
+/etc/default/hadoop-hdfs-nonstop-checkpoints
+%{conf_checkpoints}
+
%changelog
+* Thu Oct 24 2013 Konstantin Boudnik <co...@wandisco.com>
+- Adding checkpointing daemon to save checkpoints from all
+ non-stop namenodes, using secondarynamenode mechanism
* Thu Apr 29 2013 Konstantin Boudnik <co...@wandisco.com>
- Adding default dcone property files and logger
- fixing the problem where some jar files weren't picked up