#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
import
paramiko,os,sys,datetime,time,
MySQLdb
def log_w(text):
logfile = "/home/create_slave.log"
now = time.strftime("%Y-%m-%d %H:%M:%S")
tt = str(now) + "t" + str(text) + "n"
f = open(logfile,'a+')
f.write(tt)
f.close()
class Database:
def __init__(self,host):
self.user='root'
self.password='123456'
self.port=22
self.today=datetime.date.today().strftime('%Y%m%d')
self.bindir='/data1/mysql_log'
self.host=host
if not os.path.isdir(self.bindir):
os.makedirs(self.bindir)
os.popen("ln -s /data1/mysql_log /mysql_log")
if not os.path.isdir('/data1/mysql_log/binlog'):
os.makedirs('/data1/mysql_log/binlog')
if not os.path.isdir('/data1/mysql_log/relaylog'):
os.makedirs('/data1/mysql_log/relaylog')
os.popen("chown -R mysql.mysql /data1/mysql_log/")
def check_mysql(self):#检查从库ny
sql数据库服务是否运行,如在运行则pkill掉,然后跳过权限表启动,为导入数据做准备
text = "Check mysql now,Please wait...."
log_w(text)
print "