Skip to content
Snippets Groups Projects
Commit 1d9582cc authored by Dmitry Simonenko's avatar Dmitry Simonenko
Browse files

rpm installation support and tarantool_topology.sh script

parent 3f255456
No related merge requests found
#!/bin/sh
echo "creating user and group"
groupadd tarantool
useradd -r -g tarantool tarantool
echo "making single instance setup"
/usr/local/bin/tarantool_topology.sh -y 1
......@@ -11,6 +11,7 @@ if ("${CPACK_GENERATOR}" STREQUAL "RPM")
set (CPACK_RPM_PACKAGE_LICENSE "BSD")
set (CPACK_RPM_PACKAGE_GROUP "MAIL.RU")
set (CPACK_RPM_PACKAGE_DESCRIPTION "Tarantool in-memory DB storage")
set (CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_SOURCE_DIR}/cmake/rpm_post_install.sh")
set (CPACK_SET_DESTDIR "ON")
set (CPACK_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
else()
......
......@@ -2,16 +2,22 @@
# scripts for RPM package
#
if ("${CPACK_GENERATOR}" STREQUAL "RPM")
# chmod +x 655
install (FILES tarantool_box DESTINATION etc/init.d
PERMISSIONS
# chmod +x 655
install (FILES tarantool DESTINATION /etc/init.d
PERMISSIONS
OWNER_READ OWNER_WRITE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# chmod +x 755
install (FILES tarantool_box.sh DESTINATION bin
# chmod +x 755
install (FILES tarantool_multi.sh DESTINATION bin
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
# chmod +x 755
install (FILES tarantool_topology.sh DESTINATION bin
PERMISSIONS
OWNER_READ OWNER_WRITE OWNER_EXECUTE
OWNER_READ OWNER_WRITE OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE)
endif()
......@@ -15,7 +15,7 @@ export WRAP_PIDFILE="/var/${INST}/wrapper.pid"
export OPTIONS=""
# We must not run immediate!
if [ "${INST}" == "tarantool_box" ]
if [ "${INST}" == "tarantool" ]
then
echo_failure
echo
......@@ -75,4 +75,3 @@ case "$1" in
esac
exit ${RETVAL}
......@@ -7,7 +7,7 @@ BINARY="/usr/local/bin/${NAME}"
INST=$(basename $0 .sh)
CONF="/usr/local/etc/${INST}.cfg"
LOGDIR="/var/${INST}/logs"
CRONOLOG="/usr/sbin/cronolog"
WRAP_PIDFILE="/var/${INST}/wrapper.pid"
exec <&-
......@@ -18,7 +18,6 @@ report()
runtarantool()
{
ulimit -n 40960
${BINARY} ${OPTIONS} --config ${CONF} 2>&1 </dev/null &
wait
......
#!/bin/sh
#
# Tarantool DB topology setup script
#
topology_cfg='/usr/local/etc/tarantool_topology.cfg'
topology_exists=0
topology_count=0
prompt=1
ts=`/bin/date +"%Y%m%d-%H%M%S"`
if [ -f $topology_cfg ]; then
topology_exists=1
topology_count=`cat $topology_cfg`
# dont' change topology if it said so in configuration file
if [ $topology_count -eq 0 ]; then
echo "skipping topology setup"
exit 0
fi
fi
usage() {
echo "Tarantool DB topology setup script"
echo
echo "usage: tarantool_topology.sh [-y] <servers>"
exit 0
}
# processing command line arguments
#
num=0
if [ $# -eq 2 ]; then
if [ "$1" != "-y" ]; then
usage
fi
prompt=0
num=$2
else
if [ $# -ne 1 ]; then
usage
fi
num=$1
fi
# validating instance number
#
isnum=0
if [ $num -eq $num 2> /dev/null ]; then
isnum=1
fi
if [ $isnum -eq 0 ] || [ $num -eq 0 2> /dev/null ]; then
echo bad instance number
exit 1
fi
# asking permission to continue
#
if [ $prompt -eq 1 ]; then
echo "About to create new Tarantool DB topology for $num instances."
if [ $topology_exists -eq 1 ]; then
echo "Old data and configuration will be saved with $ts time-stamp prefix."
fi
echo "Are you sure? [n/y]"
read answer
case "$answer" in
[Yy]) ;;
*)
echo "aborting"
exit 0
;;
esac
fi
backup_instance() {
id=$1
workdir="/var/tarantool$id"
workdir_new="/var/tarantool${id}_${ts}"
config="/usr/local/etc/tarantool$id.cfg"
config_new="/usr/local/etc/tarantool${id}-${ts}.cfg"
echo ">> making instance $id backup"
# moving old instance directory
mv $workdir $workdir_new
# moving old configuration file
mv $config $config_new
# removving startup and wrapper links
rm -f "/etc/init.d/tarantool$id"
rm -f "/usr/local/bin/tarantool$id.sh"
}
backup() {
echo "making backup for $topology_count instances"
to=$(( $topology_count - 1 ))
for instance in `seq 0 $to`; do
backup_instance $instance
done
}
if [ $topology_exists -eq 1 ]; then
backup
fi
topology_count=$num
deploy_instance() {
id=$1
workdir="/var/tarantool$id"
config="/usr/local/etc/tarantool$id.cfg"
echo ">> deploying instance $id"
# setting up work environment
mkdir $workdir
mkdir $workdir/logs
chown tarantool:tarantool -R $workdir
# setting up startup snapshot
cp "/usr/local/share/tarantool/00000000000000000001.snap" $workdir
# setting up configuration file
cp "/usr/local/etc/tarantool.cfg" $config
echo "work_dir = \"$workdir\"" >> $config
echo "username = \"tarantool\"" >> $config
echo "logger = \"cat - >> logs/tarantool.log\"" >> $config
# setting up wrapper
ln -s "/usr/local/bin/tarantool_multi.sh" "/usr/local/bin/tarantool$id.sh"
# setting up startup script
ln -s "/etc/init.d/tarantool" "/etc/init.d/tarantool$id"
}
deploy() {
to=$(( $topology_count - 1 ))
for instance in `seq 0 $to`; do
deploy_instance $instance
done
}
update() {
echo "updating topology config"
echo $topology_count > $topology_cfg
}
deploy
update
echo done
......@@ -5,7 +5,14 @@ add_custom_target(test
tarantool_client("box/protocol" ${CMAKE_SOURCE_DIR}/test/box/protocol.c)
tarantool_client("connector_c/tt" ${CMAKE_SOURCE_DIR}/test/connector_c/tt.c)
install (FILES ${CMAKE_SOURCE_DIR}/test/box/tarantool.cfg
DESTINATION bin)
install (FILES ${CMAKE_SOURCE_DIR}/test/box/00000000000000000001.snap
DESTINATION bin)
if ("${CPACK_GENERATOR}" STREQUAL "RPM")
install (FILES ${CMAKE_SOURCE_DIR}/test/box/tarantool.cfg
DESTINATION etc)
install (FILES ${CMAKE_SOURCE_DIR}/test/box/00000000000000000001.snap
DESTINATION share/tarantool)
else()
install (FILES ${CMAKE_SOURCE_DIR}/test/box/tarantool.cfg
DESTINATION bin)
install (FILES ${CMAKE_SOURCE_DIR}/test/box/00000000000000000001.snap
DESTINATION bin)
endif()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment