How to install Redis Server and also restore the Databases of Redis server from RDB file.
wget http://download.redis.io/redis-stable.tar.gztar xvzf redis-stable.tar.gzcd redis-stableMake
Make test
Make install
p/s: after make install it will normally gone into /usr/local/sbin/
Starting Redis
redis-server
Check if Redis is working
$ redis-cli pingPONG
$ redis-cli redis 127.0.0.1:6379> pingPONGredis 127.0.0.1:6379> set mykey somevalueOKredis 127.0.0.1:6379> get mykey”somevalue”
Securing Redis
Just to make sure Redis Server listening to loopback address, do not expose redis server to INTERNET!!!!!
Installing Redis more properly
sudo mkdir /etc/redissudo mkdir /var/redis
sudo cp utils/redis_init_script /etc/init.d/redis_6379
sudo vi /etc/init.d/redis_6379
sudo cp redis.conf /etc/redis/6379.conf
sudo 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!)
- Finally add the new Redis init script to all the default runlevels using the following command:
- sudo update-rc.d redis_6379 defaults
You are done! Now you can try running your instance with:
sudo /etc/init.d/redis_6379 start
Make sure that everything is working as expected:
- Try pinging your instance with redis-cli.
- Do a test save with redis-cli save and check that the dump file is correctly stored into /var/redis/6379/ (you should find a file called dump.rdb).
- Check that your Redis instance is correctly logging in the log file.
- If it’s a new machine where you can try it without problems make sure that after a reboot everything is still working.
Restore.rpd file rom old redis.
There is nothing specific to do. Just install the redis server on the new machine, and edit the configuration file. You just need to change the following parameters to point to the location of the dump file you have just copied.
# The filename where to dump the DB dbfilename mydump.rdb
# The working directory.
# # The DB will be written inside this directory, with the filename specified # above using the ‘dbfilename’ configuration directive.
# # Also the Append Only File will be created inside this directory.
# # Note that you must specify a directory here, not a file name. dir /data/mydirectory/
Finally, the redis server can be started in the normal way.
Leave a Reply
Want to join the discussion?Feel free to contribute!