首页 > 代码库 > 使用paramikoHelper类实现MySQL安装和数据恢复
使用paramikoHelper类实现MySQL安装和数据恢复
本脚本实现远程Linux主机登陆和安装MySQL的rpm包,同时导入mysql数据,实现自动化安装
paramikoHelper类在本博客中 http://www.cnblogs.com/djoker/p/5906711.html
脚本内容:
import paramikoHelperimport ossshObj = paramikoHelper.myParamiko(ip,‘root‘,‘xxxxxxxx‘)filepath = ‘/opt/packages/mysql‘
#指定rpm包的目录,通过yum -y install mysql mysql-server --downloadonly --downloaddir=./ 下载下来
filelist = os.walk(filepath)filenameList = []for path,dir,files in filelist: for file in files: 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 = []for name in filenameList: cmdlist.append(‘rm -rf /root/‘ + name)sshObj.run_cmdlist(cmdlist)sshObj.close()
使用paramikoHelper类实现MySQL安装和数据恢复
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。