mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-02 22:25:48 +00:00
To reduce duplicated code and simplified scripts introduce scylla_lib.sh for shellscripts which provides functions to classify distributions, and load all sysconfig files. This also fixes script bugs to misdetect Debian and RHEL. Signed-off-by: Takuya ASADA <syuu@scylladb.com> Message-Id: <1480667672-9453-2-git-send-email-syuu@scylladb.com>
82 lines
2.6 KiB
Bash
Executable File
82 lines
2.6 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
. /usr/lib/scylla/scylla_lib.sh
|
|
|
|
print_usage() {
|
|
echo "scylla_io_setup --ami"
|
|
echo " --ami setup AMI instance"
|
|
exit 1
|
|
}
|
|
|
|
AMI_OPT=0
|
|
while [ $# -gt 0 ]; do
|
|
case "$1" in
|
|
"--ami")
|
|
AMI_OPT=1
|
|
shift 1
|
|
;;
|
|
*)
|
|
print_usage
|
|
;;
|
|
esac
|
|
done
|
|
|
|
|
|
is_developer_mode() {
|
|
cat /etc/scylla.d/dev-mode.conf|egrep -c "\-\-developer-mode(\s+|=)(1|true)"
|
|
}
|
|
|
|
output_to_user()
|
|
{
|
|
echo "$1"
|
|
logger -p user.err "$1"
|
|
}
|
|
|
|
if [ `is_developer_mode` -eq 0 ]; then
|
|
SMP=`echo $CPUSET|grep smp|sed -e "s/^.*smp\(\s\+\|=\)\([^ ]*\).*$/\2/"`
|
|
CPUSET=`echo $CPUSET|grep cpuset|sed -e "s/^.*\(--cpuset\(\s\+\|=\)[^ ]*\).*$/\1/"`
|
|
if [ $AMI_OPT -eq 1 ]; then
|
|
NR_CPU=`cat /proc/cpuinfo |grep processor|wc -l`
|
|
NR_DISKS=`lsblk --list --nodeps --noheadings | grep -v xvda | grep xvd | wc -l`
|
|
TYPE=`curl http://169.254.169.254/latest/meta-data/instance-type|cut -d . -f 1`
|
|
|
|
if [ "$SMP" != "" ]; then
|
|
NR_CPU=$SMP
|
|
fi
|
|
NR_SHARDS=$NR_CPU
|
|
if [ $NR_CPU -ge 8 ] && [ "$SET_NIC" = "no" ]; then
|
|
NR_SHARDS=$((NR_CPU - 1))
|
|
fi
|
|
if [ $NR_DISKS -lt 2 ]; then NR_DISKS=2; fi
|
|
|
|
NR_REQS=$((32 * $NR_DISKS / 2))
|
|
|
|
NR_IO_QUEUES=$NR_SHARDS
|
|
if [ $(($NR_REQS/$NR_IO_QUEUES)) -lt 4 ]; then
|
|
NR_IO_QUEUES=$(($NR_REQS / 4))
|
|
fi
|
|
|
|
NR_IO_QUEUES=$((NR_IO_QUEUES>NR_SHARDS?NR_SHARDS:NR_IO_QUEUES))
|
|
NR_REQS=$(($(($NR_REQS / $NR_IO_QUEUES)) * $NR_IO_QUEUES))
|
|
if [ "$TYPE" = "i2" ]; then
|
|
NR_REQS=$(($NR_REQS * 2))
|
|
fi
|
|
|
|
echo "SEASTAR_IO=\"--num-io-queues $NR_IO_QUEUES --max-io-requests $NR_REQS\"" > /etc/scylla.d/io.conf
|
|
else
|
|
DATA_DIR=`/usr/lib/scylla/scylla_config_get.py --config $SCYLLA_CONF/scylla.yaml --get data_file_directories|head -n1`
|
|
IOTUNE_ARGS="$CPUSET"
|
|
if [ "$SMP" != "" ]; then
|
|
IOTUNE_ARGS="$IOTUNE_ARGS --smp $SMP"
|
|
fi
|
|
iotune --evaluation-directory $DATA_DIR --format envfile --options-file /etc/scylla.d/io.conf $IOTUNE_ARGS
|
|
if [ $? -ne 0 ]; then
|
|
output_to_user "/var/lib/scylla did not pass validation tests, it may not be on XFS and/or has limited disk space."
|
|
output_to_user "This is a non-supported setup, and performance is expected to be very bad."
|
|
output_to_user "For better performance, placing your data on XFS-formatted directories is required."
|
|
output_to_user "To override this error, enable developer mode as follow:"
|
|
output_to_user " sudo /usr/lib/scylla/scylla_dev_mode_setup --developer-mode 1"
|
|
fi
|
|
fi
|
|
fi
|