使用paramikoHelper类实现MySQL安装和数据恢复
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用paramikoHelper类实现MySQL安装和数据恢复相关的知识,希望对你有一定的参考价值。
本脚本实现远程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安装和数据恢复的主要内容,如果未能解决你的问题,请参考以下文章
安装好了mysql了,但老实加载不了JDBC驱动程序,我知道是将mysql-connector-java-5.0.8-bin.jar放在WEB...