Monday, 7 March 2016

Install MongoDB On CentOS AWS Server


Enable MongoDB Repo:


echo "[MongoDB]
name=MongoDB Repository
baseurl=http://downloads-distro.mongodb.org/repo/redhat/os/x86_64
gpgcheck=0
enabled=1" | sudo tee -a /etc/yum.repos.d/mongodb.repo

sudo yum install -y mongodb-org-server mongodb-org-shell mongodb-org-tools
sudo nano /etc/security/limits.conf

# End of file:
* soft nofile 64000
* hard nofile 64000
* soft nproc 32000
* hard nproc 32000

:wq


sudo nano /etc/security/limits.d/90-nproc.conf
## End of file

* soft nproc 32000
* hard nproc 32000

:wq


To check disk name :
fdisk -l

## edit here disk name like sda sdb sdc etc

echo 'ACTION=="add", KERNEL=="xvda1", ATTR{bdi/read_ahead_kb}="16"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules

sudo service mongod start
sudo service mongod status
mongo
vim /etc/init.d/disable-transparent-hugepages

####

#!/bin/sh
### 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

    unset thp_path
    ;;
esac


:wq


sudo chmod 755 /etc/init.d/disable-transparent-hugepages
chkconfig --add disable-transparent-hugepages
/etc/init.d/mongod restart
/etc/init.d/mongod status
chkconfig mongod on
reboot
/etc/init.d/mongod status
mongo

> show dbs
> exit
/etc/init.d/mongod restart

==============================


https://docs.mongodb.org/ecosystem/platforms/amazon-ec2/
https://docs.mongodb.org/manual/tutorial/transparent-huge-pages/


echo 'ACTION=="add", KERNEL=="xvda1", ATTR{bdi/read_ahead_kb}="16"' | sudo tee -a /etc/udev/rules.d/85-ebs.rules

Create the init.d script.

Create the following file at /etc/init.d/disable-transparent-hugepages:

#!/bin/sh
### 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

    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 --add disable-transparent-hugepages




No comments: