#http://redis.io/
#http://download.redis.io/releases/redis-2.8.19.tar.gz

cd /files
wget www.pccc.com/downloads/redis/redis-2.8.19.tar.gz
cd /usr/src
tar zxvf /files/redis-2.8.19.tar.gz

cd redis-2.8.19

#BASED ON http://redis.io/topics/quickstart
make
make test
make install

mkdir /etc/redis
mkdir /var/redis

cp utils/redis_init_script /etc/rc.d/init.d/redis_6379
chmod +x /etc/rc.d/init.d/redis_6379

vi /etc/rc.d/init.d/redis_6379
#Add -a "password" to your stop command 

#APPEARS TO BE THERE - vi /etc/rc.d/init.d/redis_6379 and add the port as 6379
cp redis.conf /etc/redis/6379.conf

Edit the configuration file, making sure to perform the following changes:

    Set daemonize to yes (by default it is set to no).
    Set the pidfile to /var/run/redis_6379.pid (modify the port if needed).
    Change the port accordingly. In our example it is not needed as the default port is already 6379.
    Set your preferred loglevel.
    Set the logfile to /var/log/redis_6379.log
    Set the dir to /var/redis/6379 (very important step!)
    Add a password
    Set how much RAM to use with maxmemory in bytes - 6gb = 6442450944

mkdir /var/redis/6379

add log to logrotate.conf

/var/log/redis_6379.log {
    missingok
    weekly
    create 0600 root root
    rotate 1
}

#SET TO START IN RUNTIME 3
cd /etc/rc.d/rc0.d; ln -s ../init.d/redis_6379 K31redis
cd /etc/rc.d/rc3.d; ln -s ../init.d/redis_6379 S31redis  


#Start it up
/etc/rc.d/init.d/redis_6379 start


#Address these issues:
#

#1
[12890] 07 Jan 15:52:39.386 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

NOTE: This requires more swap than physical ram

See https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Performance_Tuning_Guide/s-memory-captun.html for more information

- To add more swap with a file:
fallocate -l 12GB /mnt/12GB.swap
# dd if=/dev/zero of=/files/backups/24GB.swap bs=1024 count=25165824 
mkswap /mnt/12GB.swap 
swapon /mnt/12GB.swap 
echo "/mnt/12GB.swap          none                    swap    swap    defaults        0  0" >> /etc/fstab

#2
#[12890] 07 Jan 15:52:39.387 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

Add transparent_hugepage=never to your grub.conf for the kernel so that it is disabled BEFORE the service starts.  

see http://unix.stackexchange.com/questions/99154/disable-transparent-hugepages

#3
#[12890] 07 Jan 15:52:39.387 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

see http://www.beingroot.com/articles/apache/socket-backlog-tuning-for-apache
