Home Database Mysql Tutorial MongoDB安装及做成服务

MongoDB安装及做成服务

Jun 07, 2016 pm 02:53 PM
mongodb Install Serve

MongoDB安装及做成服务 安装及使用: www.2cto.com 首先在Ubuntu上安装MongoDB。 下载MongoDB, 现在最新的生产版本1.7.0 1. 解压文件. $ tar -xvf mongodb-linux-i686-1.4.3.tgz 2. 为MongoDB创建数据目录,默认情况下它将数据存储在/data/db $ sudo mkdir -

MongoDB安装及做成服务

 

安装及使用: 

  www.2cto.com  

首先在Ubuntu上安装MongoDB。 

 

下载MongoDB, 现在最新的生产版本1.7.0 

 

1.                   解压文件. 

 

$ tar -xvf mongodb-linux-i686-1.4.3.tgz 

 

2.                  为MongoDB创建数据目录,默认情况下它将数据存储在/data/db 

 

$ sudo mkdir -p /data/db/ 

 

$ sudo chown `id -u` /data/db 

 

3.                  启动MongoDB服务. 

 

$ cd mongodb-linux-i686-1.4.3/bin 

 

$ ./mongod 

 

4.                  打开另一个终端,并确保你在MongoDB的bin目录,输入如下命令. 

 

$ ./mongo 

 

==================================================================== 

每次开机运行都需要在(cmd)下面手动输入 

    E 

    cd E:\APMServ5.2.6\MongoDb\bin 

    mongod --dbpath E:\APMServ5.2.6\MongoDb\data 

这样感觉非常麻烦,所以将Mongo数据库安装成为Windows服务。如此就方便很多啦 

    E:\APMServ5.2.6\MongoDb\bin>mongod --logpath E:\APMServ5.2.6\MongoDb\logs\MongoDB.log --logappend --dbpath E:\APMServ5.2.6\MongoDb\data --directoryperdb --serviceName MongoDB --install 

    

回车显示如下便是服务安装成功 

    all output going to: E:\APMServ5.2.6\MongoDb\logs\MongoDB.log 

    Creating service MongoDB. 

    Service creation successful. 

    Service can be started from the command line via 'net start "MongoDB"'. 

  www.2cto.com  

强调 

1:log一定要指定一个xxx.log文件(文件不存在也要这么写,会自动创建,写成这样是不可以的--logpath d:\mongodb\logs) 

2:serviceName的N字母要大写 

 

注意:这条命令要到MongoDB的bin目录下运行,刚开始的时候,我就直接在D:\下运行,结果服务的可执行目录为【"D:\mongod" --logpath  "D:\MongoDB\logs\MongoDB.log"  --logappend  --dbpath  "D:\MongoDB\data"  --directoryperdb  --service 】,肯定是不对的。 

 

该命令行指定了日志文件:E:\APMServ5.2.6\MongoDb\logs\MongoDB.log,日志是以追加的方式输出的; 

数据文件目录:E:\APMServ5.2.6\MongoDb\data,并且参数--directoryperdb说明每个DB都会新建一个目录;

 

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the use of net4.0 What is the use of net4.0 May 10, 2024 am 01:09 AM

.NET 4.0 is used to create a variety of applications and it provides application developers with rich features including: object-oriented programming, flexibility, powerful architecture, cloud computing integration, performance optimization, extensive libraries, security, Scalability, data access, and mobile development support.

Huawei's August service day is here: free mobile phone films and free labor costs for repairs Huawei's August service day is here: free mobile phone films and free labor costs for repairs Aug 07, 2024 pm 07:24 PM

According to news on August 3, according to Huawei’s official introduction, Huawei’s July Service Day has officially started, from August 3 to August 4. It is understood that Huawei’s service days are from the first consecutive Friday to Sunday of each month (if the weekend spans the month, it will be postponed to the next weekend). Huawei users who visit the store during the event can enjoy six exclusive benefits including free film stickers and free labor costs for repairs. Specifically: Huawei mobile phones: free film, cleaning, maintenance, and system upgrade services. Huawei tablets, laptops, wearables, earphones of designated models, and smart glasses: free appearance cleaning and maintenance services. In addition, during the event, users are not required to go to the store for equipment repairs. Pay labor fees and go to the store to purchase Huawei brand accessories, extended service packages, and personalized film products: enjoy a 10% discount on the recommended retail price. The repaired equipment cannot be repaired on the same day.

How to configure MongoDB automatic expansion on Debian How to configure MongoDB automatic expansion on Debian Apr 02, 2025 am 07:36 AM

This article introduces how to configure MongoDB on Debian system to achieve automatic expansion. The main steps include setting up the MongoDB replica set and disk space monitoring. 1. MongoDB installation First, make sure that MongoDB is installed on the Debian system. Install using the following command: sudoaptupdatesudoaptinstall-ymongodb-org 2. Configuring MongoDB replica set MongoDB replica set ensures high availability and data redundancy, which is the basis for achieving automatic capacity expansion. Start MongoDB service: sudosystemctlstartmongodsudosys

How to ensure high availability of MongoDB on Debian How to ensure high availability of MongoDB on Debian Apr 02, 2025 am 07:21 AM

This article describes how to build a highly available MongoDB database on a Debian system. We will explore multiple ways to ensure data security and services continue to operate. Key strategy: ReplicaSet: ReplicaSet: Use replicasets to achieve data redundancy and automatic failover. When a master node fails, the replica set will automatically elect a new master node to ensure the continuous availability of the service. Data backup and recovery: Regularly use the mongodump command to backup the database and formulate effective recovery strategies to deal with the risk of data loss. Monitoring and Alarms: Deploy monitoring tools (such as Prometheus, Grafana) to monitor the running status of MongoDB in real time, and

Xiaomi's Thanksgiving Season event starts: 20% off on battery replacement for 80 mobile phone models, 50% off on cleaning of all laptop series, starting from 49.5 yuan Xiaomi's Thanksgiving Season event starts: 20% off on battery replacement for 80 mobile phone models, 50% off on cleaning of all laptop series, starting from 49.5 yuan Jul 17, 2024 am 07:45 AM

According to news from this site on July 16, Xiaomi has launched its Thanksgiving Season event today, providing preferential replacement and maintenance services for mobile phones, laptops, air conditioners, washing machines, range hoods and other accessories. The content of the activities organized by this site is as follows: The event time is from 10:00 on July 16, 2024 to 24:00 on July 25, 2024. Mobile phone battery replacement can be enjoyed at 20% off for 80 models, with official quality and original accessories. 12 models can enjoy a 20% discount on mobile phone back cover replacement starting from 79.2 yuan. Mobile phone back cover replacement, official accessories, starting from 68 yuan. It should be noted that after users place an order for the back cover replacement service on Xiaomi Mall, the color can be selected at the store. , the specific inventory is subject to the actual situation of the store. If the selected color is out of stock, there may be a delivery delay. Replace your laptop battery with a new one and enjoy 20% off on 14 models of laptops

Navicat's method to view MongoDB database password Navicat's method to view MongoDB database password Apr 08, 2025 pm 09:39 PM

It is impossible to view MongoDB password directly through Navicat because it is stored as hash values. How to retrieve lost passwords: 1. Reset passwords; 2. Check configuration files (may contain hash values); 3. Check codes (may hardcode passwords).

Major update of Pi Coin: Pi Bank is coming! Major update of Pi Coin: Pi Bank is coming! Mar 03, 2025 pm 06:18 PM

PiNetwork is about to launch PiBank, a revolutionary mobile banking platform! PiNetwork today released a major update on Elmahrosa (Face) PIMISRBank, referred to as PiBank, which perfectly integrates traditional banking services with PiNetwork cryptocurrency functions to realize the atomic exchange of fiat currencies and cryptocurrencies (supports the swap between fiat currencies such as the US dollar, euro, and Indonesian rupiah with cryptocurrencies such as PiCoin, USDT, and USDC). What is the charm of PiBank? Let's find out! PiBank's main functions: One-stop management of bank accounts and cryptocurrency assets. Support real-time transactions and adopt biospecies

How to sort mongodb index How to sort mongodb index Apr 12, 2025 am 08:45 AM

Sorting index is a type of MongoDB index that allows sorting documents in a collection by specific fields. Creating a sort index allows you to quickly sort query results without additional sorting operations. Advantages include quick sorting, override queries, and on-demand sorting. The syntax is db.collection.createIndex({ field: <sort order> }), where <sort order> is 1 (ascending order) or -1 (descending order). You can also create multi-field sorting indexes that sort multiple fields.

See all articles