mirror of
https://github.com/scylladb/scylladb.git
synced 2026-05-12 19:02:12 +00:00
dist/common/scripts/scylla_ec2_check: support custom NIC ifname on EC2
This is bash version of commit 88fe3c2694.
Since some AMIs using consistent network device naming, primary NIC
ifname is not 'eth0'.
But we hardcoded NIC name as 'eth0' on scylla_ec2_check, we need to add
--nic option to specify custom NIC ifname.
Fixes #3658
Signed-off-by: Takuya ASADA <syuu@scylladb.com>
Message-Id: <20180807231650.13697-1-syuu@scylladb.com>
This commit is contained in:
2
dist/ami/files/.bash_profile
vendored
2
dist/ami/files/.bash_profile
vendored
@@ -120,7 +120,7 @@ else
|
||||
fi
|
||||
fi
|
||||
echo -n " "
|
||||
/usr/lib/scylla/scylla_ec2_check
|
||||
/usr/lib/scylla/scylla_ec2_check --nic eth0
|
||||
if [ $? -eq 0 ]; then
|
||||
echo
|
||||
fi
|
||||
|
||||
30
dist/common/scripts/scylla_ec2_check
vendored
30
dist/common/scripts/scylla_ec2_check
vendored
@@ -2,6 +2,12 @@
|
||||
|
||||
. /usr/lib/scylla/scylla_lib.sh
|
||||
|
||||
print_usage() {
|
||||
echo "scylla_ec2_check --nic eth0"
|
||||
echo " --nic specify NIC"
|
||||
exit 1
|
||||
}
|
||||
|
||||
get_en_interface_type() {
|
||||
TYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type|cut -d . -f 1`
|
||||
SUBTYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type|cut -d . -f 2`
|
||||
@@ -18,7 +24,7 @@ get_en_interface_type() {
|
||||
}
|
||||
|
||||
is_vpc_enabled() {
|
||||
MAC=`cat /sys/class/net/eth0/address`
|
||||
MAC=`cat /sys/class/net/$1/address`
|
||||
VPC_AVAIL=`curl -s http://169.254.169.254/latest/meta-data/network/interfaces/macs/$MAC/|grep vpc-id`
|
||||
[ -n "$VPC_AVAIL" ]
|
||||
}
|
||||
@@ -27,9 +33,27 @@ if ! is_ec2; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 ]; then
|
||||
print_usage
|
||||
fi
|
||||
while [ $# -gt 0 ]; do
|
||||
case "$1" in
|
||||
"--nic")
|
||||
verify_args $@
|
||||
NIC="$2"
|
||||
shift 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if ! is_valid_nic $NIC; then
|
||||
echo "NIC $NIC doesn't exist."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TYPE=`curl -s http://169.254.169.254/latest/meta-data/instance-type`
|
||||
EN=`get_en_interface_type`
|
||||
DRIVER=`ethtool -i eth0|awk '/^driver:/ {print $2}'`
|
||||
DRIVER=`ethtool -i $NIC|awk '/^driver:/ {print $2}'`
|
||||
if [ "$EN" = "" ]; then
|
||||
tput setaf 1
|
||||
tput bold
|
||||
@@ -39,7 +63,7 @@ if [ "$EN" = "" ]; then
|
||||
echo "More documentation available at: "
|
||||
echo "http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/enhanced-networking.html#enabling_enhanced_networking"
|
||||
exit 1
|
||||
elif ! is_vpc_enabled; then
|
||||
elif ! is_vpc_enabled $NIC; then
|
||||
tput setaf 1
|
||||
tput bold
|
||||
echo "VPC is not enabled!"
|
||||
|
||||
4
dist/common/scripts/scylla_lib.sh
vendored
4
dist/common/scripts/scylla_lib.sh
vendored
@@ -91,6 +91,10 @@ create_perftune_conf() {
|
||||
/usr/lib/scylla/perftune.py --tune net --nic "$nic" $mode --dump-options-file > /etc/scylla.d/perftune.yaml
|
||||
}
|
||||
|
||||
is_valid_nic() {
|
||||
[ -d /sys/class/net/$1 ]
|
||||
}
|
||||
|
||||
. /etc/os-release
|
||||
if is_debian_variant || is_gentoo_variant; then
|
||||
SYSCONFIG=/etc/default
|
||||
|
||||
44
dist/common/scripts/scylla_setup
vendored
44
dist/common/scripts/scylla_setup
vendored
@@ -39,6 +39,27 @@ print_usage() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
interactive_choose_nic() {
|
||||
NICS=$(for i in /sys/class/net/*;do nic=`basename $i`; if [ "$nic" != "lo" ]; then echo $nic; fi; done)
|
||||
NR_NICS=`echo $NICS|wc -w`
|
||||
if [ $NR_NICS -eq 0 ]; then
|
||||
echo "NIC not found."
|
||||
exit 1
|
||||
elif [ $NR_NICS -eq 1 ]; then
|
||||
NIC=$NICS
|
||||
else
|
||||
echo "Please select NIC from following list: "
|
||||
while true; do
|
||||
echo $NICS
|
||||
echo -n "> "
|
||||
read NIC
|
||||
if is_valid_nic $NIC; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
interactive_ask_service() {
|
||||
echo $1
|
||||
echo $2
|
||||
@@ -125,6 +146,7 @@ run_setup_script() {
|
||||
return 0
|
||||
}
|
||||
|
||||
NIC="eth0"
|
||||
AMI=0
|
||||
SET_NIC=0
|
||||
DEV_MODE=0
|
||||
@@ -265,7 +287,8 @@ if is_ec2; then
|
||||
EC2_CHECK=$?
|
||||
fi
|
||||
if [ $EC2_CHECK -eq 1 ]; then
|
||||
/usr/lib/scylla/scylla_ec2_check
|
||||
interactive_choose_nic
|
||||
/usr/lib/scylla/scylla_ec2_check --nic $NIC
|
||||
fi
|
||||
fi
|
||||
|
||||
@@ -452,24 +475,6 @@ if [ $INTERACTIVE -eq 1 ]; then
|
||||
interactive_ask_service "Do you want to setup sysconfig?" "Answer yes to do system wide configuration customized for Scylla. Answer no to do nothing." "yes" &&:
|
||||
SYSCONFIG_SETUP=$?
|
||||
if [ $SYSCONFIG_SETUP -eq 1 ]; then
|
||||
NICS=$(for i in /sys/class/net/*;do nic=`basename $i`; if [ "$nic" != "lo" ]; then echo $nic; fi; done)
|
||||
NR_NICS=`echo $NICS|wc -w`
|
||||
if [ $NR_NICS -eq 0 ]; then
|
||||
echo "NIC not found."
|
||||
exit 1
|
||||
elif [ $NR_NICS -eq 1 ]; then
|
||||
NIC=$NICS
|
||||
else
|
||||
echo "Please select NIC from following list: "
|
||||
while true; do
|
||||
echo $NICS
|
||||
echo -n "> "
|
||||
read NIC
|
||||
if [ -e /sys/class/net/$NIC ]; then
|
||||
break
|
||||
fi
|
||||
done
|
||||
fi
|
||||
interactive_ask_service "Do you want to optimize NIC queue settings?" "Answer yes to enable network card optimization and improve performance. Answer no to skip this optimization." "yes" &&:
|
||||
SET_NIC=$?
|
||||
fi
|
||||
@@ -479,6 +484,7 @@ if [ $SYSCONFIG_SETUP -eq 1 ]; then
|
||||
if [ $SET_NIC -eq 1 ]; then
|
||||
SETUP_ARGS="--setup-nic"
|
||||
fi
|
||||
interactive_choose_nic
|
||||
run_setup_script "NIC queue" /usr/lib/scylla/scylla_sysconfig_setup --nic $NIC $SETUP_ARGS
|
||||
fi
|
||||
|
||||
|
||||
Reference in New Issue
Block a user