This script enables remote Linux host to log in and install MySQL RPM package while importing MySQL data for automated installation
Paramikohelper class in this blog http://www.cnblogs.com/djoker/p/5906711.html
Script content:
ImportParamikohelperImportOssshobj= Paramikohelper.myparamiko (IP,'Root','xxxxxxxx') FilePath='/opt/packages/mysql'
#指定rpm包的目录, download it via yum-y install MySQL mysql-server--downloadonly--downloaddir=./
filelist=Os.walk (filepath) filenamelist= [] forPath,dir,filesinchfilelist: forFileinchFiles:sshObj.put (Os.path.join (path,file),'/root/'+file) filenamelist.append (file) cmdlist=[]cmdlist.append ('rpm-i perl-dbi-1.609-4.el6.x86_64.rpm') Cmdlist.append ('rpm-i mysql-libs-5.1.73-7.el6.x86_64.rpm') Cmdlist.append ('rpm-i perl-dbd-mysql-4.013-3.el6.x86_64.rpm') Cmdlist.append ('rpm-i mysql-5.1.73-7.el6.x86_64.rpm') Cmdlist.append ('rpm-i mysql-server-5.1.73-7.el6.x86_64.rpm') Cmdlist.append ('Service mysqld Start') Cmdlist.append ('MySQL </root/all.sql') Cmdlist.append ('Service mysqld Restart') Cmdlist.append ('chkconfig mysqld on') sshobj.run_cmdlist (cmdlist) cmdlist= [] forNameinchFilenameList:cmdlist.append ('rm-rf/root/'+name) sshobj.run_cmdlist (cmdlist) sshobj.close ()
Using the Paramikohelper class for MySQL installation and data recovery