在rockylinux9.4环境中安装mongodb5.0.15

在rockylinux9.4环境中安装mongodb5.0.15

一、准备环境

本次redis3.2.13版本集群搭建采用一台虚机,以192.168.190.151虚机为例

虚机配置:

机器IP

CPU&内存

系统盘

备注

192.168.190.151

hadoop1

2C4G

50GB

建议最低配置

1、登录网址:

Index of java-local/jdk

下载jdk-10.0.1_linux-x64_bin.tar.gz安装包

2、登录网址:

https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.15-rc2.tgz

下载mongodb-linux-x86_64-rhel70-5.0.15-rc2.tgz安装包

或者在rockylinux9.4系统中直接输入指令

wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-5.0.15-rc2.tgz

需在下文的software目录下执行

Ps:解压之后,检查mongodb的依赖环境:ldd ./mongod

如果发现缺少libcrypto.so.10,需使用

wget https://vault.centos.org/centos/8/AppStream/x86_64/os/Packages/compat-openssl10-1.0.2o-3.el8.x86_64.rpm

命令安装依赖环境

安装完成之后执行:rpm -ivh compat-openssl10-1.0.2o-3.el8.x86_64.rpm

3、准备好需要的目录:

cd /opt

mkdir {software,module}

cd /module

mkdir MongoDB

cd /MongoDB

mkdir data log

4、进入/software目录中,解压mongodb压缩包并解压至/MongoDB目录下:

cd /opt/software

tar -zxvf mongodb-linux-x86_64-rhel70-5.0.15-rc2.tgz -C /opt/module/MongoDB

5、重命名:

mv mongodb-linux-x86_64-rhel70-5.0.15-rc2.tgz mongodbServer

二、详细步骤

1、编辑配置文件:

vi /opt/module/MongoDB/mongodbServer/bin/mongod.conf

内容:

storage:

    dbPath: "/opt/module/MongoDB/data"

systemLog:

    destination: file

    path: "/opt/module/MongoDB/log/mongod.log"

    logAppend: true

net:

    port: 27017

    bindIpAll: true

processManagement:

    fork: true

    pidFilePath: /var/run/mongodb/mongod.pid

2、配置环境变量:

vi /etc/profile

内容:

export MONGODB_HOME=/usr/local/MongoDB/mongodbServer

export PATH=$PATH:$MONGODB_HOME/bin

export LD_LIBRARY_PATH=/usr/lib64/libcrypto.so.10/directory:$LD_LIBRARY_PATH

3、引用环境变量:

source /etc/profile

4、启动mongodb服务:

(安装完成之后,打开虚机初次使用,需先启动服务)

/opt/module/MongoDB/mongodbServer/bin/mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf

5、编写启停脚本:

vi /opt/module/MongoDB/mongodbServer/bin/mymongo

内容:

#!/bin/bash

start() {  

/opt/module/MongoDB/mongodbServer/bin/mongod  --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf

}  

  

stop() {  

/opt/module/MongoDB/mongodbServer/bin/mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf --shutdown  

}  

case "$1" in  

start)

start ;;  

  

stop)

 stop ;;  

  

restart) stop start ;;

 *)

 echo  

$"Usage:$0 {start|stop|restart}"

exit 1  

esac

6、启动启停服务:

/opt/module/MongoDB/mongodbServer/bin/mymongo stop

7、启动服务:

/opt/module/MongoDB/mongodbServer/bin/mymongo start

8、如果想使用systemctl start mongodb,可以先编写一个mongodb.service的配置文件

路径:vi /etc/systemd/system/mongodb.service

内容:

[Unit]  

Description=MongoDB Database Server  

After=network.target  

[Service]  

User=root

Group=root  

ExecStart=/opt/module/MongoDB/mongodbServer/bin/mongod --config /opt/module/MongoDB/mongodbServer/bin/mongod.conf  

ExecStop=/bin/kill -15 $MAINPID

PIDFile=/var/run/mongodb/mongod.pid

[Install]  

WantedBy=multi-user.target

  • 21
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值