redis 安装配置

Posted Pythia丶陌乐

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了redis 安装配置相关的知识,希望对你有一定的参考价值。

reids 安装配置

1.1 下载软件包

[[email protected] ~]# mkdir -p /data/src/
[[email protected] ~]# cd /data/src/
[[email protected] src]# wget http://download.redis.io/releases/redis-3.2.5.tar.gz

1.2 解压安装

[[email protected] src]# tar zxf redis-3.2.5.tar.gz 
[[email protected] src]# cd redis-3.2.5
[[email protected] src]# make
[[email protected] src]# cd src
[[email protected] src]# make install PREFIX=/usr/local/redis/

1.3 检查安装

[[email protected] src]# ll /usr/local/redis/bin/
total 26348
-rwxr-xr-x 1 root root 5580319 Jun 2 11:47 redis-benchmark
-rwxr-xr-x 1 root root 22185 Jun 2 11:47 redis-check-aof
-rwxr-xr-x 1 root root 7829986 Jun 2 11:47 redis-check-rdb
-rwxr-xr-x 1 root root 5709195 Jun 2 11:47 redis-cli
lrwxrwxrwx 1 root root 12 Jun 2 11:47 redis-sentinel -> redis-server
-rwxr-xr-x 1 root root 7829986 Jun 2 11:47 redis-server

# 常用命令存在,表示已经安装成功

1.4 添加配置文件

[[email protected] src]# mkdir /usr/local/redis/etc -p     # 创建配置文件目录
[[email protected] ~]# cat /usr/local/redis/etc/redis6380.conf 
daemonize yes
pidfile /var/run/redis6380.pid
port 6380
timeout 0
tcp-keepalive 0
loglevel notice
logfile stdout
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
# 关闭保护模式
protected-mode no 
dir /data/redis/redis6380
slave-serve-stale-data yes
slave-read-only yes
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
lua-time-limit 5000
slowlog-log-slower-than 10000
slowlog-max-len 128
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-entries 512
list-max-ziplist-value 64
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit slave 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
[[email protected] ~]# 

1.5 创建数据目录

[[email protected] src]# mkdir /data/redis/redis6380 -p

 1.6 启动服务

[[email protected] ~]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis6380.conf 

 

1.7 检查启动并添加自动配置

[[email protected] ~]# ps -ef |grep redis
root     22036 21963  0 13:03 pts/0    00:00:00 grep redis
root     27911     1  0 Mar02 ?        00:01:54 /usr/local/redis/bin/redis-server *:6380                                                      
[[email protected] ~]# cat /etc/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don‘t
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis6380.conf
[[email protected] ~]#

 

1.8 测试redis服务

[[email protected] ~]# /usr/local/redis/bin/redis-cli -h 172.24.129.3 -p 6380
172.24.129.3:6380> set key 123
OK
172.24.129.3:6380> get key 
"123"
172.24.129.3:6380> 

# 能设置值,并且还能获取到值表示所有操作配置已经完成

 

 

 

 

以上是关于redis 安装配置的主要内容,如果未能解决你的问题,请参考以下文章

linux下安装与配置Redis

#VSCode保存插件配置并使用 gist 管理代码片段

Linux07 /redis

redis存储session配制方法

vim代码片段插件ultisnips的使用

SpringDataRedis入门Demo