Absrtact: Redis is a very popular memory database in the industry, and is generally used as the system's intermediate caching system to improve the throughput and responsiveness of the overall business system. This article will briefly describe the main process of installation and give a brief test code.
1. System environment and version number description
Operating system Choose Ubuntu 14.04, redis version number select the latest stable version number 2.8.9. The client chooses the Redis Java version number Jedis 2.4.2.
2. Installation steps for Redis
A. Download the Redis installation package
wget http://download.redis.io/releases/redis-2.8.9.tar.gz
B. Under the folder. Unzip according to the package, generate a new folder redis-2.8.9
Tar Xvfz redis-2.8.9.tar.gz
C. Enter the folder after decompression to compile
CD redis-2.8.9
sudo make
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvymx1zwhlyxj0mja=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
Description: Assuming there is no obvious error, the compilation succeeds
D. Installation
sudo make install
Description: Under normal circumstances, in Ubuntu system. are required to use sudo to elevate permissions.
E. After a successful installation. Ability to perform tests to verify that Redis is functioning properly
sudo make test
F. Starting the Redis service
Find the folder for Redis installation: Find/-name ' redis* '------look for files with Redis in the name under the root folder
After finding it, Redis was found to be installed under the/usr/local/bin/folder.
Next. To start the Redis service:
/usr/local/bin/redis-server
Note: From the above, it is possible to find the boot port as the default of 6379. The user is able to specify a detailed configuration file at boot time and specify the port to start in.
G. Viewing the Redis process
Ps-ef | grep Redis
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvymx1zwhlyxj0mja=/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/southeast ">
Description: Assume that you can see the process. The description starts normally.
3. Simple Redis test procedure
Readers can create their own Eclipse project and introduce Jedis's client package. Test procedures such as the following:
public class Redistest {private Jedis Jedis = null;private String key1 = "Key1";p rivate string key2 = "Key2";p ublic RedisT EST () {Jedis = new Jedis ("localhost");} public static void Main (string[] args) {redistest redistest = new Redistest (); redistest.isreachable (); Redistest.testdata (); Redistest.deldata (); Redistest.testexpire ();} public Boolean isreachable () {Boolean isreached = true;try {jedis.connect (); jedis.ping ();//Jedis.quit ();} catch ( Jedisconnectionexception e) {e.printstacktrace (); isreached = false;} System.out.println ("The current Redis Server is Reachable:" + isreached); return isreached;} public void TestData () {Jedis.set ("Key1", "data1"); System.out.println ("Check Status of data existing:" + jedis.exists (key1)); System.out.println ("Get Data key1:" + jedis.get ("Key1")); long s = Jedis.sadd (Key2, "data2"); System.out.println ("Add key2 Data:" + jedis.scard (Key2) + "with status" + s);} public void Deldata () {Long Count = Jedis.del (Key1); System.out.println ("Get Data Key1 after it is deleteD: "+ jedis.get (Key1));} public void Testexpire () {Long Count = Jedis.expire (Key2, 5); try {thread.currentthread (). Sleep (6000);} catch ( Interruptedexception e) {e.printstacktrace ();} if (jedis.exists (Key2)) {System.out.println ("Get Key2 in Expire Action:" + jedis.scard (Key2));} else {System.out.println ("Key2 is expired with value:" + Jedis.scard (Key2));}}}
4. Summary
This article provides a brief visual introduction to Redis installation and deployment. Based on the simple test procedure of Jedis, the basic usage of Redis is explained. A lot of other stuff. Be able to consult related documents.
Redis Installation and simple test