快上网专注成都网站设计 成都网站制作 成都网站建设
成都网站建设公司服务热线:028-86922220

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

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://6mz.cn/article/jhjpho.html

其他资讯