提交 9a181d4b 编写于 作者: J Jamie McAtamney 提交者: Shoaib Lari

Remove gpseginstall

Now that the enterprise version of GPDB is only provided via RPM, including
gpseginstall in the distribution would cause conflicts if users try to install
GPDB with RPMs and with gpseginstall on the same cluster.  While it could be
preserved for use by the OSS community, there are several standard tools for
copying GPDB files to segment hosts in a cluster, and recommendations for using
one or more of those tools will be included in the GPDB documentation.

In addition to removing gpseginstall itself, this commit removes references to
it in other utilities' documentation and removes code in gppylib that was only
called by gpseginstall.
Co-authored-by: NJamie McAtamney <jmcatamney@pivotal.io>
Co-authored-by: NKalen Krempely <kkrempely@pivotal.io>
(cherry picked from commit 64014685)
上级 4c2b5b97
......@@ -26,7 +26,6 @@ ext
/gpreloadc
/gpscpc
/gpsdc
/gpseginstallc
/gpssh-exkeysc
/gpsshc
/gpstartc
......
......@@ -29,12 +29,6 @@ from gppylib import gplog
from gppylib import gpsubprocess
from pygresql.pg import DB
# paramiko prints deprecation warnings which are ugly to the end-user
import warnings
warnings.simplefilter('ignore', DeprecationWarning)
import paramiko, getpass
logger = gplog.get_default_logger()
GPHOME = os.environ.get('GPHOME')
......@@ -389,20 +383,19 @@ class ExecutionError(Exception):
# specify types of execution contexts.
LOCAL = 1
REMOTE = 2
NAKED = 4
gExecutionContextFactory = None
#
# @param factory needs to have a createExecutionContext(self, execution_context_id, remoteHost, stdin, nakedExecutionInfo) function
# @param factory needs to have a createExecutionContext(self, execution_context_id, remoteHost, stdin) function
#
def setExecutionContextFactory(factory):
global gExecutionContextFactory
gExecutionContextFactory = factory
def createExecutionContext(execution_context_id, remoteHost, stdin, nakedExecutionInfo=None, gphome=None):
def createExecutionContext(execution_context_id, remoteHost, stdin, gphome=None):
if gExecutionContextFactory is not None:
return gExecutionContextFactory.createExecutionContext(execution_context_id, remoteHost, stdin)
elif execution_context_id == LOCAL:
......@@ -411,13 +404,6 @@ def createExecutionContext(execution_context_id, remoteHost, stdin, nakedExecuti
if remoteHost is None:
raise Exception("Programmer Error. Specified REMOTE execution context but didn't provide a remoteHost")
return RemoteExecutionContext(remoteHost, stdin, gphome)
elif execution_context_id == NAKED:
if remoteHost is None:
raise Exception("Programmer Error. Specified NAKED execution context but didn't provide a remoteHost")
if nakedExecutionInfo is None:
raise Exception(
"Programmer Error. Specified NAKED execution context but didn't provide a NakedExecutionInfo")
return NakedExecutionContext(remoteHost, stdin, nakedExecutionInfo)
class ExecutionContext():
......@@ -432,10 +418,10 @@ class ExecutionContext():
def execute(self, cmd):
pass
def interrupt(self, cmd):
def interrupt(self):
pass
def cancel(self, cmd):
def cancel(self):
pass
......@@ -472,190 +458,19 @@ class LocalExecutionContext(ExecutionContext):
cmd.set_results(CommandResult(
rc, "".join(stdout_value), "".join(stderr_value), self.completed, self.halt))
def cancel(self, cmd):
def cancel(self):
if self.proc:
try:
os.kill(self.proc.pid, signal.SIGTERM)
except OSError:
pass
def interrupt(self, cmd):
def interrupt(self):
self.halt = True
if self.proc:
self.proc.cancel()
##########################################################################
# Naked Execution is used to run commands where ssh keys are not exchanged
class NakedExecutionInfo:
SFTP_NONE = 0
SFTP_PUT = 1
SFTP_GET = 2
def __init__(self, passwordMap, sftp_operation=SFTP_NONE, sftp_remote=None, sftp_local=None):
self.passwordMap = passwordMap
self.sftp_operation = sftp_operation
self.sftp_remote = sftp_remote
self.sftp_local = sftp_local
class NakedExecutionPasswordMap:
def __init__(self, hostlist):
self.hostlist = hostlist
self.mapping = dict()
self.unique_passwords = set()
self.complete = False
# this method throws exceptions on error to create a valid list
def discover(self):
for host in self.hostlist:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
# TRY NO PASSWORD
try:
client.connect(host)
self.mapping[host] = None
client.close()
continue # next host
except Exception, e:
pass
try:
client.close()
except Exception, e:
pass
# TRY EXISTING PASSWORDS
foundit = False
for passwd in self.unique_passwords:
try:
client.connect(host, password=passwd)
foundit = True
self.mapping[host] = passwd
break
except Exception, e:
pass
if foundit:
continue
# ASK USER
foundit = False
for attempt in range(5):
try:
passwd = getpass.getpass(' *** Enter password for %s: ' % (host), sys.stderr)
client.connect(host, password=passwd)
foundit = True
self.mapping[host] = passwd
if passwd not in self.unique_passwords:
self.unique_passwords.add(passwd)
break
except Exception, e:
pass
try:
client.close()
except Exception, e:
pass
if not foundit:
raise Exception("Did not get a valid password for host " + host)
if len(self.mapping.keys()) == len(self.hostlist) and len(self.hostlist) > 0:
self.complete = True
class NakedExecutionContext(LocalExecutionContext):
def __init__(self, targetHost, stdin, nakedCommandInfo):
LocalExecutionContext.__init__(self, stdin)
self.targetHost = targetHost
self.passwordMap = nakedCommandInfo.passwordMap
self.sftp_operation = nakedCommandInfo.sftp_operation
self.sftp_remote = nakedCommandInfo.sftp_remote
self.sftp_local = nakedCommandInfo.sftp_local
self.client = None
def execute(self, cmd):
self.client = paramiko.SSHClient()
self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
try:
self.client.connect(self.targetHost, password=self.passwordMap.mapping[self.targetHost])
except paramiko.AuthenticationException:
self.client.close()
cmd.set_results(CommandResult(1, "", "password validation on %s failed" % self.targetHost, False, False))
return
except Exception, e:
cmd.set_results(
CommandResult(1, "", "connection to host " + self.targetHost + " failed: " + e.__str__(), False, False))
return
if self.sftp_operation == NakedExecutionInfo.SFTP_NONE:
self.execute_ssh(cmd)
elif self.sftp_operation == NakedExecutionInfo.SFTP_PUT:
self.execute_sftp_put(cmd)
elif self.sftp_operation == NakedExecutionInfo.SFTP_GET:
self.execute_sftp_get(cmd)
else:
raise Exception("bad NakedExecutionInfo.sftp_operation")
def execute_ssh(self, cmd):
try:
stdin, stdout, stderr = self.client.exec_command(cmd.cmdStr)
rc = stdout.channel.recv_exit_status()
self.completed = True
cmd.set_results(CommandResult(rc, stdout.readlines(), stderr.readlines(), self.completed, self.halt))
stdin.close()
stdout.close()
stderr.close()
except Exception, e:
cmd.set_results(CommandResult(1, "", e.__str__(), False, False))
finally:
self.client.close()
def execute_sftp_put(self, cmd):
ftp = None
try:
ftp = self.client.open_sftp()
ftp.put(self.sftp_local, self.sftp_remote)
self.completed = True
cmd.set_results(CommandResult(0, "", "", self.completed, self.halt))
except Exception, e:
cmd.set_results(CommandResult(1, "", e.__str__(), False, False))
finally:
ftp.close()
self.client.close()
def execute_sftp_get(self, cmd):
ftp = None
try:
ftp = self.client.open_sftp()
ftp.get(self.sftp_remote, self.sftp_local)
self.completed = True
cmd.set_results(CommandResult(0, "", "", self.completed, self.halt))
except Exception, e:
cmd.set_results(CommandResult(1, "", e.__str__(), False, False))
finally:
ftp.close()
self.client.close()
def interrupt(self, cmd):
self.halt = True
self.client.close()
cmd.set_results(CommandResult(1, "", "command on host " + self.targetHost + " interrupted ", False, False))
def cancel(self, cmd):
self.client.close()
cmd.set_results(CommandResult(1, "", "command on host " + self.targetHost + " canceled ", False, False))
class RemoteExecutionContext(LocalExecutionContext):
trail = set()
"""
......@@ -708,10 +523,10 @@ class Command(object):
exec_context = None
propagate_env_map = {} # specific environment variables for this command instance
def __init__(self, name, cmdStr, ctxt=LOCAL, remoteHost=None, stdin=None, nakedExecutionInfo=None, gphome=None):
def __init__(self, name, cmdStr, ctxt=LOCAL, remoteHost=None, stdin=None, gphome=None):
self.name = name
self.cmdStr = cmdStr
self.exec_context = createExecutionContext(ctxt, remoteHost, stdin=stdin, nakedExecutionInfo=nakedExecutionInfo,
self.exec_context = createExecutionContext(ctxt, remoteHost, stdin=stdin,
gphome=gphome)
self.remoteHost = remoteHost
self.logger = gplog.get_default_logger()
......@@ -772,11 +587,11 @@ class Command(object):
def cancel(self):
if self.exec_context and isinstance(self.exec_context, ExecutionContext):
self.exec_context.cancel(self)
self.exec_context.cancel()
def interrupt(self):
if self.exec_context and isinstance(self.exec_context, ExecutionContext):
self.exec_context.interrupt(self)
self.exec_context.interrupt()
def was_successful(self):
if self.results is None:
......
此差异已折叠。
......@@ -400,4 +400,4 @@ Initialize a Greenplum Database array with an optional standby master host:
SEE ALSO
*****************************************************
gpseginstall, gpssh-exkeys
gpssh-exkeys
......@@ -131,4 +131,4 @@ SEE ALSO
*****************************************************
gpssh-exkeys, gpssh, gpseginstall
gpssh-exkeys, gpssh
COMMAND NAME: gpseginstall
Installs Greenplum Database on segment hosts.
*****************************************************
SYNOPSIS
*****************************************************
gpseginstall -f host_file [-u user] [-p password]
[-c [u|p|c|s|E|e|l|v]]
gpseginstall --help
*****************************************************
DESCRIPTION
*****************************************************
The gpseginstall utility provides a simple way to quickly install Greenplum
Database on segment hosts that you specify in a host list file. The utility
does not install or update Greenplum Database on the master host. You can
run gpseginstall as root or as a non-root user. gpseginstall does not perform
database initialization. See gpinitsystem for more information about
initializing Greenplum Database.
When run as root, gpseginstall default actions are to add a system user
(default is gpadmin), create a password (default is changeme), and deploy and
install Greenplum Database on segment hosts. To do this, gpseginstall locates
the current Greenplum Database binaries on the master from the installation
path in the current user’s environment variables ($GPHOME). It compresses
Greenplum Database software into a tar.gz file and performs an MD5 checksum
to verify file integrity.
Then, it copies Greenplum Database to the segment hosts, installs
(decompresses) Greenplum Database, and changes the ownership of the Greenplum
Database installation to the system user you specify with the -u option.
Lastly, it exchanges keys between all Greenplum Database hosts as both root
and as the system user you specify with the -u option. gpseginstall also perform
a user limit check and verifies the version number of Greenplum Database on all
the segments.
If you run gpseginstall as a non-root user, gpseginstall only compresses, copies,
and installs Greenplum Database on segment hosts. It can also exchanges keys
between Greenplum Database hosts for the current system user, and verifies the
version number of Greenplum Database on all the segments.
*****************************************************
OPTIONS
*****************************************************
-c | --commands command_option(s)
This allows you to customize gpseginstall actions. Note that these command
options are executed by default if you do not specify the -c option in the
gpseginstall syntax.
* u: Adds a system user. (root only)
* p: Changes the password for a system user. (root only)
* s: Compresses, copies, decompresses (installs) Greenplum Database on all
segments.
* c: Changes the ownership of the Greenplum Database installation directory on
the segment hosts. (root only)
* E: Exchange keys between Greenplum Database master and segment hosts for the
root user. (root only)
* e: Exchange keys between Greenplum Database master and segment hosts for the
non-root system user.
* l: (Linux only) Checks and modifies the user limits configuration file
(/etc/security/limits.conf file) when adding a new user to segment hosts.
(root only)
* v: Verifies the version of Greenplum Database running on all segments.
gpseginstall checks the version number of the Greenplum Database
installation referenced by the $GPHOME environment variable and symbolic
link to the installation directory. An error occurs if there is a version
number mismatch or the Greenplum Database installation directory cannot be
found.
-f | --file host_file
This option is required. This specifies the file that lists the segment hosts
onto which you want to install Greenplum Database.
The host list file must have one host name per line and includes a host name
for each segment host in your Greenplum system. Make sure there are no blank
lines or extra spaces. If a host has multiple configured host names, use only
one host name per host. For example:
sdw1-1
sdw2-1
sdw3-1
sdw4-1
If available, you can use the same gpssh-exkeys host list file you used to
exchange keys between Greenplum Database hosts.
-p | --password password
This sets the password for the user you specify with the -u option. The
default password is changeme. This option is only available when you run
gpseginstall as root.
Best practises: Always use passwords, do not use default passwords,
change default passwords immediately after installation.
-u | --user user
This specifies the system user. This user is also the Greenplum Database
administrative user. This user owns Greenplum Database installation and
administers the database. This is also the user under which Greenplum
Database is started/initialized. This option is only available when you run
gpseginstall as root. The default is gpadmin.
--help (help)
Displays the online help.
*****************************************************
EXAMPLES
*****************************************************
As root, install a Greenplum Database on all segments, leave the system user
as the default (gpadmin) and set the gpadmin password to secret123:
$ gpseginstall -f my_host_list_file -p secret123
As a non-root user, compress and copy Greenplum Database binaries to all
segments (as gpadmin)
$ gpseginstall -f host_file
As root, add a user (gpadmin2), set the password for the user (secret1234),
exchange keys between hosts as the new user, check user limits, and verify
version numbers, but do not change ownership of Greenplum binaries,
compress/copy/ install Greenplum Database on segments, or exchange keys as
root.
$ gpseginstall -f host_file -u gpadmin2 -p secret1234 -c upelv
*****************************************************
SEE ALSO
*****************************************************
gpinitsystem
\ No newline at end of file
......@@ -163,5 +163,5 @@ hosts sdw4 and sdw5 as part of a system expansion operation:
SEE ALSO
*****************************************************
gpssh, gpscp, gpseginstall
gpssh, gpscp
......@@ -4,36 +4,6 @@ import socket
import inspect
from gppylib.commands.base import Command
class GpSegInstall(Command):
"""
This is a wrapper for gpseginstall
"""
def __init__(self, gphome, hosts):
self.hostfile = '/tmp/gpseginstall_hosts'
self.gphome = gphome
self.hosts = hosts
cmd_str = "gpseginstall -f %s -u %s" %(self.hostfile, getpass.getuser())
Command.__init__(self, 'run gpseginstall', cmd_str)
def run(self, validate=True):
print "Running gpseginstall: %s" % self
with open(self.hostfile, 'w') as f:
for host in self.hosts[1:]:
f.write(host)
f.write('\n')
res = run_shell_command('gpssh-exkeys -f %s' %self.hostfile, 'gpssh-exkeys')
if res['rc'] > 0:
raise Exception("Failed to do gpssh-exkeys: %s" %res['stderr'])
res = run_shell_command("gpssh -f %s -e 'mkdir -p %s'" %(self.hostfile, self.gphome), 'gpssh-exkeys')
if res['rc'] > 0:
raise Exception("Failed to create gphome directories on segments: %s" %res[stderr])
Command.run(self, validateAfter=validate)
result = self.get_results()
return result
class GpDeleteSystem(Command):
"""This is a wrapper for gpdeletesystem."""
def __init__(self, mdd=None):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册