Python Deployment MongoDB Database

Source: Internet
Author: User
Tags chmod mkdir mongodb

Note: This environment only applies to the CENTOS6 version of the system, version 7 does not need to be installed glibc

#!/usr/bin/env python#coding:utf-8import osimport zipfileimport tarfileimport shutilline = Os.linesepscript_path = OS.GETCWD () glibc_package = ' glibc-2.14.zip ' mongo_package = ' mongodb-linux-x86_64-rhel70-3.2.8.tgz ' Mongo_path = '/usr ' /local/mongodb/' def decompression (): Try:z = ZipFile. ZipFile (Glibc_package, ' R ') Z.extractall () z.close () except:print "Zip decompression failed" try:t = TA Rfile.open (Mongo_package, ' R ') T.extractall () t.close () Except:print "Tar decompression failed" Def CreateDirectory ( ): Shutil.move (script_path+ '/mongodb-linux-x86_64-rhel70-3.2.8 ', Mongo_path) Os.mkdir (mongo_path+ ' conf ') Os.makedi    RS ('/data/mongodb/logs ') os.mkdir ('/data/mongodb/db ') shutil.move (script_path+ '/mongodb.conf ', mongo_path+ ' conf ') With open ('/etc/profile ', ' a ') as F:f.write ("Export path=/usr/local/mongodb/bin: $PATH%sexport ld_library_path=/usr/ Local/glibc-2.14/lib: $LD _library_path%sexport lc_all=c%s "% (line,line,line)) Os.chdir (script_path+ '/glibc-2.14 ') os.mkdir (' Build ') os.chdir (' Build ') def comPiled (): Try:os.system ("chmod +x%s/glibc- 2.14/* "% Script_path) Os.system (" chmod +x%s/glibc-2.14/scripts/* "% script_path) os.system (' ...        /configure--prefix=/usr/locsal/glibc-2.14 ') os.system (' Make-j4 ') os.system (' make install ') except: Print "Compilation failed, please check" Def startservice (): Os.system (' Source/etc/profile ') os.system ('%sbin/mongod-f/usr/local/mongod B/conf/mongodb.conf '% Mongo_path) decompression () CreateDirectory () comPiled () StartService ()

Python deployment MongoDB database

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.