当前位置:Gxlcms > 数据库问题 > MongoDB 3.6 安装详解

MongoDB 3.6 安装详解

时间:2021-07-01 10:21:17 帮助过:88人阅读

   方法二: 二进制包安装

  1. 下载包:

    curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.6.0.tgz

  2.  解压:

    tar -zxvf mongodb-linux-x86_64-3.6.0.tgz

  3. 创建目录:

    mkdir -p mongodb

    cp -R -n mongodb-linux-x86_64-3.6.0/ mongodb

  4. export path:

    export PATH=<mongodb-install-directory>/bin:$PATH

     最好放在 bashrc 或者 profile里,不用每次都手动export

 

  notes: 解决出现TPH warning的问题

   技术分享图片

  在 /etc/init.d/ 目录下创建 一个文件 /etc/init.d/disable-transparent-hugepages

#!/bin/bash
### BEGIN INIT INFO
# Provides:          disable-transparent-hugepages
# Required-Start:    $local_fs
# Required-Stop:
# X-Start-Before:    mongod mongodb-mms-automation-agent
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Disable Linux transparent huge pages
# Description:       Disable Linux transparent huge pages, to improve
#                    database performance.
### END INIT INFO

case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo never > ${thp_path}/enabled
    echo never > ${thp_path}/defrag

    re=^[0-1]+$
    if [[ $(cat ${thp_path}/khugepaged/defrag) =~ $re ]]
    then
      # RHEL 7
      echo 0  > ${thp_path}/khugepaged/defrag
    else
      # RHEL 6
      echo no > ${thp_path}/khugepaged/defrag
    fi

    unset re
    unset thp_path
    ;;
esac

  然后添加可执行权限: 

sudo chmod 755 /etc/init.d/disable-transparent-hugepages

 最后添加自启动即可:
sudo update-rc.d disable-transparent-hugepages defaults

MongoDB 3.6 安装详解

标签:red   --   page   linux   12px   安装   更新   base   es2017   

人气教程排行