Av. Circular, Nº. 1192 - Goiânia contato[@]cuidadodigital.com.br
Estamos pronto para ajudar o seu negócio crescer.

Tutorial: MongoDB em Docker No CentOS 7

Instalação e configuração e ajuste fino do MongoDB em Docker no Centos& Procedimento de instalação e exposição de porta. docker run --name mongoDB -p 27017:27017 -v /storage/mongoDB:/data/db -d mongo:3.0-wheezy Conectar no mongo via terminal para criação de usuário docker exec -it mongoDB mongo admin Criação de usuário: db.createUser({ user: 'MyUser', pwd: 'MyPass', roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] });   Ajuste findo de BlockSize para melhor otimização do Mongo DB, ao receber a seguinte mensagem proceda: WARNING: Readahead for /data/db is set to 4096KB We suggest setting it to 256KB (512 sectors) or less http://dochub.mongodb.org/core/readahead # vim /usr/lib/tuned/throughput-performance/tuned.conf Localize e o readahead  e altere seu valor para 256 Para os seguintes ajustes, proceda:

WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'. We suggest setting it to 'never' WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'. We suggest setting it to 'never'
Create the init.d script.
Create the following file at /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
2

Make it executable.

Run the following command to ensure that the init script can be used:
sudo chmod 755 /etc/init.d/disable-transparent-hugepages
3

Configure your operating system to run it on boot.

Use the appropriate command to configure the new init script on your Linux distribution.
Distribution Command
Ubuntu and Debian
sudo update-rc.d disable-transparent-hugepages defaults
SUSE
sudo insserv /etc/init.d/disable-transparent-hugepages
Red Hat, CentOS, Amazon Linux, and derivatives
sudo chkconfig