您好,登錄后才能下訂單哦!
#!/usr/bin/env python
#coding:utf-8
import os
import tarfile
import shutil
mongo_package = 'mongodb-linux-x86_64-rhel70-3.2.8.tgz'
mongo_path = '/usr/local/mongodb'
script_path = os.getcwd()
line = os.linesep
t = tarfile.open(mongo_package,'r')
t.extractall()
t.close()
shutil.move(script_path+'/mongodb-linux-x86_64-rhel70-3.2.8',mongo_path)
mongo_dir = [mongo_path+'/conf','/data/mongodb/logs','/data/mongodb/db']
for dirs in mongo_dir:
os.makedirs(dirs)
shutil.copyfile(script_path+'/mongodb.conf',mongo_path+'/conf/mongodb.conf')
shutil.copyfile(script_path+'/mongod','/etc/init.d/mongod')
with open('/etc/profile','a')as f:
f.write("export PATH=/usr/local/mongodb/bin:$PATH%sexport LC_ALL=C%s" % (line,line))
list = ['chmod +x /etc/init.d/mongod','service mongod start','source /etc/profile']
for i in list:
os.system(i)
~
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。