Aklımda Kalası Kelimeler

* давайте работать вместе
* Zarf ve Mazruf, Zerafet(xHoyratlık) ile aynı kökten(za-ra-fe) gelir
* Bedesten
* Suç subuta ermiştir - Suç sabit olmuştur

26 Ocak 2015 Pazartesi

Redis, Centos 6.5 & 7

Redis rpm paketleri: http://www.rpmfind.net/linux/rpm2html/search.php?query=redis
2.6 dan yüksek Redis sürümü için: https://robotsystematic.com/redis-higher-than-2-6-in-centos
Ref: http://sharadchhetri.com/2014/10/04/install-redis-server-centos-7-rhel-7/
original: https://troubleshootguru.wordpress.com/2014/11/19/how-to-install-redis-on-a-centos-6-5-centos-7-0-server-2/
Redis is an open source, BSD licensed, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.

How To Install Redis on Centos 7
# wget -r –no-parent -A ‘epel-release-*.rpm’ http://dl.fedoraproject.org/pub/epel/7/x86_64/e/
# rpm -Uvh dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-*.rpm

It will create two epel’s repo file inside /etc/yum.repos.d
These are –
1. epel.repo
2.epel-testing.repo
Install Redis with Yum
# yum install redis php-pecl-redis

Enable Redis service to start on boot
# systemctl enable redis-server.service

Disable Redis service from start on boot
# systemctl disable redis-server.service

Start/Stop/Restart Redis
# systemctl start redis-server.service
# systemctl stop redis-server.service
# systemctl restart redis-server.service

Check if Redis is Running
#systemctl is-active redis-server.service

How To Install Redis on Centos 6.5
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm
# yum install redis php-pecl-redis
# service redis start
# chkconfig redis on

Now verify its set to start at boot
# chkconfig –list redis
redis 0:off 1:off 2:on 3:on 4:on 5:on 6:off

To make sure redis is working, run command “redis-cli ping” from command line. If you get result “PONG”, that shows redis is working.
Now install redis PHP extension, using following command.
# pecl install redis

Now open php.ini ( /usr/local/lib/php.ini on cPanel servers ) file and add the following line to it
extension=redis.so
Now restart Apache to apply the changes to php.ini file.
Now that was pretty simple, but lets say you want to add a second instance to your server on a different port

Add a second instance of Redis
# cp redis.conf redis2.conf && cp /etc/init.d/redis /etc/init.d/redis2

Change
# vim /etc/init.d/redis2
pidfile=”/var/run/redis/redis.pid” to pidfile=”/var/run/redis/redis2.pid”
REDIS_CONFIG=”/etc/redis.conf” to REDIS_CONFIG=”/etc/redis2.conf”

Change
# vim /etc/redis2.conf
port 6379 to port 6380
unixsocket /tmp/redis.sock to unixsocket /tmp/redis2.sock

# service redis2 start

To install a web interface for redis
# cd /downloads/
# git clone https://github.com/ErikDubbelboer/phpRedisAdmin.git
# cd phpRedisAdmin/includes
# cp config.sample.inc.php config.inc.php
Make sure the setting are correct
# vim config.inc.php
Lets add the RedisAdmin configuration file to Apache
# vim /etc/httpd/conf.d/redisadmin.conf
Now add the following
#
# Web Interface for RedisAdmin
#

Order Deny,Allow
Deny from all
Allow from 127.0.0.1
Allow from

Alias /redisAdmin /downloads/phpRedisAdmin
Alias /redisadmin /downloads/phpRedisAdmin
View your RedisAdmin Section

http://example.tld/redisadmin

Create a Bash Script to make sure Redis is Running
vim /scripts/redis-check.sh
Add the following for the above installation

#!/bin/bash
PS=$(which ps)
GREP=$(which grep)
WHEN=$(date +”%Y-%m-%d-%H:%M:%S”)
if ! $PS aux | $GREP “redis.conf” | $GREP -v grep 2>&1 > /dev/null; then
/etc/init.d/redis restart
echo ‘Restarted Redis @’ $WHEN
fi
#Check Second instance
if ! $PS aux | $GREP “redis2.conf” | $GREP -v grep 2>&1 > /dev/null; then
/etc/init.d/redis2 restart
echo ‘Restarted Redis2 @’ $WHEN
fi
Make the Script executable

# chmod +x /scripts/redis-check.sh
Add your script to your cron to run every 3 minutes or so

# vim /var/spool/cron/root
*/3 * * * * /bin/bash /script/redis-check.sh >> /var/log/redis-check.log