Home Database Mysql Tutorial 【MongDB运维】MongDB自动安装脚本--rpm包安装版

【MongDB运维】MongDB自动安装脚本--rpm包安装版

Jun 07, 2016 pm 03:56 PM
m Install Script automatic Operation and maintenance

MongoDB自动安装部署 本文共分为2部分: MongoDB自动安装目录说明; MongoDB自动安装脚本内容。 第一部分 MongoDB自动安装脚本目录说明: # ls 查看当前目录 -- install_mongodb.sh # MongoDB 自动安装脚本 -- mongo-10gen-2.4.10-mongodb_1.x86_64.rpm # mo

MongoDB自动安装部署

本文共分为2部分:

MongoDB自动安装目录说明;

MongoDB自动安装脚本内容。

第一部分

MongoDB自动安装脚本目录说明:

# ls 查看当前目录

-- install_mongodb.sh # MongoDB 自动安装脚本

-- mongo-10gen-2.4.10-mongodb_1.x86_64.rpm # mongodb安装包

-- mongo-10gen-server-2.4.10-mongodb_1.x86_64.rpm # mongodb安装包

第二部分

########################### MongoDB自动安装脚本内容开始(install_mongodb.sh)#######################

#!/bin/bash

# Version: v1.0 by Jason_Asia on 2014-05-14
# Desc: auto install mongodb rpm packages


software_dir=/home/dba/software/mongodb

##{{{ check mongodb install status

mongod_thread_status="`netstat -nltp | grep mongod | wc -l`"

if [ ${mongod_thread_status} -gt 0 ];then
echo "Critical: mongod is running."
exit
fi

[ `which mongod ` ] && echo "Critical: mongodb has been installed on this server." && exit

##}}}


##{{{ install mongodb rpms
function rpm_install(){
echo "Info: start to install mongo-10gen and mongo-10gen-server..."

# check rpms
cd $software_dir

mongo_10gen_rpm="mongo-10gen-[0-9]*mongodb*x86_64.rpm"
mongo_10gen_server_rpm="mongo-10gen-server-[0-9]*mongodb*x86_64.rpm"
# examples:
# mongo-10gen-server-2.4.10-mongodb_1.x86_64.rpm
# mongo-10gen-2.4.10-mongodb_1.x86_64.rpm

mongo_10gen_status="`ls ${mongo_10gen_rpm} >/dev/null 2>&1 ; echo $?`"
mongo_10gen_server_status="`ls ${mongo_10gen_server_rpm} >/dev/null 2>&1 ; echo $?`"

if [ "${mongo_10gen_status}" -ne 0 ];then
echo "Error: mongo-10gen doesn't exists in $software_dir/."
exit
elif [ "${mongo_10gen_server_status}" -ne 0 ];then
echo "Error: mongo-10gen-server doesn't exists in $software_dir/."
exit
else
echo "Info: mongo-10gen and mongo-10gen-server are ok."
fi

# install mongodb

rpm -ivh ${software_dir}/${mongo_10gen_rpm}
mongo_10gen_install_status="echo $?"
if [ ${mongo_10gen_install_status} -ne 0 ];then
echo "Error: mongo-10gen install failed."
fi

rpm -ivh ${software_dir}/${mongo_10gen_server_rpm}
mongo_10gen_server_install_status="echo $?"
if [ ${mongo_10gen_server_install_status} -ne 0 ];then
echo "Error: mongo-10gen-server install failed."
fi

echo "Info: mongodb install status:"
rpm -aq |grep mongo

echo "Info: finish installing mongodb."
echo ""
}

##}}}

##{{{ set mongodb configuration file
function configure(){
echo "Info: start to configure mongodb..."

# add user mongd
useradd mongod

# make mongodb directories
mkdir -p /home/mongodb
chown -R mongod.mongod /home/mongodb

mongod_conf=/etc/mongod.conf

# check /etc/mongod.conf
if [ ! -f ${mongod_conf} ];then
echo "Error: file ${mongod_conf} doesn't."
exit
fi


# set configurations
echo "Info: set ${mongod_conf}."

sed -i '2 amaster = true' ${mongod_conf}

sed -i '2 aport = 27017' ${mongod_conf}

sed -i '2 aauth = true' ${mongod_conf}

sed -i 's/^pidfilepath\(.*\)/#pidfilepath\1/g' ${mongod_conf}
sed -i '2 apidfilepath=/home/mongodb/mongod.pid' ${mongod_conf}

sed -i 's/^dbpath\(.*\)/#dbpath\1/g' ${mongod_conf}
sed -i '2 adbpath=/home/mongodb' ${mongod_conf}

sed -i 's/^logpath\(.*\)/#logpath\1/g' ${mongod_conf}
sed -i '2 alogpath=/home/mongodb/mongod.log' ${mongod_conf}

egrep '^dbpath|^logpath|^pidfilepath|^port' ${mongod_conf}

# set mongod service
echo "Info: set mogod service autostart."
chkconfig --level 2345 mongod on
chkconfig --list | grep mongod

echo "Info: finish configuring mongodb."
echo ""

}
##}}}


rpm_install
configure

