MongoDB完全手动安装
一 目录说明 按照官方建议各个文件存放路径如下所示: 可执行文件存放路径 /usr/local/bin(Ubuntu) /usr/bin(CentOS) 数据库文件存放路径 /var/lib/mongo 日志文件存放路径 /var/log/mongo/mongod.log 配置文件存放路径 /etc/mongod.conf 启动脚本存放路径 /e
一 目录说明按照官方建议各个文件存放路径如下所示: 可执行文件存放路径 /usr/local/bin(Ubuntu) /usr/bin(CentOS) 数据库文件存放路径 /var/lib/mongo 日志文件存放路径 /var/log/mongo/mongod.log 配置文件存放路径 /etc/mongod.conf 启动脚本存放路径 /etc/init.d/mongod 二 手动按照过程
1.首先从官网 http://www.mongodb.org/downloads 下载MongoDB
选择合适的版本
2.添加mongod用户 root@zhangzhe-laptop:/home/zhangzhe# useradd --create-home mongod root@zhangzhe-laptop:/home/zhangzhe# passwd mongod
3.解压文件 root@zhangzhe-laptop:/home/zhangzhe/下载# tar -zxvf mongodb-linux-i686-2.4.8.tgz
root@zhangzhe-laptop:/home/zhangzhe/下载# mv mongodb-linux-i686-2.4.8 mongo root@zhangzhe-laptop:/home/zhangzhe/下载/mongod/bin# chown -R mongod:mongod ./
注意:修改mongod下所有可执行文件的权限 4.将可执行文件放到 /usr/local/bin 目录下
root@zhangzhe-laptop:/home/zhangzhe/下载/mongod/bin# mv * /usr/local/bin
5. 创建数据库存储目录 /var/lib/mongo root@zhangzhe-laptop:/usr/local/bin# mkdir -p /var/lib/mongo root@zhangzhe-laptop:/usr/local/bin# chown -R mongod:mongod /var/lib/mongo 注意:修改相应文件的权限 6.创建日志 /var/log/mongo
root@zhangzhe-laptop:/var/lib# mkdir -p /var/log/mongo root@zhangzhe-laptop:/var/lib# chown -R mongod:mongod /var/log/mongo
7. 在 /etc/mongod.conf目录下新建配置文件 root@zhangzhe-laptop:/etc# vi mongod.conf
#mongo.conf #where to log logpath=/var/log/mongo/mongod.log logappend = true
#fork and run in background
fork = true #port = 27017
dbpath=/var/lib/mongo
#location of pidfile
pidfilepath=/var/run/mongodb/mongod.pid
8. 在 /etc/init.d 目录下新建mongod文件 root@zhangzhe-laptop:/home/zhangzhe# vi /etc/init.d/mongod 编写开机启动脚本
#!/bin/sh . /lib/lsb/init-functions CONFIG="/etc/mongod.conf" PROGRAM="/usr/local/bin/mongod" MONGOPID=`ps -ef | grep 'mongod' | grep -v grep | awk '{print $2}'` test -x $PROGRAM || exit 0 case "$1" in start) ulimit -n 3000 log_begin_msg "Starting MongoDB Server" $PROGRAM -f $CONFIG & log_end_msg 0 ;; stop) log_begin_msg "Stopping MongoDB Server" if [ ! -z "$MONGOPID" ]; then kill -15 $MONGOPID fi log_end_msg 0 ;; *) log_success_msg "Usage:/etc/init.d/mongodb {start|stop}" exit 1 esac exit 0
chmod +x /etc/init.d/mongod
update-rc.d mongod defaults
三 测试 启动和停止
sudo service mongodb start sudo service mongodb stop
除了使用手动方式进行按照以外,Ubuntu和Centos(Red hat)版本的linux都支持在线自动按照,可以自动的创建用户和相关目录。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

.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.

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

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

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).

When developing an e-commerce website, I encountered a difficult problem: how to provide users with personalized product recommendations. Initially, I tried some simple recommendation algorithms, but the results were not ideal, and user satisfaction was also affected. In order to improve the accuracy and efficiency of the recommendation system, I decided to adopt a more professional solution. Finally, I installed andres-montanez/recommendations-bundle through Composer, which not only solved my problem, but also greatly improved the performance of the recommendation system. You can learn composer through the following address:

Detailed explanation of MongoDB efficient backup strategy under CentOS system This article will introduce in detail the various strategies for implementing MongoDB backup on CentOS system to ensure data security and business continuity. We will cover manual backups, timed backups, automated script backups, and backup methods in Docker container environments, and provide best practices for backup file management. Manual backup: Use the mongodump command to perform manual full backup, for example: mongodump-hlocalhost:27017-u username-p password-d database name-o/backup directory This command will export the data and metadata of the specified database to the specified backup directory.

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

Encrypting MongoDB database on a Debian system requires following the following steps: Step 1: Install MongoDB First, make sure your Debian system has MongoDB installed. If not, please refer to the official MongoDB document for installation: https://docs.mongodb.com/manual/tutorial/install-mongodb-on-debian/Step 2: Generate the encryption key file Create a file containing the encryption key and set the correct permissions: ddif=/dev/urandomof=/etc/mongodb-keyfilebs=512
