dist/common/scripts: support nonroot mode on setup scripts
Since nonroot mode requires to run everything on non-privileged user, most of setup scripts does not able to use nonroot mode. We only provide following functions on nonroot mode: - EC2 check - IO setup - Node exporter installer - Dev mode setup Rest of functions will be skipped on scylla_setup. To implement nonroot mode on setup scripts, scylla_util provides utility functions to abstract difference of directory structure between normal installation and nonroot mode.
This commit is contained in:
14
dist/common/scripts/node_exporter_install
vendored
14
dist/common/scripts/node_exporter_install
vendored
@@ -28,18 +28,18 @@ from scylla_util import *
|
||||
import argparse
|
||||
|
||||
VERSION='0.17.0'
|
||||
INSTALL_DIR='/opt/scylladb/Prometheus/node_exporter'
|
||||
INSTALL_DIR=scylladir()+'/Prometheus/node_exporter'
|
||||
|
||||
if __name__ == '__main__':
|
||||
parser = argparse.ArgumentParser(description='Download and install prometheus node_exporter')
|
||||
parser.add_argument('-F', '--force', action='store_true', default=False, help='Force re-installation when node_exporter is already installed')
|
||||
args = parser.parse_args()
|
||||
force = args.force
|
||||
if os.getuid() > 0:
|
||||
if not is_nonroot() and os.getuid() > 0:
|
||||
print('Requires root permission.')
|
||||
sys.exit(1)
|
||||
|
||||
if os.path.exists('/usr/bin/node_exporter') or os.path.exists('/usr/bin/prometheus-node_exporter'):
|
||||
node_exporter_p = bindir_p() / 'node_exporter'
|
||||
if node_exporter_p.exists() or (bindir_p() / 'prometheus-node_exporter').exists():
|
||||
if force:
|
||||
print('node_exporter already installed, reinstalling')
|
||||
else:
|
||||
@@ -61,9 +61,9 @@ if __name__ == '__main__':
|
||||
with tarfile.open('/var/tmp/node_exporter-{version}.linux-amd64.tar.gz'.format(version=VERSION)) as tf:
|
||||
tf.extractall(INSTALL_DIR)
|
||||
os.remove('/var/tmp/node_exporter-{version}.linux-amd64.tar.gz'.format(version=VERSION))
|
||||
if os.path.exists('/usr/bin/node_exporter'):
|
||||
os.remove('/usr/bin/node_exporter')
|
||||
os.symlink('{install_dir}/node_exporter-{version}.linux-amd64/node_exporter'.format(install_dir=INSTALL_DIR, version=VERSION), '/usr/bin/node_exporter')
|
||||
if node_exporter_p.exists():
|
||||
node_exporter_p.unlink()
|
||||
os.symlink('{install_dir}/node_exporter-{version}.linux-amd64/node_exporter'.format(install_dir=INSTALL_DIR, version=VERSION), str(node_exporter_p))
|
||||
if is_systemd():
|
||||
node_exporter = systemd_unit('node-exporter.service')
|
||||
node_exporter.enable()
|
||||
|
||||
6
dist/common/scripts/scylla_dev_mode_setup
vendored
6
dist/common/scripts/scylla_dev_mode_setup
vendored
@@ -26,7 +26,7 @@ import argparse
|
||||
from scylla_util import *
|
||||
|
||||
if __name__ == '__main__':
|
||||
if os.getuid() > 0:
|
||||
if not is_nonroot() and os.getuid() > 0:
|
||||
print('Requires root permission.')
|
||||
sys.exit(1)
|
||||
parser = argparse.ArgumentParser(description='Modify Scylla running mode.')
|
||||
@@ -35,9 +35,9 @@ if __name__ == '__main__':
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.developer_mode == 0:
|
||||
with open('/etc/scylla.d/dev-mode.conf', 'w') as f:
|
||||
with open(etcdir()+'/scylla.d/dev-mode.conf', 'w') as f:
|
||||
f.close()
|
||||
else:
|
||||
cfg = sysconfig_parser('/etc/scylla.d/dev-mode.conf')
|
||||
cfg = sysconfig_parser(etcdir()+'/scylla.d/dev-mode.conf')
|
||||
cfg.set('DEV_MODE', '--developer-mode=1')
|
||||
cfg.commit()
|
||||
|
||||
26
dist/common/scripts/scylla_io_setup
vendored
26
dist/common/scripts/scylla_io_setup
vendored
@@ -22,7 +22,7 @@
|
||||
|
||||
import os
|
||||
import re
|
||||
import scylla_util
|
||||
from scylla_util import *
|
||||
import subprocess
|
||||
import argparse
|
||||
import yaml
|
||||
@@ -36,13 +36,13 @@ if __name__ == "__main__":
|
||||
help='configure AWS AMI')
|
||||
args = parser.parse_args()
|
||||
|
||||
cpudata = scylla_util.scylla_cpuinfo()
|
||||
if not scylla_util.is_developer_mode():
|
||||
cpudata = scylla_cpuinfo()
|
||||
if not is_developer_mode():
|
||||
if args.ami:
|
||||
idata = scylla_util.aws_instance()
|
||||
idata = aws_instance()
|
||||
|
||||
disk_properties = {}
|
||||
disk_properties["mountpoint"] = "/var/lib/scylla"
|
||||
disk_properties["mountpoint"] = datadir()
|
||||
nr_disks = len(idata.ephemeral_disks())
|
||||
## both i3 and i2 can run with 1 I/O Queue per shard
|
||||
if idata.instance() == "i3.large":
|
||||
@@ -81,22 +81,22 @@ if __name__ == "__main__":
|
||||
disk_properties["read_bandwidth"] = 507338935 * nr_disks
|
||||
disk_properties["write_iops"] = 57100 * nr_disks
|
||||
disk_properties["write_bandwidth"] = 483141731 * nr_disks
|
||||
properties_file = open("/etc/scylla.d/io_properties.yaml", "w")
|
||||
properties_file = open(etcdir() + "/scylla.d/io_properties.yaml", "w")
|
||||
yaml.dump({ "disks": [ disk_properties ] }, properties_file, default_flow_style=False)
|
||||
ioconf = open("/etc/scylla.d/io.conf", "w")
|
||||
ioconf = open(etcdir() + "/scylla.d/io.conf", "w")
|
||||
ioconf.write("SEASTAR_IO=\"--io-properties-file={}\"\n".format(properties_file.name))
|
||||
else:
|
||||
if "SCYLLA_CONF" in os.environ:
|
||||
conf_dir = os.environ["SCYLLA_CONF"]
|
||||
else:
|
||||
conf_dir = "/etc/scylla"
|
||||
conf_dir = etcdir() + "/scylla"
|
||||
cfg = yaml.safe_load(open(os.path.join(conf_dir, "scylla.yaml")))
|
||||
if not "data_file_directories" in cfg:
|
||||
logging.error("No data directories found. Please check the configuration and run scylla_io_setup again.\n")
|
||||
sys.exit(1)
|
||||
data_dirs = cfg["data_file_directories"]
|
||||
|
||||
default_path = '/var/lib/scylla/'
|
||||
default_path = datadir()
|
||||
for t in [ "commitlog", "hints", "view_hints", "saved_caches" ]:
|
||||
key = "%s_directory" % t
|
||||
if key in cfg:
|
||||
@@ -127,15 +127,15 @@ if __name__ == "__main__":
|
||||
iotune_args += [ "--smp", str(cpudata.smp()) ]
|
||||
|
||||
try:
|
||||
subprocess.check_call(["iotune",
|
||||
subprocess.check_call([bindir() + "/iotune",
|
||||
"--format", "envfile",
|
||||
"--options-file", "/etc/scylla.d/io.conf",
|
||||
"--properties-file", "/etc/scylla.d/io_properties.yaml"] + iotune_args)
|
||||
"--options-file", etcdir() + "/scylla.d/io.conf",
|
||||
"--properties-file", etcdir() + "/scylla.d/io_properties.yaml"] + iotune_args)
|
||||
except Exception:
|
||||
logging.error("%s did not pass validation tests, it may not be on XFS and/or has limited disk space.\n"
|
||||
"This is a non-supported setup, and performance is expected to be very bad.\n"
|
||||
"For better performance, placing your data on XFS-formatted directories is required.\n"
|
||||
"To override this error, enable developer mode as follow:\n"
|
||||
"sudo /opt/scylladb/scripts/scylla_dev_mode_setup --developer-mode 1", data_dirs)
|
||||
"sudo %s/scylla_dev_mode_setup --developer-mode 1", data_dirs, scriptsdir())
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
301
dist/common/scripts/scylla_setup
vendored
301
dist/common/scripts/scylla_setup
vendored
@@ -127,7 +127,7 @@ def get_unused_disks():
|
||||
|
||||
def run_setup_script(name, script):
|
||||
global interactive
|
||||
res = run(script, exception=False)
|
||||
res = run('{}/{}'.format(scriptsdir(), script), exception=False)
|
||||
if res != 0:
|
||||
if interactive:
|
||||
colorprint('{red}{name} setup failed. Press any key to continue...{nocolor}', name=name)
|
||||
@@ -138,7 +138,7 @@ def run_setup_script(name, script):
|
||||
return res
|
||||
|
||||
if __name__ == '__main__':
|
||||
if os.getuid() > 0:
|
||||
if not is_nonroot() and os.getuid() > 0:
|
||||
print('Requires root permission.')
|
||||
sys.exit(1)
|
||||
parser = argparse.ArgumentParser(description='Configure environment for Scylla.')
|
||||
@@ -221,7 +221,7 @@ if __name__ == '__main__':
|
||||
|
||||
umask = current_umask()
|
||||
# files have to be world-readable
|
||||
if (umask & 0o7) != 0o2:
|
||||
if not is_nonroot() and (umask & 0o7) != 0o2:
|
||||
colorprint('{red}Scylla does not work with current umask setting ({umask}),\nplease restore umask to the default value (0022).{nocolor}', umask='{0:o}'.format(umask).zfill(4))
|
||||
sys.exit(1)
|
||||
|
||||
@@ -237,18 +237,19 @@ if __name__ == '__main__':
|
||||
if ec2_check:
|
||||
nic = interactive_choose_nic()
|
||||
if ec2_check:
|
||||
run('/opt/scylladb/scripts/scylla_ec2_check --nic {}'.format(nic))
|
||||
run('{}/scylla_ec2_check --nic {}'.format(scriptsdir(), nic))
|
||||
|
||||
kernel_check = interactive_ask_service('Do you want to run check your kernel version?', 'Yes - runs a script to verify that the kernel for this instance qualifies to run Scylla. No - skips the kernel check.', kernel_check)
|
||||
args.no_kernel_check = not kernel_check
|
||||
if kernel_check:
|
||||
run('/opt/scylladb/scripts/scylla_kernel_check')
|
||||
if not is_nonroot():
|
||||
kernel_check = interactive_ask_service('Do you want to run check your kernel version?', 'Yes - runs a script to verify that the kernel for this instance qualifies to run Scylla. No - skips the kernel check.', kernel_check)
|
||||
args.no_kernel_check = not kernel_check
|
||||
if kernel_check:
|
||||
run('{}/scylla_kernel_check'.format(scriptsdir()))
|
||||
|
||||
verify_package = interactive_ask_service('Do you want to verify the ScyllaDB packages are installed?', 'Yes - runs a script to confirm that ScyllaDB is installed. No - skips the installation check.', verify_package)
|
||||
args.no_verify_package = not verify_package
|
||||
if verify_package:
|
||||
do_verify_package('scylla-jmx')
|
||||
do_verify_package('scylla-tools')
|
||||
verify_package = interactive_ask_service('Do you want to verify the ScyllaDB packages are installed?', 'Yes - runs a script to confirm that ScyllaDB is installed. No - skips the installation check.', verify_package)
|
||||
args.no_verify_package = not verify_package
|
||||
if verify_package:
|
||||
do_verify_package('scylla-jmx')
|
||||
do_verify_package('scylla-tools')
|
||||
|
||||
enable_service = interactive_ask_service('Do you want the Scylla server service to automatically start when the Scylla node boots?', 'Yes - Scylla server service automatically starts on Scylla node boot. No - skips this step. Note you will have to start the Scylla Server service manually.', enable_service)
|
||||
args.no_enable_service = not enable_service
|
||||
@@ -258,160 +259,162 @@ if __name__ == '__main__':
|
||||
elif is_gentoo_variant():
|
||||
run('rc-update add scylla-server default')
|
||||
|
||||
if not os.path.exists('/etc/scylla.d/housekeeping.cfg'):
|
||||
version_check = interactive_ask_service('Do you want to enable Scylla to check if there is a newer version of Scylla available?', 'Yes - start the Scylla-housekeeping service to check for a newer version. This check runs periodically. No - skips this step.', version_check)
|
||||
args.no_version_check = not version_check
|
||||
if version_check:
|
||||
with open('/etc/scylla.d/housekeeping.cfg', 'w') as f:
|
||||
f.write('[housekeeping]\ncheck-version: True\n')
|
||||
if is_systemd():
|
||||
systemd_unit('scylla-housekeeping-daily.timer').unmask()
|
||||
systemd_unit('scylla-housekeeping-restart.timer').unmask()
|
||||
else:
|
||||
with open('/etc/scylla.d/housekeeping.cfg', 'w') as f:
|
||||
f.write('[housekeeping]\ncheck-version: False\n')
|
||||
if is_systemd():
|
||||
hk_daily = systemd_unit('scylla-housekeeping-daily.timer')
|
||||
hk_daily.mask()
|
||||
hk_daily.stop()
|
||||
hk_restart = systemd_unit('scylla-housekeeping-restart.timer')
|
||||
hk_restart.mask()
|
||||
hk_restart.stop()
|
||||
|
||||
cur_version=out('scylla --version', exception=False)
|
||||
if len(cur_version) > 0:
|
||||
if is_debian_variant():
|
||||
new_version=out('sudo -u scylla /opt/scylladb/scripts/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/apt/sources.list.d/scylla*.list\' version --version {} --mode i'.format(cur_version), shell=True, exception=False)
|
||||
else:
|
||||
new_version=out('sudo -u scylla /opt/scylladb/scripts/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/yum.repos.d/scylla*.repo\' version --version {} --mode i'.format(cur_version), shell=True, exception=False)
|
||||
if len(new_version) > 0:
|
||||
print(new_version)
|
||||
else:
|
||||
if is_debian_variant():
|
||||
new_version=out('sudo -u scylla /opt/scylladb/scripts/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/apt/sources.list.d/scylla*.list\' version --version unknown --mode u', shell=True, exception=False)
|
||||
else:
|
||||
new_version=out('sudo -u scylla /opt/scylladb/scripts/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/yum.repos.d/scylla*.repo\' version --version unknown --mode u', shell=True, exception=False)
|
||||
print('A Scylla executable was not found, please check your installation {}'.format(new_version))
|
||||
|
||||
if is_redhat_variant():
|
||||
selinux_setup = interactive_ask_service('Do you want to disable SELinux?', 'Yes - disables SELinux. Choosing Yes greatly improves performance. No - keeps SELinux activated.', selinux_setup)
|
||||
args.no_selinux_setup = not selinux_setup
|
||||
if selinux_setup:
|
||||
res = run_setup_script('SELinux', '/opt/scylladb/scripts/scylla_selinux_setup')
|
||||
if res != 0:
|
||||
selinux_reboot_required=True
|
||||
|
||||
if args.ami:
|
||||
bootparam_setup = interactive_ask_service('Do you want add hugepages capability to the bootloader options?', 'Yes - enable hugepages at boot time. Choosing yes greatly improves performance. No - skips this step.', bootparam_setup)
|
||||
args.no_bootparam_setup = not bootparam_setup
|
||||
if bootparam_setup:
|
||||
run_setup_script('boot parameter', '/opt/scylladb/scripts/scylla_bootparam_setup --ami')
|
||||
|
||||
ntp_setup = interactive_ask_service('Do you want to setup Network Time Protocol(NTP) to auto-synchronize the current time on the node?', 'Yes - enables time-synchronization. This keeps the correct time on the node. No - skips this step.', ntp_setup)
|
||||
args.no_ntp_setup = not ntp_setup
|
||||
if ntp_setup:
|
||||
if args.ntp_domain:
|
||||
run_setup_script('NTP', '/opt/scylladb/scripts/scylla_ntp_setup --subdomain {}'.format(args.ntp_domain))
|
||||
else:
|
||||
run_setup_script('NTP', '/opt/scylladb/scripts/scylla_ntp_setup')
|
||||
|
||||
res = interactive_ask_service('Do you want to setup RAID0 and XFS?', 'It is recommended to use RAID0 and XFS for Scylla data. If you select yes, you will be prompted to choose the unmounted disks to use for Scylla data. Selected disks are formatted as part of the process.\nYes - choose a disk/disks to format and setup for RAID0 and XFS. No - skip this step.', raid_setup)
|
||||
if res:
|
||||
raid_setup = interactive_ask_service('Are you sure you want to setup RAID0 and XFS?', 'If you choose Yes, the selected drive will be reformated, erasing all existing data in the process.', raid_setup)
|
||||
else:
|
||||
raid_setup = False
|
||||
if res and raid_setup and not disks:
|
||||
devices = get_unused_disks()
|
||||
if len(devices) == 0:
|
||||
print('No free disks were detected, abort RAID/XFS setup. Disks must be unmounted before proceeding.\n')
|
||||
raid_setup = False
|
||||
else:
|
||||
print('Please select unmounted disks from the following list: {}'.format(devices))
|
||||
selected = []
|
||||
dsklist = []
|
||||
while True:
|
||||
print('type \'cancel\' to cancel RAID/XFS setup.')
|
||||
print('type \'done\' to finish selection. Selected: {}'.format(selected))
|
||||
if len(dsklist) > 0:
|
||||
dsk = dsklist.pop(0)
|
||||
if not is_nonroot():
|
||||
if not os.path.exists('/etc/scylla.d/housekeeping.cfg'):
|
||||
version_check = interactive_ask_service('Do you want to enable Scylla to check if there is a newer version of Scylla available?', 'Yes - start the Scylla-housekeeping service to check for a newer version. This check runs periodically. No - skips this step.', version_check)
|
||||
args.no_version_check = not version_check
|
||||
if version_check:
|
||||
with open('/etc/scylla.d/housekeeping.cfg', 'w') as f:
|
||||
f.write('[housekeeping]\ncheck-version: True\n')
|
||||
if is_systemd():
|
||||
systemd_unit('scylla-housekeeping-daily.timer').unmask()
|
||||
systemd_unit('scylla-housekeeping-restart.timer').unmask()
|
||||
else:
|
||||
dsk = input('> ')
|
||||
if dsk == 'cancel':
|
||||
raid_setup = 0
|
||||
break
|
||||
if dsk == 'done':
|
||||
if len(selected) == 0:
|
||||
continue
|
||||
break
|
||||
if dsk == '':
|
||||
continue
|
||||
if dsk.find(',') > 0:
|
||||
dsklist = dsk.split(',')
|
||||
continue
|
||||
if not os.path.exists(dsk):
|
||||
print('{} not found'.format(dsk))
|
||||
continue
|
||||
if not stat.S_ISBLK(os.stat(dsk).st_mode):
|
||||
print('{} is not block device'.format(dsk))
|
||||
continue
|
||||
selected.append(dsk)
|
||||
devices.remove(dsk)
|
||||
disks = ','.join(selected)
|
||||
args.disks = disks
|
||||
with open('/etc/scylla.d/housekeeping.cfg', 'w') as f:
|
||||
f.write('[housekeeping]\ncheck-version: False\n')
|
||||
if is_systemd():
|
||||
hk_daily = systemd_unit('scylla-housekeeping-daily.timer')
|
||||
hk_daily.mask()
|
||||
hk_daily.stop()
|
||||
hk_restart = systemd_unit('scylla-housekeeping-restart.timer')
|
||||
hk_restart.mask()
|
||||
hk_restart.stop()
|
||||
|
||||
args.no_raid_setup = not raid_setup
|
||||
if raid_setup:
|
||||
run_setup_script('RAID', '/opt/scylladb/scripts/scylla_raid_setup --disks {} --update-fstab'.format(disks))
|
||||
|
||||
coredump_setup = interactive_ask_service('Do you want to enable coredumps?', 'Yes - sets up coredump to allow a post-mortem analysis of the Scylla state just prior to a crash. No - skips this step.', coredump_setup)
|
||||
args.no_coredump_setup = not coredump_setup
|
||||
if coredump_setup:
|
||||
if disks:
|
||||
run_setup_script('coredump', '/opt/scylladb/scripts/scylla_coredump_setup --dump-to-raiddir')
|
||||
cur_version=out('scylla --version', exception=False)
|
||||
if len(cur_version) > 0:
|
||||
if is_debian_variant():
|
||||
new_version=out('sudo -u scylla {}/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/apt/sources.list.d/scylla*.list\' version --version {} --mode i'.format(scriptsdir(), cur_version), shell=True, exception=False)
|
||||
else:
|
||||
new_version=out('sudo -u scylla {}/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/yum.repos.d/scylla*.repo\' version --version {} --mode i'.format(scriptsdir(), cur_version), shell=True, exception=False)
|
||||
if len(new_version) > 0:
|
||||
print(new_version)
|
||||
else:
|
||||
run_setup_script('coredump', '/opt/scylladb/scripts/scylla_coredump_setup')
|
||||
if is_debian_variant():
|
||||
new_version=out('sudo -u scylla {}/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/apt/sources.list.d/scylla*.list\' version --version unknown --mode u'.format(scriptsdir()), shell=True, exception=False)
|
||||
else:
|
||||
new_version=out('sudo -u scylla {}/scylla-housekeeping --uuid-file /var/lib/scylla-housekeeping/housekeeping.uuid --repo-files \'/etc/yum.repos.d/scylla*.repo\' version --version unknown --mode u'.format(scriptsdir()), shell=True, exception=False)
|
||||
print('A Scylla executable was not found, please check your installation {}'.format(new_version))
|
||||
|
||||
sysconfig_setup = interactive_ask_service('Do you want to setup a system-wide customized configuration for Scylla?', 'Yes - setup the sysconfig file. No - skips this step.', sysconfig_setup)
|
||||
args.no_sysconfig_setup = not sysconfig_setup
|
||||
if sysconfig_setup:
|
||||
nic = interactive_choose_nic()
|
||||
set_nic_and_disks = interactive_ask_service('Do you want to enable Network Interface Card (NIC) and disk(s) optimization?', 'Yes - optimize the NIC queue and disks settings. Selecting Yes greatly improves performance. No - skip this step.', set_nic_and_disks)
|
||||
if sysconfig_setup:
|
||||
setup_args = '--setup-nic-and-disks' if set_nic_and_disks else ''
|
||||
run_setup_script('NIC queue', '/opt/scylladb/scripts/scylla_sysconfig_setup --nic {nic} {setup_args}'.format(nic=nic, setup_args=setup_args))
|
||||
if is_redhat_variant():
|
||||
selinux_setup = interactive_ask_service('Do you want to disable SELinux?', 'Yes - disables SELinux. Choosing Yes greatly improves performance. No - keeps SELinux activated.', selinux_setup)
|
||||
args.no_selinux_setup = not selinux_setup
|
||||
if selinux_setup:
|
||||
res = run_setup_script('SELinux', 'scylla_selinux_setup')
|
||||
if res != 0:
|
||||
selinux_reboot_required=True
|
||||
|
||||
if args.ami:
|
||||
bootparam_setup = interactive_ask_service('Do you want add hugepages capability to the bootloader options?', 'Yes - enable hugepages at boot time. Choosing yes greatly improves performance. No - skips this step.', bootparam_setup)
|
||||
args.no_bootparam_setup = not bootparam_setup
|
||||
if bootparam_setup:
|
||||
run_setup_script('boot parameter', 'scylla_bootparam_setup --ami')
|
||||
|
||||
ntp_setup = interactive_ask_service('Do you want to setup Network Time Protocol(NTP) to auto-synchronize the current time on the node?', 'Yes - enables time-synchronization. This keeps the correct time on the node. No - skips this step.', ntp_setup)
|
||||
args.no_ntp_setup = not ntp_setup
|
||||
if ntp_setup:
|
||||
if args.ntp_domain:
|
||||
run_setup_script('NTP', 'scylla_ntp_setup --subdomain {}'.format(args.ntp_domain))
|
||||
else:
|
||||
run_setup_script('NTP', 'scylla_ntp_setup')
|
||||
|
||||
res = interactive_ask_service('Do you want to setup RAID0 and XFS?', 'It is recommended to use RAID0 and XFS for Scylla data. If you select yes, you will be prompted to choose the unmounted disks to use for Scylla data. Selected disks are formatted as part of the process.\nYes - choose a disk/disks to format and setup for RAID0 and XFS. No - skip this step.', raid_setup)
|
||||
if res:
|
||||
raid_setup = interactive_ask_service('Are you sure you want to setup RAID0 and XFS?', 'If you choose Yes, the selected drive will be reformated, erasing all existing data in the process.', raid_setup)
|
||||
else:
|
||||
raid_setup = False
|
||||
if res and raid_setup and not disks:
|
||||
devices = get_unused_disks()
|
||||
if len(devices) == 0:
|
||||
print('No free disks were detected, abort RAID/XFS setup. Disks must be unmounted before proceeding.\n')
|
||||
raid_setup = False
|
||||
else:
|
||||
print('Please select unmounted disks from the following list: {}'.format(devices))
|
||||
selected = []
|
||||
dsklist = []
|
||||
while True:
|
||||
print('type \'cancel\' to cancel RAID/XFS setup.')
|
||||
print('type \'done\' to finish selection. Selected: {}'.format(selected))
|
||||
if len(dsklist) > 0:
|
||||
dsk = dsklist.pop(0)
|
||||
else:
|
||||
dsk = input('> ')
|
||||
if dsk == 'cancel':
|
||||
raid_setup = 0
|
||||
break
|
||||
if dsk == 'done':
|
||||
if len(selected) == 0:
|
||||
continue
|
||||
break
|
||||
if dsk == '':
|
||||
continue
|
||||
if dsk.find(',') > 0:
|
||||
dsklist = dsk.split(',')
|
||||
continue
|
||||
if not os.path.exists(dsk):
|
||||
print('{} not found'.format(dsk))
|
||||
continue
|
||||
if not stat.S_ISBLK(os.stat(dsk).st_mode):
|
||||
print('{} is not block device'.format(dsk))
|
||||
continue
|
||||
selected.append(dsk)
|
||||
devices.remove(dsk)
|
||||
disks = ','.join(selected)
|
||||
args.disks = disks
|
||||
|
||||
args.no_raid_setup = not raid_setup
|
||||
if raid_setup:
|
||||
run_setup_script('RAID', 'scylla_raid_setup --disks {} --update-fstab'.format(disks))
|
||||
|
||||
coredump_setup = interactive_ask_service('Do you want to enable coredumps?', 'Yes - sets up coredump to allow a post-mortem analysis of the Scylla state just prior to a crash. No - skips this step.', coredump_setup)
|
||||
args.no_coredump_setup = not coredump_setup
|
||||
if coredump_setup:
|
||||
if disks:
|
||||
run_setup_script('coredump', 'scylla_coredump_setup --dump-to-raiddir')
|
||||
else:
|
||||
run_setup_script('coredump', 'scylla_coredump_setup')
|
||||
|
||||
sysconfig_setup = interactive_ask_service('Do you want to setup a system-wide customized configuration for Scylla?', 'Yes - setup the sysconfig file. No - skips this step.', sysconfig_setup)
|
||||
args.no_sysconfig_setup = not sysconfig_setup
|
||||
if sysconfig_setup:
|
||||
nic = interactive_choose_nic()
|
||||
set_nic_and_disks = interactive_ask_service('Do you want to enable Network Interface Card (NIC) and disk(s) optimization?', 'Yes - optimize the NIC queue and disks settings. Selecting Yes greatly improves performance. No - skip this step.', set_nic_and_disks)
|
||||
if sysconfig_setup:
|
||||
setup_args = '--setup-nic-and-disks' if set_nic_and_disks else ''
|
||||
run_setup_script('NIC queue', 'scylla_sysconfig_setup --nic {nic} {setup_args}'.format(nic=nic, setup_args=setup_args))
|
||||
|
||||
io_setup = interactive_ask_service('Do you want IOTune to study your disks IO profile and adapt Scylla to it? (*WARNING* Saying NO here means the node will not boot in production mode unless you configure the I/O Subsystem manually!)', 'Yes - let iotune study my disk(s). Note that this action will take a few minutes. No - skip this step.', io_setup)
|
||||
args.no_io_setup = not io_setup
|
||||
if io_setup:
|
||||
run_setup_script('IO configuration', '/opt/scylladb/scripts/scylla_io_setup')
|
||||
run_setup_script('IO configuration', 'scylla_io_setup')
|
||||
|
||||
node_exporter = interactive_ask_service('Do you want to install node exporter to export Prometheus data from the node? Note that the Scylla monitoring stack uses this data', 'Yes - install node exporter. No - skip this step.', node_exporter)
|
||||
args.no_node_exporter = not node_exporter
|
||||
if node_exporter:
|
||||
run_setup_script('node exporter', '/opt/scylladb/scripts/node_exporter_install')
|
||||
run_setup_script('node exporter', 'node_exporter_install')
|
||||
|
||||
if args.developer_mode:
|
||||
run_setup_script('developer mode', '/opt/scylladb/scripts/scylla_dev_mode_setup --developer-mode 1')
|
||||
run_setup_script('developer mode', 'scylla_dev_mode_setup --developer-mode 1')
|
||||
|
||||
cpuscaling_setup = interactive_ask_service('Do you want to set the CPU scaling governor to Performance level on boot?', 'Yes - sets the CPU scaling governor to performance level. No - skip this step.', cpuscaling_setup)
|
||||
args.no_cpuscaling_setup = not cpuscaling_setup
|
||||
if cpuscaling_setup:
|
||||
run_setup_script('CPU scaling', '/opt/scylladb/scripts/scylla_cpuscaling_setup')
|
||||
if not is_nonroot():
|
||||
cpuscaling_setup = interactive_ask_service('Do you want to set the CPU scaling governor to Performance level on boot?', 'Yes - sets the CPU scaling governor to performance level. No - skip this step.', cpuscaling_setup)
|
||||
args.no_cpuscaling_setup = not cpuscaling_setup
|
||||
if cpuscaling_setup:
|
||||
run_setup_script('CPU scaling', 'scylla_cpuscaling_setup')
|
||||
|
||||
fstrim_setup = interactive_ask_service('Do you want to enable fstrim service?', 'Yes - runs fstrim on your SSD. No - skip this step.', fstrim_setup)
|
||||
args.no_fstrim_setup = not fstrim_setup
|
||||
if fstrim_setup:
|
||||
run_setup_script('fstrim', '/opt/scylladb/scripts/scylla_fstrim_setup')
|
||||
fstrim_setup = interactive_ask_service('Do you want to enable fstrim service?', 'Yes - runs fstrim on your SSD. No - skip this step.', fstrim_setup)
|
||||
args.no_fstrim_setup = not fstrim_setup
|
||||
if fstrim_setup:
|
||||
run_setup_script('fstrim', 'scylla_fstrim_setup')
|
||||
|
||||
print('ScyllaDB setup finished.')
|
||||
|
||||
if interactive:
|
||||
print_non_interactive_suggestion_message(args)
|
||||
if not is_nonroot():
|
||||
if interactive:
|
||||
print_non_interactive_suggestion_message(args)
|
||||
|
||||
if selinux_reboot_required:
|
||||
print('Please restart your machine before using ScyllaDB, as you have disabled')
|
||||
print(' SELinux.')
|
||||
if selinux_reboot_required:
|
||||
print('Please restart your machine before using ScyllaDB, as you have disabled')
|
||||
print(' SELinux.')
|
||||
|
||||
|
||||
if dist_name() == 'Ubuntu':
|
||||
run('apt-get install -y hugepages')
|
||||
if dist_name() == 'Ubuntu':
|
||||
run('apt-get install -y hugepages')
|
||||
|
||||
75
dist/common/scripts/scylla_util.py
vendored
75
dist/common/scripts/scylla_util.py
vendored
@@ -30,6 +30,54 @@ import urllib.parse
|
||||
import urllib.request
|
||||
import yaml
|
||||
import psutil
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
def scriptsdir_p():
|
||||
p = Path(sys.argv[0]).resolve()
|
||||
if p.parent.name == 'libexec':
|
||||
return p.parents[1]
|
||||
return p.parent
|
||||
|
||||
def scylladir_p():
|
||||
p = scriptsdir_p()
|
||||
return p.parent
|
||||
|
||||
def is_nonroot():
|
||||
return Path(scylladir_p() / 'SCYLLA-NONROOT-FILE').exists()
|
||||
|
||||
def bindir_p():
|
||||
if is_nonroot():
|
||||
return scylladir_p() / 'bin'
|
||||
else:
|
||||
return Path('/usr/bin')
|
||||
|
||||
def etcdir_p():
|
||||
if is_nonroot():
|
||||
return scylladir_p() / 'etc'
|
||||
else:
|
||||
return Path('/etc')
|
||||
|
||||
def datadir_p():
|
||||
if is_nonroot():
|
||||
return scylladir_p()
|
||||
else:
|
||||
return Path('/var/lib/scylla')
|
||||
|
||||
def scriptsdir():
|
||||
return str(scriptsdir_p())
|
||||
|
||||
def scylladir():
|
||||
return str(scylladir_p())
|
||||
|
||||
def bindir():
|
||||
return str(bindir_p())
|
||||
|
||||
def etcdir():
|
||||
return str(etcdir_p())
|
||||
|
||||
def datadir():
|
||||
return str(datadir_p())
|
||||
|
||||
def curl(url, byte=False):
|
||||
max_retries = 5
|
||||
@@ -195,7 +243,7 @@ def _reopt(s):
|
||||
|
||||
|
||||
def is_developer_mode():
|
||||
f = open("/etc/scylla.d/dev-mode.conf", "r")
|
||||
f = open(etcdir() + "/scylla.d/dev-mode.conf", "r")
|
||||
pattern = re.compile(_nocomment + r".*developer-mode" + _scyllaeq + "(1|true)")
|
||||
return len([x for x in f if pattern.match(x)]) >= 1
|
||||
|
||||
@@ -206,7 +254,7 @@ class scylla_cpuinfo:
|
||||
to run, how many total threads exist in the system, etc"""
|
||||
|
||||
def __parse_cpuset(self):
|
||||
f = open("/etc/scylla.d/cpuset.conf", "r")
|
||||
f = open(etcdir() + "/scylla.d/cpuset.conf", "r")
|
||||
pattern = re.compile(_nocomment + r"CPUSET=\s*\"" + _reopt(_cpuset) + _reopt(_smp) + "\s*\"")
|
||||
grp = [pattern.match(x) for x in f.readlines() if pattern.match(x)]
|
||||
if not grp:
|
||||
@@ -513,36 +561,39 @@ class SystemdException(Exception):
|
||||
|
||||
class systemd_unit:
|
||||
def __init__(self, unit):
|
||||
if is_nonroot():
|
||||
self.ctlparam = '--user'
|
||||
else:
|
||||
self.ctlparam = ''
|
||||
try:
|
||||
run('systemctl cat {}'.format(unit), silent=True)
|
||||
run('systemctl {} cat {}'.format(self.ctlparam, unit), silent=True)
|
||||
except subprocess.CalledProcessError:
|
||||
raise SystemdException('unit {} not found'.format(unit))
|
||||
self._unit = unit
|
||||
|
||||
def start(self):
|
||||
return run('systemctl start {}'.format(self._unit))
|
||||
return run('systemctl {} start {}'.format(self.ctlparam, self._unit))
|
||||
|
||||
def stop(self):
|
||||
return run('systemctl stop {}'.format(self._unit))
|
||||
return subprocess.check_call(['systemctl', 'stop', self._unit])
|
||||
return run('systemctl {} stop {}'.format(self.ctlparam, self._unit))
|
||||
|
||||
def restart(self):
|
||||
return run('systemctl restart {}'.format(self._unit))
|
||||
return run('systemctl {} restart {}'.format(self.ctlparam, self._unit))
|
||||
|
||||
def enable(self):
|
||||
return run('systemctl enable {}'.format(self._unit))
|
||||
return run('systemctl {} enable {}'.format(self.ctlparam, self._unit))
|
||||
|
||||
def disable(self):
|
||||
return run('systemctl disable {}'.format(self._unit))
|
||||
return run('systemctl {} disable {}'.format(self.ctlparam, self._unit))
|
||||
|
||||
def is_active(self):
|
||||
return out('systemctl is-active {}'.format(self._unit), exception=False)
|
||||
return out('systemctl {} is-active {}'.format(self.ctlparam, self._unit), exception=False)
|
||||
|
||||
def mask(self):
|
||||
return run('systemctl mask {}'.format(self._unit))
|
||||
return run('systemctl {} mask {}'.format(self.ctlparam, self._unit))
|
||||
|
||||
def unmask(self):
|
||||
return run('systemctl unmask {}'.format(self._unit))
|
||||
return run('systemctl {} unmask {}'.format(self.ctlparam, self._unit))
|
||||
|
||||
|
||||
class sysconfig_parser:
|
||||
|
||||
13
install.sh
13
install.sh
@@ -244,6 +244,14 @@ ExecStart=
|
||||
ExecStart=$rprefix/bin/scylla \$SCYLLA_ARGS \$SEASTAR_IO \$DEV_MODE \$CPUSET
|
||||
ExecStopPost=
|
||||
User=
|
||||
EOS
|
||||
install -d -m755 "$retc"/systemd/system/node-exporter.service.d
|
||||
cat << EOS > "$retc"/systemd/system/node-exporter.service.d/nonroot.conf
|
||||
[Service]
|
||||
ExecStart=
|
||||
ExecStart=$rprefix/bin/node_exporter --collector.interrupts
|
||||
User=
|
||||
Group=
|
||||
EOS
|
||||
install -d "$rprefix"/sbin
|
||||
for i in $SBINFILES; do
|
||||
@@ -254,6 +262,11 @@ EOS
|
||||
fi
|
||||
ln -srf $rsystemd/scylla-server.service ~/.config/systemd/user/
|
||||
ln -srf "$retc"/systemd/system/scylla-server.service.d/nonroot.conf ~/.config/systemd/user/scylla-server.service.d
|
||||
if [ ! -d ~/.config/systemd/user/node-exporter.service.d ]; then
|
||||
mkdir -p ~/.config/systemd/user/node-exporter.service.d
|
||||
fi
|
||||
ln -srf $rsystemd/node-exporter.service ~/.config/systemd/user/
|
||||
ln -srf "$retc"/systemd/system/node-exporter.service.d/nonroot.conf ~/.config/systemd/user/node-exporter.service.d
|
||||
fi
|
||||
|
||||
install -m755 scylla-gdb.py -Dt "$rprefix"/scripts/
|
||||
|
||||
Reference in New Issue
Block a user