1. 安装Redis
- 1.下载和解压缩
cd /usr/local/
wget http://download.redis.io/releases/redis-3.2.1.tar.gz
tar -zxvf /redis-3.2.1.tar.gz
- 2.编译安装
cd redis-3.2.1
make && make install
cd src
make install PREFIX=/usr/local/redis-3.2.1
- 3.调整配置文件位置
# Redis的服务目录
mv redis.conf ./etc/
这样的话差不多就算安装完成了,然后启动文件都在
bin/
目录中
2. 配置Redis
daemonize:如需要在后台运行,把该项的值改为yes
port:监听端口,默认为6379
3. 增加远程密码登录
将redis.conf
中的配置改为以下配置
# bind 127.0.0.1
protected-mode no
Redis的配置文件默认在/etc/redis.conf
,找到如下行:
去掉前面的注释,并修改为所需要的密码:
#requirepass foobared
requirepass myPassword #(其中myPassword就是要设置的密码)
4. 启动Redis
启动命令都在
bin
目录中
启动时指定配置文件
# 启动服务
./bin/redis-server ./etc/redis.conf
# 客户端登录
./bin/redis-cli -h 127.0.0.1 -p 6379 -a password
# 关闭Redis服务
./bin/redis-cli -a password shutdown
5. Redis 压力测试
./bin/redis-benchmark -h 127.0.0.1 -p 6379 -a password -q -n 10000
网友评论