Build Redis under Linux and troubleshoot problems with Redis

Source: Internet
Author: User
Tags redis cluster

The first is to build Redis, which is relatively simple.

1. Check the installation dependent program

install gcc-c++yum install -y tclyum install wget

2. Get the installation files

wget http://download.redis.io/releases/
这里面有很多版本,自己选择需要的下载

3. Unzip the file

Create a new directory to unzip the Redis inside

tar -zxvf redis-3.2.01.tar.gzmv redis-3.2.01 /usr/local/redis

4. Enter the catalogue

cd /usr/local/redis

5. Compile and install

install

6. Set configuration file path

mkdir -p /etc/rediscp redis.conf/etc/redis

7. Modify the configuration file

Redis.conf is a redis configuration file, redis.conf in the Redis source directory.

Note Modify the port as the Redis process ports, port default 6379. If you need to build a redis cluster, don't forget to modify the port number.

Redis has two ways to start, directly run Bin/redis-server will start in front-end mode, the disadvantage of front-end mode startup is the SSH Command Window closed redis-server program end, it is not recommended to use this method. Such as:

Back-end mode startup

Modify the redis.conf configuration file, daemonize Yes to the backend mode to start. Recommended!

Open redis.conf, use the command:/daemonize Quick Find to daemonize and then modify.

vi /etc/redis/redis.conf仅修改: daemonize yes (no-->yes)

8. Start

/usr/local/bin/redis-server /etc/redis/redis.conf

9. View Startup

ps -ef | grep redis 

10. Using the Client

redis-cli>set name davidOK>get name"david"

11. Close the Client

shutdown

12. Boot Start configuration

"/usr/local/bin/redis-server /etc/redis/redis.conf &" >> /etc/rc.local

Boot boot to be configured in rc.local , and /etc/profile file, to have the user logged in, will be executed.

13. Set the password

Because this is used for many people on the LAN, it is necessary to set up an access password.

Modify the redis.conf file configuration

Use the command:/Requirepass quickly find the # Requirepass foobared and then remove the comment, this foobared changed to its own password. Then Wq save.

14. Restart Redis

sudo service Redis Restart this time to try to log in to Redis and find that it can be boarded, but the execution of a specific command is prompt operation is not allowed

    1. Redis-cli-h 127.0.0.1-p 6379
    2. Redis 127.0.0.1:6379>
    3. Redis 127.0.0.1:6379> Keys *
    4. (Error) ERR Operation not permitted

Try to log in with a password and execute a specific command to see that it can be executed successfully

    1. Redis-cli-h 127.0.0.1-p 6379-a Password
    2. Redis 127.0.0.1:6379> Keys *
    3. 1) "MySet"
    4. 2) "Mysortset"
    5. Redis 127.0.0.1:6379> Select 1
    6. Ok

If it is the use of their own on the machine now can be, because I this is available to everyone in the LAN to use, so also need a final configuration.

When the development of the configuration file was modified, the startup Project error.

Org.springframework.data.redis.RedisConnectionFailureException:Cannot get Jedis connection; Nested exception is redis.clients.jedis.exceptions.JedisConnectionException:Could not get a resource from the pool
At Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.fetchJedisConnector ( jedisconnectionfactory.java:162) ~[spring-data-redis-1.5.0.release.jar:1.5.0.release]
At Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection ( jedisconnectionfactory.java:251) ~[spring-data-redis-1.5.0.release.jar:1.5.0.release]
At Org.springframework.data.redis.connection.jedis.JedisConnectionFactory.getConnection ( jedisconnectionfactory.java:58) ~[spring-data-redis-1.5.0.release.jar:1.5.0.release]
At Org.springframework.data.redis.core.RedisConnectionUtils.doGetConnection (redisconnectionutils.java:128) ~[ Spring-data-redis-1.5.0.release.jar:1.5.0.release]

Open cmd and then use the Telnet IP port to ping the configured Redis (to ensure that Redis is started) and find that it cannot be ping.

This is because there is a configuration in redis.conf bind 127.0.0.1 This is the default only native access, put this comment off, note that after viewing the Redis process becomes the following:

[Email protected] redis]# Ps-ef | grep Redis
Root 5655 1 0 11:40? 00:00:23 ./redis-server *:6379
Root 21184 18040 0 17:33 pts/1 00:00:00 grep--color=auto Redis

This indicates that other users will be allowed to access the * number. Then you can ping it by using the Telnet IP port on the cmd that opens the machine.

The above is the whole content, the shortcomings are welcome to point out, mutual exchange only progress!

Build Redis under Linux and troubleshoot problems with Redis

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.