How to rebuild /etc/yum.repos.d in CentOS


If you remove all the files in /etc/yum.repos.d you may see this error. You can restore using the way below.

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
There are no enabled repos.
 Run "yum repolist all" to see the repos you have.
 To enable Red Hat Subscription Management repositories:
     subscription-manager repos --enable <repo>
 To enable custom repositories:
     yum-config-manager --enable <repo>
[22:09][~]# cat /etc/redhat-release
 CentOS Linux release 7.3.1611 (Core)

Check your version and reinstall using this way.

[22:09][~]# yum reinstall http://vault.centos.org/7.3.1611/os/x86_64/Packages/centos-release-7-3.1611.el7.centos.x86_64.rpm


An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.

Gem files will remain installed in /var/www/discourse/vendor/bundle/ruby/2.5.0/gems/mysql2-0.5.2 for inspection.
Results logged to /var/www/discourse/vendor/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0-static/mysql2-0.5.2/gem_make.out
An error occurred while installing mysql2 (0.5.2), and Bundler cannot continue.
Make sure that gem install mysql2 -v '0.5.2' --source 'https://rubygems.org/' succeeds before bundling.
In Gemfile:
mysql2

I found the best way to solve the problem.

I think that you may missing the dev library of mysql:

On ubuntu

sudo apt-get install libmysqlclient-dev

On Red Hat/CentOS and other distributions using yum:

sudo yum install mysql-devel

On Mac OS X with Homebrew:

brew install mysql

Install Tinyproxy on Centos 7

Tinyproxy is a light-weight HTTP/HTTPS proxy daemon for POSIX operating systems.
Designed from the ground up to be fast and yet small, it is an ideal solution for use cases such as embedded deployments where a full featured HTTP proxy is required, but the system resources for a larger proxy are unavailable.

[code lang=”shell”]
yum install -y epel-release
yum update -y
yum -y install tinyproxy
yum install vim -y
[/code]

vim /etc/tinyproxy/tinyproxy.conf

Search for
[code lang=”shell”]
Port 8888
[/code]

Then
Search for:
[code lang=”shell”]
Allow xxx.xxx.xxx.xxx
[/code]
If you want to let it connect from anywhere then just comment it, but I’m not recommended, because it will allow other user connect in.

To test from the Allowed server to the TinyProxy Server

ssh [email protected] -L 1234:localhost:8888 -N

[code lang=”shell”]
curl -I https://juzhax.com/ –proxy [email protected]:8888
[/code]

How to clear nginx cache manually ?

Normally I like to do manually job.

assume that the default path of your nginx cache is /var/cache/nginx

[code lang=”shell”]
find /var/cache/nginx -type f -delete
[/code]

This will clear all your cache in one line.

Delete a single file from nginx cache

If you just want to delete a single file from nginx cache, you can try this.

[code lang=”shell”]
grep -lr ‘//juzhax.com/wp-content/plugins/jetpack/modules/wpgroho.js’ /var/cache/nginx*
[/code]
Then it will show something like this
/var/cache/nginx/8/45/6025f6b505cd8cbc1172d4e541ac3458

You can safely remove by using rm
[code lang=”shell”]
rm /var/cache/nginx/8/45/6025f6b505cd8cbc1172d4e541ac3458
[/code]

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.

[code lang=”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.
[/code]

Solution

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

[code lang=”shell”]
#!/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
[/code]

Make it executable.
Run the following command to ensure that the init script can be used:

[code lang=”shell”]
sudo chmod 755 /etc/init.d/disable-transparent-hugepages
[/code]

[code lang=”shell”]
sudo chkconfig –add disable-transparent-hugepages
[/code]

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

[code lang=”shell”]
[[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.
[/code]

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.