########################### MongoDB自动安装脚本内容结束(install_mongodb.sh)#######################
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

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
4 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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)

Solution to the problem that Win11 system cannot install Chinese language pack Solution to the problem that Win11 system cannot install Chinese language pack Mar 09, 2024 am 09:48 AM

Solution to the problem that Win11 system cannot install Chinese language pack With the launch of Windows 11 system, many users began to upgrade their operating system to experience new functions and interfaces. However, some users found that they were unable to install the Chinese language pack after upgrading, which troubled their experience. In this article, we will discuss the reasons why Win11 system cannot install the Chinese language pack and provide some solutions to help users solve this problem. Cause Analysis First, let us analyze the inability of Win11 system to

Unable to install guest additions in VirtualBox Unable to install guest additions in VirtualBox Mar 10, 2024 am 09:34 AM

You may not be able to install guest additions to a virtual machine in OracleVirtualBox. When we click on Devices>InstallGuestAdditionsCDImage, it just throws an error as shown below: VirtualBox - Error: Unable to insert virtual disc C: Programming FilesOracleVirtualBoxVBoxGuestAdditions.iso into ubuntu machine In this post we will understand what happens when you What to do when you can't install guest additions in VirtualBox. Unable to install guest additions in VirtualBox If you can't install it in Virtua

How to create a script for editing? Tutorial on how to create a script through editing How to create a script for editing? Tutorial on how to create a script through editing Mar 13, 2024 pm 12:46 PM

Cutting is a video editing tool with comprehensive editing functions, support for variable speed, various filters and beauty effects, and rich music library resources. In this software, you can edit videos directly or create editing scripts, but how to do it? In this tutorial, the editor will introduce the method of editing and making scripts. Production method: 1. Click to open the editing software on your computer, then find the "Creation Script" option and click to open. 2. In the creation script page, enter the "script title", and then enter a brief introduction to the shooting content in the outline. 3. How can I see the "Storyboard Description" option in the outline?

What should I do if Baidu Netdisk is downloaded successfully but cannot be installed? What should I do if Baidu Netdisk is downloaded successfully but cannot be installed? Mar 13, 2024 pm 10:22 PM

If you have successfully downloaded the installation file of Baidu Netdisk, but cannot install it normally, it may be that there is an error in the integrity of the software file or there is a problem with the residual files and registry entries. Let this site take care of it for users. Let’s introduce the analysis of the problem that Baidu Netdisk is successfully downloaded but cannot be installed. Analysis of the problem that Baidu Netdisk downloaded successfully but could not be installed 1. Check the integrity of the installation file: Make sure that the downloaded installation file is complete and not damaged. You can download it again, or try to download the installation file from another trusted source. 2. Turn off anti-virus software and firewall: Some anti-virus software or firewall programs may prevent the installation program from running properly. Try disabling or exiting the anti-virus software and firewall, then re-run the installation

How to execute .sh file in Linux system? How to execute .sh file in Linux system? Mar 14, 2024 pm 06:42 PM

How to execute .sh file in Linux system? In Linux systems, a .sh file is a file called a Shell script, which is used to execute a series of commands. Executing .sh files is a very common operation. This article will introduce how to execute .sh files in Linux systems and provide specific code examples. Method 1: Use an absolute path to execute a .sh file. To execute a .sh file in a Linux system, you can use an absolute path to specify the location of the file. The following are the specific steps: Open the terminal

How to install Android apps on Linux? How to install Android apps on Linux? Mar 19, 2024 am 11:15 AM

Installing Android applications on Linux has always been a concern for many users. Especially for Linux users who like to use Android applications, it is very important to master how to install Android applications on Linux systems. Although running Android applications directly on Linux is not as simple as on the Android platform, by using emulators or third-party tools, we can still happily enjoy Android applications on Linux. The following will introduce how to install Android applications on Linux systems.

Windows PowerShell Scripting Tutorial for Beginners Windows PowerShell Scripting Tutorial for Beginners Mar 13, 2024 pm 10:55 PM

We've designed this Windows PowerShell scripting tutorial for beginners, whether you're a tech enthusiast or a professional looking to improve your scripting skills. If you have no prior knowledge of PowerShell scripting, this article will start with the basics and be tailored for you. We'll help you master the installation steps for a PowerShell environment and walk you through the main concepts and features of PowerShell scripts. If you're ready to learn more about PowerShell scripting, let's embark on this exciting learning journey together! What is WindowsPowerShell? PowerShell is a hybrid command system developed by Microsoft

How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 How to Install and Run the Ubuntu Notes App on Ubuntu 24.04 Mar 22, 2024 pm 04:40 PM

While studying in high school, some students take very clear and accurate notes, taking more notes than others in the same class. For some, note-taking is a hobby, while for others, it is a necessity when they easily forget small information about anything important. Microsoft's NTFS application is particularly useful for students who wish to save important notes beyond regular lectures. In this article, we will describe the installation of Ubuntu applications on Ubuntu24. Updating the Ubuntu System Before installing the Ubuntu installer, on Ubuntu24 we need to ensure that the newly configured system has been updated. We can use the most famous "a" in Ubuntu system

See all articles