Tag Archives: warning

Install NodeJS and MongoDB on CentOS 7

As always, I’m sharing my personal notes here. I’ve used virtual machines for development since the first version of VMware. I’ve been using DigitalOcean’s services for some time. I generally use their CentOS 7 install.

NodeJS

Update: I have newer install instructions here.

Edit: Removed old instructions.

Some native add-ons from npm require build tools. If you anticipate needing those, install:

yum -y install gcc-c++ make

MongoDB

Installing MongoDB’s community edition requires creating a yum repo file, a a system configuration file, and then a reboot.

vim /etc/yum.repos.d/mongodb-org-3.2.repo

and fill it with the following text:

[mongodb-org-3.2]
name=MongoDB Repository
baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/
gpgcheck=1
enabled=1
gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

which allows MongoDB to be installed with a simple:

yum install -y mongodb-org
service mongod start
chkconfig mongod on

Getting Rid of Warnings

If you use the mongo client, you’ll notice the following warnings:

Server has startup warnings:
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 64000 files. Number of processes should be at least 32000 : 0.5 times number of files.
2016-09-04T18:27:20.393+0000 I CONTROL  [initandlisten]

The soft rlimits warning can be fixed by creating a file:

 vim /etc/security/limits.d/90-nproc.conf

and putting the following line in it:

mongod     soft    nproc     64000

and rebooting the system.

The transparent_hugepage warnings can be fixed by creating a file:

vim /etc/init.d/disable-transparent-hugepages

and filling it with:

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

ensuring it runs at startup:

chmod 755 /etc/init.d/disable-transparent-hugepages
chkconfig --add disable-transparent-hugepages

and then, finally, rebooting. The mongo client should start without warnings now:

 
MongoDB shell version: 3.2.9
connecting to: test
>

 

 

Setting MySQL to Default to Unicode

When running unit tests in Django, I was getting a strange MySQL failure when attempting to insert non-ASCII Unicode characters into the database, for example:

[code light=”true”]
Warning: Incorrect string value: ‘\xE2\x89\xA5 %’ for column ‘value’ at row 1
[/code]

What is happening is that Django creates a new schema from scratch for testing. This new schema picks up the MySQL defaults. All my test tables ended up with Latin-1 encoding instead of UTF-8 encoding.

I needed to change mysqld to default to unicode internally so Django will run unit tests involving correctly.

In /etc/my.cnf I added the following:

[code lang=”c” light=”true”]
[client]
default-character-set=utf8

[mysql]
default-character-set=utf8

[mysqld]
collation-server = utf8_unicode_ci
init-connect=’SET NAMES utf8′
character-set-server = utf8
[/code]

h/t stackoverflow