• centos下安装mongodb 通过shell脚本


     
    #! /bin/bash
    
    yum -y update 
    
    echo -e "开始安装mongodb
    "
    download_url=https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-4.0.18.tgz
    file_name=${download_url##*/}
    file_dir=${file_name%.tgz*}
    
    
    dbpath=dbpath=/usr/local/mongodb/db
    logpath=logpath=/usr/local/mongodb/logs/mongodb.log
    fork=fork=true
    port=port=27017
    
    echo -e "进入 /usr/local/src目录
    "
    
    cd /usr/local/src
    
    echo -e "删除/usr/local/mongodb
    "
    rm -rf /usr/local/mongodb
    rm -rf /usr/local/src/${file_dir}
    
    echo -e "检测是否存在包"
    
    if [ ! -f "/usr/local/src/${file_name}" ];then
        echo -e "下载: "${download_url} 
        wget ${download_url}
    fi
    
    
    tar -zxvf $file_name
    
    mv $file_dir /usr/local/mongodb
    
    cd /usr/local/mongodb
    
    if [ ! -d "/usr/local/mongodb/db" ]; then
      mkdir /usr/local/mongodb/db
    fi
     
    if [ ! -d "/usr/local/mongodb/logs" ]; then
      mkdir /usr/local/mongodb/logs
    fi
    
    binpath=/usr/local/mongodb/bin
    ip=0.0.0.0
    
    rm -rf bin/mongodb.conf
    
    echo $dbpath >> bin/mongodb.conf
    echo $logpath >> bin/mongodb.conf
    echo $fork >> bin/mongodb.conf
    echo $port >> bin/mongodb.conf
    
    bindpath=/usr/local/mongodb/bin
    
    # kill previous mongodb process
    #ps -ef|grep mongodb|grep -v grep|cut -c 9-15|xargs kill -9
    
    echo -e "启动
    "
    ${binpath}/mongod --bind_ip ${ip} -f ${binpath}/mongodb.conf
    
    echo -e "放入/etc/rc.local 开机启动
    "
    
    echo ${binpath}/mongod --bind_ip ${ip} -f ${binpath}/mongodb.conf >> /etc/rc.local
    
    rm -rf /usr/local/bin/mongo
    
    echo -e "建立软连接
    "
    ln -s ${binpath}/mongo /usr/local/bin/mongo
    
    echo -e "启动命令为:
    "
    echo -e ${binpath}/mongod --bind_ip ${ip} -f ${binpath}/mongodb.conf
    

      

    链接: 去百度网盘下载 提取码: vjrs 

  • 相关阅读:
    【Android开发艺术探索】Activity的生命周期和启动模式
    【Android】基于WanAndroid开放API实现的文章阅读APP
    【Android】天气应用
    【Android】动态更新Icon
    【Android】VirtualAPK的简单使用
    Android数据存储之SD卡文件操作
    Android数据存储之SQLite数据库
    Android数据存储之共享参数SharedPreferences
    tensor维度变换
    tensor数据基操----索引与切片
  • 原文地址:https://www.cnblogs.com/brady-wang/p/12816764.html
Copyright © 2020-2023  润新知