DOWNLOAD

INSTALL STEP

당근

Install MongoDB Community on Red Hat or CentOS using .tgz Tarball ( Version 5.0 )

Install MongoDB Community Edition

  1. Prerequisites
[root@mongo ~]# sudo yum -y install libcurl openssl xz-libs
  1. OS 설정

    ##Create User
    groupadd mongo
    useradd -g mongo mongo
    
    ##limit.conf
    cat << 'EOF' | sudo tee -a /etc/security/limits.conf
    mongo soft fsize unlimited # (file size)
    mongo hard fsize unlimited # (file size)
    mongo soft cpu unlimited # (cpu time)
    mongo hard cpu unlimited # (cpu time)
    mongo soft as unlimited # (virtual memory size)
    mongo hard as unlimited # (virtual memory size)
    mongo soft nofile 64000 # (open files)
    mongo hard nofile 64000 # (open files)
    mongo soft rss unlimited # (max resident set size)
    mongo hard rss unlimited # (max resident set size)
    mongo soft nproc 64000 # (processes/threads)
    mongo hard nproc 64000 # (processes/threads)
    mongo soft memlock unlimited # (locked-in-memory size)
    mongo hard memlock unlimited # (locked-in-memory size)
    EOF
    
    ##swap
    cat << 'EOF' | sudo tee -a /etc/sysctl.conf
    vm.swappiness = 1
    EOF
    
    ##hugepage 비활성화
    sudo su
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    echo never > /sys/kernel/mm/transparent_hugepage/defrag
    
    vi /etc/default/grub
    GRUB_CMDLINE_LINUX="elevator=deadline audit=1 crashkernel=auto rd.lvm.lv=rootvg/rootlv rd.lvm.lv=rootvg/swaplv rd.lvm.lv=rootvg/usrlv transparent_hugepage=never"
    grub2-mkconfig -o /boot/grub2/grub.cfg
    
    ##재기동
    reboot
    
    
  2. Procedure

    [root@mongo ~]# tar -zxvf mongodb-linux-x86_64-rhel70-5.0.14.tgz
    
  3. Ensure the binaries are in a directory listed in your PATH enviorment variable.

    [root@mongo ~]# cp mongodb-linux-x86_64-rhel70-5.0.14/bin/* /usr/local/bin/
    [root@mongo ~]# sudo ln -s mongodb-linux-x86_64-rhel70-5.0.14/bin/* /usr/local/bin/
    
  4. Install the MongoDB Shell(mongosh)

    ## Data / Log Directory 생성
    mkdir -p /mongo/data1/ /mongo/data1_log
    chown -R mongo.mongo /mongo
    
    ##CONF
    cat << 'ENDCONF' | sudo tee /etc/mongod.conf
    systemLog:
     destination: file
     path: /mongo/data1_log/mongod.log
     logAppend: true
    
    storage:
     dbPath:  /mongo/data1/
     engine: wiredTiger
     wiredTiger:
      engineConfig:
       cacheSizeGB: 3.5
       directoryForIndexes: true
     journal:
      enabled: true
    
    processManagement:
     fork: true
     pidFilePath: /mongo/mongod.pid
    
    ENDCONF
    
  5. Start MongoDB

    [root@mongo ~]# mongod --config /etc/mongod.conf
    about to fork child process, waiting until server is ready for connections.
    forked process: 2695
    child process started successfully, parent exiting
    
    [root@mongo ~]# ps -ef | grep mongo
    root        861      1  0 13:18 ?        00:00:00 /sbin/dhclient -H mongo -1 -q -lf /var/lib/dhclient/dhclient--eth0.lease -pf /var/run/dhclient-eth0.pid eth0
    root       2695      1  5 13:27 ?        00:00:00 mongod --config /etc/mongod.conf
    root       2732   2286  0 13:27 pts/0    00:00:00 grep --color=auto mongo
    
    [root@mongo ~]# mongo
    MongoDB shell version v5.0.14
    connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
    Implicit session: session { "id" : UUID("2ee3dcd1-ab2c-4d86-a6ab-d1ff9dc7c92c") }
    MongoDB server version: 5.0.14
    ================
    Warning: the "mongo" shell has been superseded by "mongosh",
    which delivers improved usability and compatibility.The "mongo" shell has been deprecated and will be removed in
    an upcoming release.
    For installation instructions, see
    <https://docs.mongodb.com/mongodb-shell/install/>
    ================
    Welcome to the MongoDB shell.
    For interactive help, type "help".
    For more comprehensive documentation, see
            <https://docs.mongodb.com/>
    Questions? Try the MongoDB Developer Community Forums
            <https://community.mongodb.com>
    ---
    The server generated these startup warnings when booting: 
            2022-12-07T13:27:11.557+09:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
            2022-12-07T13:27:11.557+09:00: You are running this process as the root user, which is not recommended
            2022-12-07T13:27:11.557+09:00: This server is bound to localhost. Remote systems will be unable to connect to this server. Start the server with --bind_ip <address> to specify which IP addresses it should serve responses from, or with --bind_ip_all to bind to all interfaces. If this behavior is desired, start the server with --bind_ip 127.0.0.1 to disable this warning
            2022-12-07T13:27:11.557+09:00: Soft rlimits for open file descriptors too low
            2022-12-07T13:27:11.557+09:00:         currentValue: 1024
            2022-12-07T13:27:11.557+09:00:         recommendedMinimum: 64000
    ---
    ---
            Enable MongoDB's free cloud-based monitoring service, which will then receive and display
            metrics about your deployment (disk utilization, CPU, operation statistics, etc).
    
            The monitoring data will be available on a MongoDB website with a unique URL accessible to you
            and anyone you share the URL with. MongoDB may use this information to make product
            improvements and to suggest MongoDB products and deployment options to you.
    
            To enable free monitoring, run the following command: db.enableFreeMonitoring()
            To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
    ---