Commit 2de6c688 authored by gerd's avatar gerd

added


git-svn-id: https://gps.dynxs.de/private/svn/app-plasma/trunk@228 55289a75-7b90-4627-9e07-ffb4263930b2
parent e2acb109
#! /bin/sh
# Deploys software for an instance. Does NOT initialize databases, and
# does NOT initialize datanodes
usage () {
echo "usage: $0 inst_name" >&2
exit 2
}
inst=""
while [ $# -gt 0 ]; do
case "$1" in
-*)
usage ;;
*)
if [ -z "$inst" ]; then
inst="$1"
else
usage
fi
shift
esac
done
if [ -z "$inst" ]; then
echo "Error: missing instance";
usage
fi
if [ ! -d "instances/$inst" ]; then
echo "Error: no such instance: $inst" >&2
exit 2
fi
# Collect now all hosts from the .hosts files and form the union set:
hosts="$(awk '
/^[:blank:]*$/ { next }
/^[:blank:]*#/ { next }
/^\w+[:blank:]*#/ { hosts[$1]=1; next }
/^\w+[:blank:]*$/ { hosts[$1]=1; next }
// { print "bad line in " FILENAME ": " $0 >"/dev/stderr"; next }
END { for (host in hosts) { print host } }' \
instances/$inst/*.hosts)"
if [ $? -ne 0 ]; then
echo "Stopping after error" >&2
exit 2
fi
. "instances/$inst/global.conf"
na="$(which netplex-admin)"
if [ -z "$na" ]; then
echo "Error: netplex-admin not found in PATH"
fi
for host in $hosts; do
echo "Deploying to $host:"
ssh $host \
"mkdir -p '$prefix/bin' '$prefix/etc' '$prefix/log' '$prefix/data'"
scp instances/$inst/*.conf instances/$inst/*.hosts instances/$inst/*.sh \
$host:"$prefix/etc"
scp ../sql/namenode.sql $host:"$prefix/etc"
scp ../src/pfs_daemon/plasmad ../src/pfs_nfs3/nfs3d ../src/pfs_admin/plasma_datanode_init "$na" \
$host:"$prefix/bin"
done
#! /bin/sh
# Creates the PostgreSQL databases. It is required that the software
# is already deployed (deploy_inst.sh).
usage () {
echo "usage: $0 [-drop] inst_name" >&2
exit 2
}
inst=""
drop=0
while [ $# -gt 0 ]; do
case "$1" in
-drop)
drop=1; shift ;;
-*)
usage ;;
*)
if [ -z "$inst" ]; then
inst="$1"
else
usage
fi
shift
esac
done
if [ -z "$inst" ]; then
echo "Error: missing instance";
usage
fi
if [ ! -d "instances/$inst" ]; then
echo "Error: no such instance: $inst" >&2
exit 2
fi
# Collect now all namenode hosts from the .hosts files and form the union set:
hosts="$(awk '
/^[:blank:]*$/ { next }
/^[:blank:]*#/ { next }
/^\w+[:blank:]*#/ { hosts[$1]=1; next }
/^\w+[:blank:]*$/ { hosts[$1]=1; next }
// { print "bad line in " FILENAME ": " $0 >"/dev/stderr"; next }
END { for (host in hosts) { print host } }' \
instances/$inst/namenode.hosts)"
if [ $? -ne 0 ]; then
echo "Stopping after error" >&2
exit 2
fi
. "instances/$inst/global.conf"
for host in $hosts; do
if [ $drop -gt 0 ]; then
echo "Dropping database plasma_$inst on $host:"
ssh $host dropdb "plasma_$inst"
else
echo "Creating database plasma_$inst on $host:"
ssh $host createdb "plasma_$inst"
ssh $host psql "plasma_$inst" "-f '$prefix/etc/namenode.sql'" -q 2>&1 |
grep -v NOTICE
fi
echo " done"
done
#! /bin/sh
# Initializes datanode space
#
# For this, the software must already deployed (deploy_inst.sh), and
# the namenode daemon must already run (rc_nn.sh)
usage () {
echo "usage: $0 inst_name size[KMG] (host host ... | all)" >&2
exit 2
}
inst=""
size=""
hosts=""
all_hosts=0
while [ $# -gt 0 ]; do
case "$1" in
-*)
usage ;;
*)
if [ -z "$inst" ]; then
inst="$1"
elif [ -z "$size" ]; then
size="$1"
elif [ "$1" = "all" ]; then
all_hosts=1
else
hosts="$hosts $1"
fi
shift
esac
done
if [ -z "$inst" ]; then
echo "Error: missing instance";
usage
fi
if [ -z "$size" ]; then
echo "Error: missing size parameter";
usage
fi
if [ -z "$hosts" -a $all_hosts = 0 ]; then
echo "Error: no hosts"
usage
fi
if [ ! -d "instances/$inst" ]; then
echo "Error: no such instance: $inst" >&2
exit 2
fi
. "instances/$inst/global.conf"
# Check/translate size:
b="$(echo "$size" | sed -e 's/^[0-9]\+[KMG]\?$//')"
if [ -n "$b" ]; then
echo "Error: size must be a number, optionally followed by K, M, G" >&2
exit 2
fi
case "$size" in
*K)
size="$(echo "$size" | sed -e 's/K//')"
size="$(echo "$size * 1024" | bc)" ;;
*M)
size="$(echo "$size" | sed -e 's/M//')"
size="$(echo "$size * 1048576" | bc)" ;;
*G)
size="$(echo "$size" | sed -e 's/G//')"
size="$(echo "$size * 1073741824" | bc)" ;;
esac
blocks="(echo "$size / $blocksize" | bc)"
echo "Using $blocks blocks"
if [ $all_hosts -gt 0 ]; then
hosts="$(awk '
/^[:blank:]*$/ { next }
/^[:blank:]*#/ { next }
/^\w+[:blank:]*#/ { hosts[$1]=1; next }
/^\w+[:blank:]*$/ { hosts[$1]=1; next }
// { print "bad line in " FILENAME ": " $0 >"/dev/stderr"; next }
END { for (host in hosts) { print host } }' \
instances/$inst/datanode.hosts)"
if [ $? -ne 0 ]; then
echo "Stopping after error" >&2
exit 2
fi
fi
# TODO
nn=XXX
for host in $hosts; do
echo "Initializing on $host:"
ssh $host \
"$prefix/bin/plasma_datanode_init $prefix/data $blocks"
id="$(ssh $host head -1 $prefix/data/config)"
echo " adding identity to namenode"
../src/pfs_admin/plasma_admin \
add_datanode -namenode $nn -size $blocks $id
echo " enabling"
../src/pfs_admin/plasma_admin \
enable_datanode -namenode $nn $id $host:2728
# FIXME: dn port number should be configurable
done
(* -*- tuareg -*- *)
netplex {
controller {
socket_directory = "/tmp/plasma_dn_<INST>";
max_level = "debug"; (* Log level *)
logging {
type = "multi_file";
directory = "<PREFIX>/log";
file {
file = "datanode_debug.log";
component = "*";
max_level = "debug";
};
file {
file = "datanode_info.log";
component = "*";
max_level = "info";
};
file {
file = "datanode_crit.log";
component = "*";
max_level = "crit";
};
}
};
datanode {
clustername="<INST>";
directory = "<PREFIX>/data";
blocksize = <BLOCKSIZE>;
io_processes = 16;
shm_queue_length = 128;
sync_period = 1.0;
};
service {
name = "Dn_manager";
protocol {
name = "RPC";
address {
type = "internet";
bind = "0.0.0.0:2728"
};
address {
type = "local";
path = "/tmp/plasma_dn_<INST>/dn_manager.rpc"
}
};
processor {
type = "dn_manager";
};
workload_manager {
type = "constant";
threads = 1;
};
};
}
# Add here the host names of the machines that are going to be
# data nodes. One host name per line.
# Some global configs for this instance. (Shell-sourcable)
# inst=
# prefix=
# blocksize=
(* -*- tuareg -*- *)
netplex {
controller {
socket_directory = "/tmp/plasma_nn_<INST>";
max_level = "debug"; (* Log level *)
logging {
type = "multi_file";
directory = "<PREFIX>/log";
file {
file = "namenode_debug.log";
component = "*";
max_level = "debug";
};
file {
file = "namenode_info.log";
component = "*";
max_level = "info";
};
file {
file = "namenode_crit.log";
component = "*";
max_level = "crit";
};
}
};
database {
dbname = "plasma_<INST>"
};
namenodes {
clustername="<INST>";
node_list = "namenode.hosts";
port = 2730;
alive_min = 2;
replication = 2;
rank_script = "ip addr show label 'eth*' | grep link/ether | awk '{print $2}'";
elect_timeout = 60.0;
inodecache { port = 2740 };
};
datanodes {
node_list = "datanode.hosts";
port = 2728;
blocksize = <BLOCKSIZE>;
};
service {
name = "Nn_manager";
protocol {
name = "RPC";
address {
type = "internet";
bind = "0.0.0.0:2730"
};
address {
type = "local";
path = "/tmp/plasma_nn_<INST>/nn_manager.rpc";
};
};
processor {
type = "nn_manager";
};
workload_manager {
type = "constant";
threads = 1;
};
};
service {
name = "Nn_inodecache";
protocol {
name = "RPC";
address {
type = "internet";
bind = "0.0.0.0:2740"
};
address {
type = "container";
};
};
processor {
type = "nn_inodecache";
};
workload_manager {
type = "constant";
threads = 1;
};
};
}
# Add here the host names of the machines that are going to be
# name nodes. One host name per line.
# Add here the host names of the machines where you want nfs servers.
# One host name per line.
#! /bin/sh
# rc script for datanode start/stop
#! /bin/sh
thisdir="$(dirname "$0")"
. "$thisdir/global.conf"
descrname="Plasma namenode"
progname="plasmad"
logname="namenode"
sockdir="/tmp/plasma_nn_$inst"
conf="$prefix/etc/namenode.conf"
status() {
pid=`cat "$sockdir/pid" 2>/dev/null`
if kill -0 $pid 2>/dev/null; then
exe=`readlink /proc/$pid/exe | sed -e 's/ (deleted)$//'`
exe=`basename "$exe"`
if [ "X$exe" = "X$progname" ]; then
return 0
fi
fi
return 1
}
start() {
if status; then
echo `hostname`": $descrname already running"; exit 1
fi
mkdir -p "$sockdir"
$prefix/bin/$progname \
-pid "$sockdir/pid" \
-conf "$conf" \
2>>$prefix/log/${logname}_stderr.log
}
stop() {
if ! status; then
echo `hostname`": $descrname already running"; exit 1
fi
pid="$(cat "$sockdir/pid")"
$prefix/bin/netplex-admin -sockdir "$sockdir" -shutdown
# Wait until the process group vanishes:
n=0
while kill -0 -$pid 2>/dev/null; do
sleep 0.1
n=$((n+1))
if [ $n -eq 50 ]; then
echo `hostname`",$descrname: Killing processes (hard shutdown)" >&2
kill -15 $pid
fi
if [ $n -gt 600 ]; then break; fi
done
if [ $n -gt 600 ]; then
echo `hostname`": Timing out shutdown of $descrname" >&2
exit 1
fi
}
case "$1" in
start)
start ;;
stop)
stop ;;
status)
status ;;
*)
echo "$0 (start|stop|status)" ;;
esac
# Add here the host names of the machines that are going to be
# task nodes. One host name per line. (You can also make this file
# a symlink to datanode.hosts)
#! /bin/sh
# Creates a new instance in the "instances/" subdirectory.
usage () {
echo "usage: $0 [-template templ_name] inst_name prefix blocksize[KM]" >&2
exit 2
}
template="template"
inst=""
prefix=""
blocksize=""
while [ $# -gt 0 ]; do
case "$1" in
-template)
template="$2"
shift 2 ;;
-*)
usage ;;
*)
if [ -z "$inst" ]; then
inst="$1"
elif [ -z "$prefix" ]; then
prefix="$1"
elif [ -z "$blocksize" ]; then
blocksize="$1"
else
usage
fi
shift
esac
done
if [ -z "$inst" ]; then
echo "Error: missing instance";
usage
fi
if [ -z "$prefix" ]; then
echo "Error: missing prefix";
usage
fi
if [ -z "$blocksize" ]; then
echo "Error: missing blocksize";
usage
fi
# Check validity of instance:
s="$(echo "$inst" | tr -d a-zA-Z0-9_)"
if [ -n "$s" ]; then
echo "Error: instance name must only consist of alphanumeric chars and _" >&2
exit 2
fi
# Check validity of prefix:
case "$prefix" in
/*) true ;;
*) echo "Error: prefix must start with /" >&2; exit 2 ;;
esac
# Check/translate blocksize:
b="$(echo "$blocksize" | sed -e 's/^[0-9]\+[KM]\?$//')"
if [ -n "$b" ]; then
echo "Error: blocksize must be a number, optionally followed by K or M" >&2
exit 2
fi
case "$blocksize" in
*K)
blocksize="$(echo "$blocksize" | sed -e 's/K//')"
blocksize="$(echo "$blocksize * 1024" | bc)" ;;
*M)
blocksize="$(echo "$blocksize" | sed -e 's/M//')"
blocksize="$(echo "$blocksize * 1048576" | bc)" ;;
esac
code="$(echo "$blocksize > 67108864" | bc)"
if [ $code = 1 ]; then
echo "Error: blocksize is limited to 64M" >&2
exit 2
fi
m="$(echo "$blocksize % 4096" | bc)"
if [ $m != 0 ]; then
echo "Error: blocksize is not a multiple of 4096" >&2
exit 2
fi
echo "Creating new instance:"
echo "Name: $inst"
echo "Prefix: $prefix"
echo "Blocksize: $blocksize"
echo "Template: $template"
mkdir -p instances/$inst
for f in namenode.hosts datanode.hosts tasknode.hosts nfsnode.hosts global.conf rc_dn.sh rc_nn.sh rc_nfsd.sh; do
cp -p "instances/$template/$f" "instances/$inst/$f"
done
for f in namenode.conf datanode.conf; do
sed -e 's/<INST>/'$inst'/g' \
-e 's|<PREFIX>|'$prefix'|g' \
-e 's/<BLOCKSIZE>/'$blocksize'/g' \
"instances/$template/$f" > "instances/$inst/$f"
done
echo "inst=\"$inst\"" >> instances/$inst/global.conf
echo "prefix=\"$prefix\"" >> instances/$inst/global.conf
echo "blocksize=$blocksize" >> instances/$inst/global.conf
echo "Done"
#! /bin/sh
# Start/stop namenodes
usage () {
echo "usage: $0 (start|stop|status) inst_name" >&2
exit 2
}
op=""
inst=""
while [ $# -gt 0 ]; do
case "$1" in
-*)
usage ;;
*)
if [ -z "$op" ]; then
op="$1"
elif [ -z "$inst" ]; then
inst="$1"
else
usage
fi
shift
esac
done
if [ -z "$op" ]; then
echo "Error: missing operation";
usage
fi
case "$op" in
start|stop|status) true ;;
*)
echo "Error: bad operation: $op" >&2
exit 2 ;;
esac
if [ -z "$inst" ]; then
echo "Error: missing instance";
usage
fi
if [ ! -d "instances/$inst" ]; then
echo "Error: no such instance: $inst" >&2
exit 2
fi
# Collect now all hosts from the .hosts files and form the union set:
hosts="$(awk '
/^[:blank:]*$/ { next }
/^[:blank:]*#/ { next }
/^\w+[:blank:]*#/ { hosts[$1]=1; next }
/^\w+[:blank:]*$/ { hosts[$1]=1; next }
// { print "bad line in " FILENAME ": " $0 >"/dev/stderr"; next }
END { for (host in hosts) { print host } }' \
instances/$inst/namenode.hosts)"
if [ $? -ne 0 ]; then
echo "Stopping after error" >&2
exit 2
fi
. "instances/$inst/global.conf"
for host in $hosts; do
printf "$host: "
ssh $host "$prefix/etc/rc_nn.sh $op"
if [ $? -eq 0 ]; then
echo "ok"
else
echo "error"
fi
done
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment