1. Create a virtual machine and install openSUSE-11.1
2. After installation, close the firewall so that SSH can be connected.
Susefirewall2 stop
3. Install redis after the SSH connection
Enter the directory:
CD/opt/
Follow the official instructions as follows:
$ Wget http://redis.googlecode.com/files/redis-2.4.8.tar.gz
$ Tar xzf redis-2.4.8.tar.gz
$ Redis-2.4.8 CD
$ Make
The following error is reported during direct installation.
Linux-1dw5:/opt/redis-2.4.8 # Make
Cd src & make all
Make [1]: Entering directory '/opt/redis-2.4.8/src'
Make hiredis
Make [2]: Entering directory '/opt/redis-2.4.8/deps/hiredis'
Gcc-STD = c99-pedantic-C-O3-FPIC-wall-w-wstrict-prototypes-wwrite-strings-g-ggdb net. c
Make [2]: GCC: Command not found
Make [2]: *** [net. O] Error 127
Make [2]: Leaving directory '/opt/redis-2.4.8/deps/hiredis'
Make [1]: *** [dependencies] Error 2
Make [1]: Leaving directory '/opt/redis-2.4.8/src'
Make: *** [all] Error 2
Gcc is not installed.
Find the information and find the command zypper install gcc.
4. Install gcc
Run the following command:
Zypper install gcc
Download the relevant files, install them, and follow these steps.
After installation, run the following command:
Which gcc
Check whether gcc is successfully installed.
Run the command: which gcc
The returned result is as follows:
/Usr/bin/gcc
Gcc is successfully installed.
5. Go to the redis directory and execute make
It may take several minutes to start installation,
Prompt that the installation is successful.
6. Start the redis Service
Src/redis-server
7. Open the official Client
Src/redis-cli
Run
Set foo bar
Get foo
By now, the simplest redis environment has been set up.
Java client Test
Package com. yanek. study. redis;
Import redis. clients. jedis. Jedis;
Public class Test {
/**
*
* @ Author Administrator/2012-2-22/10:48:03 AM
*/
Public static void main (String [] args ){
Jedis jedis = new Jedis ("192.168.195.130 ");
Jedis. set ("id", "10000 ");
String id = jedis. get ("id ");
Jedis. set ("name", "javaboy2012 ");
String name = jedis. get ("name ");
System. out. println ("id =" + id );
System. out. println ("name =" + name );
}
}
Output:
Id = 10000
Name = javaboy2012