python安装mongodb

#!/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)
~                 

网站题目:python安装mongodb
浏览路径:http://csruizhi.cn/article/jhjpho.html

其他资讯

Copyright © 2007-2024 成都优众联杰科技有限公司 All Rights Reserved 蜀ICP备2024116266号
友情链接: 成都网站设计 网站建设方案 成都定制网站建设 重庆电商网站建设 成都网站建设 企业网站建设 网站制作 响应式网站设计方案 成都网站设计 成都网站设计公司 成都网站制作 成都网站设计 响应式网站设计 网站建设费用 外贸网站设计方案 网站建设 网站制作报价 成都定制网站建设 成都网站建设推广 上市集团网站建设 成都网站建设 成都网站设计