码迷,mamicode.com
首页 > 数据库 > 详细

python安装mongodb

时间:2018-07-29 14:14:13      阅读:178      评论:0      收藏:0      [点我收藏+]

标签:nes   安装   export   copyfile   path   ice   x86_64   tar   pen   

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

标签:nes   安装   export   copyfile   path   ice   x86_64   tar   pen   

原文地址:http://blog.51cto.com/yht1990/2151727

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!