1. Install the necessary packages
yum install gcc
2. Installation under linux
#download wget http://download.redis.io/releases/redis-3.0.0 .tar.gz tar zxvf redis-3.0.0.tar.gz cd redis -3.0.0 #If no parameters are added , an error will be reported under linux make MALLOC=libc
After installation, start the file
#start redis src/redis-server & #Close redis src/redis-cli shutdown
test redis
$ src/redis-cli 127.0.0.1:6379> set foo bar OK 127.0.0.1:6379> get foo "bar" $
test was successful
In the real environment, redis cannot be accessed by anyone who wants to access it. Therefore, you must set a password and modify the redis.conf file configuration.
# requirepass foobared remove the comment, foobared is changed to its own password, I changed it to redis here
If changing the password does not take effect, please use the specified configuration file to start
src/redis-server ./redis.conf
After getting the connection in java programming, add it after the Jedis object
jedis.auth("设置的密码");
find / -name 'redis*' 快速查找定位redis的目录
一种是登录的时候就用-a参数指定密码、一种是在会话中auth进行验证。具体如下: [redies@localhost redis-2.4]$ src/redis-cli redis 127.0.0.1:6379> keys * (error) ERR operation not permitted //此处系统报错,是因为我们没有权限 redis 127.0.0.1:6379> auth qikeyun //用auth命令进行验证授权。 OK 127.0.0.1:6379> keys * (empty list or set) 127.0.0.1:6379> 127.0.0.1:6379> quit $ redis-cli -a qikeyun //登录的时候就指定了密码。 127.0.0.1:6379> keys * (empty list or set)