1. command-line installation
sudo apt-get updatesudoinstall redis-server
2. Start Redis
$redis-server
3208: C -The +: -:42.264# warning:no Configfilespecified, using the default Config. In order to specify a configfileUse redis-server/path/to/redis.conf3208: M -The +: -:42.266* Increased maximum number of open files to10032(It is originally set to1024x768). _._ _.-``__"'-._ _.-`` `. `_."'-._ Redis3.0.6(00000000/0) -bit.-`` .-```. ```\/ _.,_"'-._ ( ' , .-` | `, ) Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'| Port:6379| `-._ `._ / _.-' | pid:3208`-._ `-._ `-./ _.-' _.-'|`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-'| http//Redis.io`-._ `-._`-.__.-'_.-'_.-'|`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-'| `-._ `-._`-.__.-'_.-'_.-'`-._ `-.__.-' _.-' `-._ _.-'`-.__.-' 3208: M -The +: -:42.267# warning:the TCP Backlog setting of511Cannot be enforced because/proc/sys/net/core/somaxconn are set to the lower value of -.3208: M -The +: -:42.267# Server started, Redis version3.0.63208: M -The +: -:42.267# WARNING Overcommit_memory is set to0! Background save may fail under low memory condition. To fix this issue add'vm.overcommit_memory = 1'To/etc/sysctl.conf and ThenReboot or run the command'sysctl Vm.overcommit_memory=1' forThis is take effect.3208: M -The +: -:42.267# WARNING You has Transparent Huge Pages (THP) Support enabledinchYour kernel. This would 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.localinchorder to retain the setting after a reboot. Redis must be restarted after THP is disabled.3208: M -The +: -:42.267* The server is now a ready-to-accept connections on port6379
4. Start the client
$ redis-CLI127.0. 0.1:6379
5. Verify that the installation is successful
127.0. 0.1:6379pingPONG
6.java Connection Test
Public classRedistest { Public Static voidMain (string[] args) {Jedis Jedis=NewJedis ("localhost"); System.out.println ("Redis Connect Success"); //Add StringJedis.set ("Mykey1", "Hahahaha"); System.out.println ("Add Complete" +jedis.get ("Mykey1")); //Add listString[] STRs = {"Haha", "Heihei", "Heheh"}; Jedis.lpush ("List1", STRs); //Get list Datalist<string> list = Jedis.lrange ("List1", 0, 2); for(String va:list) {System.out.println ("List List1:" +va); } showkeys (Jedis); } /*** Show All keys *@paramJedis*/ Private Static voidShowkeys (Jedis jedis) {Set<String> set = Jedis.keys ("*"); Iterator<String> iter =Set.iterator (); while(Iter.hasnext ()) {String key=Iter.next (); System.out.println ("Key:" +key); } }}
Installing Redis under Ubuntu environment