Redis Install
-------------
Introduction
* redis-server - is the Redis Server itself.
* redis-cli - is the command line interface utility to talk with Redis.
* redis-benchmark - is used to check Redis performances.
* redis-check-aof - and redis-check-dump are useful in the rare event of corrupted data files.
#wget http://download.redis.io/redis-stable.tar.gz
#tar xvzf redis-stable.tar.gz
#cd redis-stable
#make
#make install
Configuring redis
-----------------
#mkdir /etc/redis
#mkdir /var/redis
#cp utils/redis_init_script /etc/init.d/redis_6379
#vim /etc/init.d/redis_6379
Make sure to modify REDIS_PORT accordingly to the port you are using. Both the pid file path and the configuration file name depend on the port number
#cp redis.conf /etc/redis/6379.conf
#mkdir /var/redis/6379
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!)
To start the redis
------------------
/etc/init.d/redis_6379 start
To start the redis
------------------
/etc/init.d/redis_6379 stop
To Restart the redis
--------------------
redis-cli -p 6379 save
redis-cli -9 6379 shutdown
/etc/init.d/redis_6379 start
Check if Redis is working
--------------------------
$ redis-cli ping
PONG
$ redis-cli
redis 127.0.0.1:6379> ping
PONG
redis 127.0.0.1:6379> set mykey somevalue
OK
redis 127.0.0.1:6379> get mykey
"somevalue"
Shutdown redis
--------------
$ redis-cli shutdown
Master/Slave Configuration for Redis
------------------------------------
Add the master ip and port in slave configuration file
slave>vim /etc/redis/6479.conf
slaveof <masterip> <masterport>
Ex: slaveof 192.168.2.14 6379
#Restart server for both master and slave
Setting security password for master/slave replication
------------------------------------------------------
redis-master# vim /etc/redis/6379.conf
#Add the below line
requirepass <any_password>
redis-slave# vim /etc/redis/6479.conf
masterauth <above_set_password>
#Restart server for both master and slave
-------------
Introduction
* redis-server - is the Redis Server itself.
* redis-cli - is the command line interface utility to talk with Redis.
* redis-benchmark - is used to check Redis performances.
* redis-check-aof - and redis-check-dump are useful in the rare event of corrupted data files.
#wget http://download.redis.io/redis-stable.tar.gz
#tar xvzf redis-stable.tar.gz
#cd redis-stable
#make
#make install
Configuring redis
-----------------
#mkdir /etc/redis
#mkdir /var/redis
#cp utils/redis_init_script /etc/init.d/redis_6379
#vim /etc/init.d/redis_6379
Make sure to modify REDIS_PORT accordingly to the port you are using. Both the pid file path and the configuration file name depend on the port number
#cp redis.conf /etc/redis/6379.conf
#mkdir /var/redis/6379
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!)
To start the redis
------------------
/etc/init.d/redis_6379 start
To start the redis
------------------
/etc/init.d/redis_6379 stop
To Restart the redis
--------------------
redis-cli -p 6379 save
redis-cli -9 6379 shutdown
/etc/init.d/redis_6379 start
Check if Redis is working
--------------------------
$ redis-cli ping
PONG
$ redis-cli
redis 127.0.0.1:6379> ping
PONG
redis 127.0.0.1:6379> set mykey somevalue
OK
redis 127.0.0.1:6379> get mykey
"somevalue"
Shutdown redis
--------------
$ redis-cli shutdown
Master/Slave Configuration for Redis
------------------------------------
Add the master ip and port in slave configuration file
slave>vim /etc/redis/6479.conf
slaveof <masterip> <masterport>
Ex: slaveof 192.168.2.14 6379
#Restart server for both master and slave
Setting security password for master/slave replication
------------------------------------------------------
redis-master# vim /etc/redis/6379.conf
#Add the below line
requirepass <any_password>
redis-slave# vim /etc/redis/6479.conf
masterauth <above_set_password>
#Restart server for both master and slave