1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      Linux中怎么安裝MongoDB

      本篇文章給大家分享的是有關(guān)Linux中怎么安裝MongoDB,小編覺得挺實用的,因此分享給大家學(xué)習(xí),希望大家閱讀完這篇文章后可以有所收獲,話不多說,跟著小編一起來看看吧。

      創(chuàng)新互聯(lián)2013年開創(chuàng)至今,先為西林等服務(wù)建站,西林等地企業(yè),進(jìn)行企業(yè)商務(wù)咨詢服務(wù)。為西林企業(yè)網(wǎng)站制作PC+手機(jī)+微官網(wǎng)三網(wǎng)同步一站式服務(wù)解決您的所有建站問題。

      1.安裝MongoDB

             mongoDB的tar包下載地址:https://www.mongodb.com/download-center#atlas

           解壓安裝包   tar -zxvf     xxxxxxxxxx.tar

           移動到安裝目錄   mv mongodb-linux-x86_64-xxx    /usr/local/mongodb

            添加環(huán)境變量   echo "export PATH=\$PATH:/usr/local/mongodb/bin【解壓后移動過去會存在一個目錄,所以需要配置】" > /etc/profile.d/mongodb.sh    (這個里面要小心了!)

           使環(huán)境變量生效   source /etc/profile.d/mongodb.sh

           創(chuàng)建Mongodb用戶和組  useradd -r -M -s /sbin/nologin mongod

          ***創(chuàng)建啟動數(shù)據(jù)庫和啟動日志 mkdir -p /data/mongodb/{db,log}/

           修改權(quán)限        chown -R mongod:mongod/data/mongodb/

           配置mongoDB配置文件:    vi /etc/mongod.conf

          #mongod.conf

          #for documentation of all options, see:

         #  http://docs.mongodb.org/manual/reference/configuration-options/

          #where to write logging data.

         systemLog:

           destination: file

           logAppend: true

           path: /data/mongodb/log/mongod.log

          #Where and how to store data.

         storage:

           dbPath: /data/mongodb/db

           journal:

             enabled: true

         #  engine:

         #  mmapv1:

         #  wiredTiger:

          #how the process runs

         processManagement:

           fork: true  # fork and run inbackground

           pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile

          #network interfaces

         net:

           port: 27017

           bindIp: 127.0.0.1  # Listen tolocal interface only, comment to listen on all interfaces.

         #security:

         #operationProfiling:

         #replication:

         #sharding:

         ## Enterprise-Only Options

         #auditLog:

         #snmp:

      備注:

      如果MongoDB端口不在27017-27019,28017-28019之間,需要執(zhí)行以下步驟:

      # yum -y install policycoreutils-python

      # semanage port -a -t mongod_port_t -p tcp   27017

      創(chuàng)建MongoDB自啟動腳本     vi /etc/init.d/mongod

         #!/bin/bash

          #mongod - Startup script for mongod

          #chkconfig: 35 85 15

          #description: Mongo is a scalable, document-oriented database.

          #processname: mongod

          #config: /etc/mongod.conf

          #pidfile: /var/run/mongodb/mongod.pid

          ./etc/rc.d/init.d/functions

          #things from mongod.conf get there by mongod reading it

          #NOTE: if you change any OPTIONS here, you get what you pay for:

          #this script assumes all options are in the config file.

         CONFIGFILE="/etc/mongod.conf"

         OPTIONS=" -f $CONFIGFILE"

         SYSCONFIG="/etc/sysconfig/mongod"

         PIDFILEPATH=`awk -F'[:=]' -v IGNORECASE=1'/^[[:blank:]]*(processManagement\.)?pidfilepath[[:blank:]]*[:=][[:blank:]]*/{print$2}' "$CONFIGFILE" | tr -d "[:blank:]\"'" | cut -d"#" -f 1`

         mongod=${MONGOD-/usr/local/mongodb/bin/mongod}

         MONGO_USER=mongod

         MONGO_GROUP=mongod

         if [ -f "$SYSCONFIG" ]; then

             . "$SYSCONFIG"

         fi

         PIDDIR=`dirname $PIDFILEPATH`

          #Handle NUMA access to CPUs (SERVER-3574)

          #This verifies the existence of numactl as well as testing that the commandworks

         NUMACTL_ARGS="--interleave=all"

         if which numactl >/dev/null 2>/dev/null && numactl$NUMACTL_ARGS ls / >/dev/null 2>/dev/null

         then

             NUMACTL="numactl $NUMACTL_ARGS"

         else

             NUMACTL=""

         fi

         start()

          {

           # Make sure the default pidfile directory exists

           if [ ! -d $PIDDIR ]; then

             install -d -m 0755 -o $MONGO_USER -g $MONGO_GROUP $PIDDIR

           fi

           # Recommended ulimit values for mongod or mongos

           # Seehttp://docs.mongodb.org/manual/reference/ulimit/#recommended-settings

           #

           ulimit -f unlimited

           ulimit -t unlimited

           ulimit -v unlimited

           ulimit -n 64000

           ulimit -m unlimited

           ulimit -u 64000

           echo -n $"Starting mongod: "

           daemon --user "$MONGO_USER" --check $mongod "$NUMACTL$mongod $OPTIONS >/dev/null 2>&1"

           RETVAL=$?

           echo

           [ $RETVAL -eq 0 ] && touch /var/lock/subsys/mongod

          }

         stop()

          {

           echo -n $"Stopping mongod: "

           mongo_killproc "$PIDFILEPATH" $mongod

           RETVAL=$?

           echo

           [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/mongod

          }

         restart () {

                 stop

                 start

          }

          #Send TERM signal to process and wait up to 300 seconds for process to go away.

          #If process is still alive after 300 seconds, send KILL signal.

          #Built-in killproc() (found in /etc/init.d/functions) is on certain versions ofLinux

          #where it sleeps for the full $delay seconds if process does not respond fastenough to

          #the initial TERM signal.

         mongo_killproc()

          {

           local pid_file=$1

           local procname=$2

           local -i delay=300

           local -i duration=10

           local pid=`pidofproc -p "${pid_file}" ${procname}`

           kill -TERM $pid >/dev/null 2>&1

           usleep 100000

           local -i x=0

           while [ $x -le $delay ] && checkpid $pid; do

             sleep $duration

             x=$(( $x + $duration))

           done

           kill -KILL $pid >/dev/null 2>&1

           usleep 100000

           checkpid $pid # returns 0 only if the process exists

           local RC=$?

           [ "$RC" -eq 0 ] && failure "${procname}shutdown" || rm -f "${pid_file}"; success "${procname}shutdown"

           RC=$((! $RC)) # invert return code so we return 0 when process is dead.

           return $RC

          }

         RETVAL=0

         case "$1" in

           start)

             start

             ;;

           stop)

             stop

             ;;

           restart|reload|force-reload)

             restart

             ;;

           condrestart)

             [ -f /var/lock/subsys/mongod ] && restart || :

             ;;

           status)

             status $mongod

             RETVAL=$?

             ;;

           *)

             echo "Usage: $0{start|stop|status|restart|reload|force-reload|condrestart}"

             RETVAL=1

         esac

         exit $RETVAL

      設(shè)置MongoDB服務(wù)開機(jī)自啟動

         chmod +x /etc/init.d/mongod

         chkconfig mongod on

          啟動MongoDB服務(wù)

         service mongod start

      如果啟動不成功:

         主要查看     啟動腳本 .sh 文件中的配置的環(huán)境變量是否正確,  同時查看db  log的權(quán)限是否是腳本中配置的用戶和組,同時可執(zhí)行,我給的777

      驗證啟動成功:

      service mongod status

         mongod.service - SYSV: Mongo is a scalable, document-oriented database.

            Loaded: loaded (/etc/rc.d/init.d/mongod)

            Active: active (running) since Fri 2017-12-15 23:34:50 EST; 31min ago

           Process: 7648 ExecStop=/etc/rc.d/init.d/mongod stop (code=exited,status=0/SUCCESS)

           Process: 7677 ExecStart=/etc/rc.d/init.d/mongod start (code=exited,status=0/SUCCESS)

          Main PID: 7688 (mongod)

            CGroup: /system.slice/mongod.service

                     └─7688/usr/local/mongodb/mongodb-linux-x86_64-3.6.0/bin/mongod -f /etc/mongod.conf

         Dec 15 23:34:49 localhost.localdomain systemd[1]: Starting SYSV: Mongois a scalable, document-oriented database....

         Dec 15 23:34:49 localhost.localdomain runuser[7684]:pam_unix(runuser:session): session opened for user mongod by (uid=0)

         Dec 15 23:34:50 localhost.localdomain mongod[7677]: Starting mongod:[  OK ]

         Dec 15 23:34:50 localhost.localdomain systemd[1]: Started SYSV: Mongo isa scalable, document-oriented database..

      Mongodb編輯:

      輸入mongo:

         > db.foo.find();

          {"_id" : ObjectId("5a34a3de8420293d5f46b0ee"),"name" : "xiaonanhai", "age" : "23" }

         > show dbs;

         admin   0.000GB

         config  0.000GB

         local   0.000GB

         test    0.000GB

         >

      END

      以上就是Linux中怎么安裝MongoDB,小編相信有部分知識點可能是我們?nèi)粘9ぷ鲿姷交蛴玫降摹OM隳芡ㄟ^這篇文章學(xué)到更多知識。更多詳情敬請關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。


      分享題目:Linux中怎么安裝MongoDB
      本文鏈接:http://ef60e0e.cn/article/gsscde.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        嘉善县| 永康市| 阿拉善左旗| 关岭| 衡东县| 天峨县| 洪湖市| 海南省| 石渠县| 武穴市| 建瓯市| 岗巴县| 玉门市| 自治县| 察哈| 内江市| 洮南市| 宁城县| 洪雅县| 北流市| 宣化县| 芦山县| 宁陕县| 贡嘎县| 文化| 民县| 铅山县| 崇明县| 沙田区| 富平县| 华宁县| 锡林浩特市| 郧西县| 栾城县| 北票市| 文登市| 旬阳县| 永春县| 乌兰县| 宁陵县| 沧州市|