码迷,mamicode.com
首页 > 数据库 > 详细

使用paramikoHelper类实现MySQL安装和数据恢复

时间:2016-09-25 22:05:54      阅读:209      评论:0      收藏:0      [点我收藏+]

标签:

本脚本实现远程Linux主机登陆和安装MySQL的rpm包,同时导入mysql数据,实现自动化安装

paramikoHelper类在本博客中 http://www.cnblogs.com/djoker/p/5906711.html

脚本内容:

import paramikoHelper
import os

sshObj = 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安装和数据恢复

标签:

原文地址:http://www.cnblogs.com/djoker/p/5906749.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!