Sunday, 5 April 2015

Install and configure redis in ubuntu


Before install redis, make sure all your packages are upto date, to make installation easy.

Step 1: Update all packages.
apt-get update

Step 2: Install redis server.
apt-get install redis-server

Step 3: Once installaion successfull, start redis server using command “redis-server
“.
root@hk-Inspiron-N5010:~# redis-server 
[4271] 13 Mar 22:44:11.090 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 
[4271] 13 Mar 22:44:11.092 * Max number of open files set to 10032 
[4271] 13 Mar 22:44:11.092 # Warning: 32 bit instance detected but no memory limit set. Setting 3 GB maxmemory limit with 'noeviction' policy now. 
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 2.8.4 (00000000/0) 32 bit 
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in stand alone mode 
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379 
 |    `-._   `._    /     _.-'    |     PID: 4271 
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

[4271] 13 Mar 22:44:11.093 # Server started, Redis version 2.8.4 
[4271] 13 Mar 22:44:11.093 # 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. 
[4271] 13 Mar 22:44:11.093 * The server is now ready to accept connections on port 6379 


Note :
In order to start Redis with a configuration file use the full path of the configuration file as first argument, like "redis-server /etc/redis.conf".

Step 4: Check redis is working or not.
Redis provides a command line utility called “redis-cli”. The first thing to do in order to check if Redis is working properly is sending a PING command using redis-cli.

root@hk-Inspiron-N5010:~# redis-cli ping 
PONG 

If you want to run redis-cli in interactive mode, just run “redis-cli” without any arguments.

root@hk-Inspiron-N5010:~# redis-cli 
127.0.0.1:6379> ping 
PONG 
127.0.0.1:6379> set myKey ptr 
OK 
127.0.0.1:6379> get myKey 
"ptr" 
127.0.0.1:6379> 


Prevoius                                                 Next                                                 Home

No comments:

Post a Comment