Accessing the Redis sample from a Java client (Getting started)

Source: Internet
Author: User
Tags download redis install redis redis server

Transferred from: http://blog.csdn.net/kkdelta/article/details/7217761

This document documents the steps to install Redis and access Redis from the Java side

Download the required documentation for this article from http://download.csdn.net/detail/kkdelta/4034137.

1, install the Redis service on Linux.

The following operation is base dir for/root/4setup

Tar xzf Redis-2.4.6.tar

CD redis-2.4.6

Make

Start after installation

Nohup Src/redis-server &
Here are the detailed steps from the http://tech.it168.com/a2011/0830/1239/000001239923.shtml copy.

Step one: Download Redis http://download.csdn.net/detail/kkdelta/4034137

Step two: Compile the source program

[[email protected] 4setup]# ll total 29168-rw-r--r--1 root root455240 2011-07-22 redis-2.2.12.tar.gz [[email protected] 4  setup]# tar xzf redis-2.2.12.tar.gz [[email protected] 4setup]# CD redis-2.2.12 [[email protected] redis-2.2.12]# make CD src && make all Make[1]: Entering directory '/ROOT/4SETUP/REDIS-2.2.12/SRC '

Step three: Start the Redis service

src/redis-server [[email protected] Redis-2.2.12]# src/redis-Server [6246] 19:17:22 # warning:no config file specified, using thedefaultConfig. In order to specify a config file use ' redis-server/path/to/redis.conf '[6246] 19:17:22* Server started, Redis version2.2.12[6246] 19:17:22 # WARNING overcommit_memory isset to 0! Background save may fail under low memory condition. To fix ThisIssue add ' vm.overcommit_memory = 1 ' to/etc/sysctl.conf and then reboot or run the command ' Sysctl Vm.overcommit_memory=1 ' for  ThisTo take effect. [6246] 19:17:22* The serveris now Readyto accept Connectionson Port 6379[6246] 19:17:22-0 clients connected (0 slaves), 539544 bytes in use

The default connection port on the Redis server is 6379.

Step four: Randomly start redis as a Linux service

Vi/etc/rc.local, use the VI Editor to open the random startup configuration file and add the following line of code to it.

/root/4setup/redis-2.2.12/src/redis-server

Step five: Client connection verification

Open a new session input: SRC/REDIS-CLI, if prompted below, then you can start the Redis journey.

[Email protected] redis-2.2.12]# src/redis-127.0.0.1:6379>

Step Six: View Redis logs

View the server-side session to view or analyze the health of Redis.

[6246]05 19:24:33-0 clients connected (0 slaves), 539544 bytes in use[6246] 19:24:37-accepted 127.0.0 .1:51381[6246] 19:24:38-1 clients connected (0 slaves), 547372 bytes in use

A few more steps will be OK!! Such a simple Redis database can run smoothly.

Step Seven: Stop the Redis instance

The simplest approach is to use CONTROL-C to stop the instance directly in the session that launches the instance.

We can also use the client to stop the service, such as the shutdown can be used to stop Redis instances, as follows:

[Email protected] redis-2.2.12]# src/redis-cli shutdown2,

2, develop the client Java program:

Create a new javaproject in Eclipse and import the jar package above.

The following is a simple example code:

     Public Static void Main (string[] args) {        new Jedis ("147.151.240.234", 6379);        Jedis.set ("foo", "Bar");         = Jedis.get ("foo");        System.out.println (value);    }

Link to an introduction to installing Redis on Windows http://cardyn.iteye.com/blog/794194

Accessing the Redis sample from a Java client (Getting started)

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.