redis 安装使用

2020/11/15 Linux redis

redis 安装使用

# 安装并编译
wget https://download.redis.io/releases/redis-6.0.9.tar.gz -O /tmp/redis-6.0.9.tar.gz
cd /tmp
tar xzf redis-6.0.9.tar.gz
cd redis-6.0.9
make
# 创建环境
BASE_PATH=/opt/redis-single-point
mkdir -p $BASE_PATH
mkdir -p $BASE_PATH/bin
mkdir -p $BASE_PATH/conf
mkdir -p $BASE_PATH/data
mkdir -p $BASE_PATH/log/

cp /tmp/redis-6.0.9/src/redis-server /tmp/redis-6.0.9/src/redis-cli /tmp/redis-6.0.9/src/redis-benchmark $BASE_PATH/bin
# 配置 redis.conf
vi $BASE_PATH/conf/redis.conf

bind 127.0.0.1
protected-mode no
port 4399
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /var/run/redis_6379.pid
loglevel notice
logfile "/opt/redis-single-point/log/redis.log"
databases 16
always-show-logo yes
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error yes
rdbcompression yes
rdbchecksum yes
dbfilename dump.rdb
rdb-del-sync-files no
dir /opt/redis-single-point/data/
replica-serve-stale-data yes
replica-read-only yes
repl-diskless-sync no
repl-diskless-sync-delay 5
repl-diskless-load disabled
repl-disable-tcp-nodelay no
replica-priority 100
acllog-max-len 128
lazyfree-lazy-eviction no
lazyfree-lazy-expire no
lazyfree-lazy-server-del no
replica-lazy-flush no
lazyfree-lazy-user-del no
oom-score-adj no
oom-score-adj-values 0 200 800
appendonly no
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
aof-load-truncated yes
aof-use-rdb-preamble yes
lua-time-limit 5000
cluster-enabled no
cluster-node-timeout 15000
slowlog-log-slower-than 10000
slowlog-max-len 128
latency-monitor-threshold 0
notify-keyspace-events ""
hash-max-ziplist-entries 512
hash-max-ziplist-value 64
list-max-ziplist-size -2
list-compress-depth 0
set-max-intset-entries 512
zset-max-ziplist-entries 128
zset-max-ziplist-value 64
hll-sparse-max-bytes 3000
stream-node-max-bytes 4096
stream-node-max-entries 100
activerehashing yes
client-output-buffer-limit normal 0 0 0
client-output-buffer-limit replica 256mb 64mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
dynamic-hz yes
aof-rewrite-incremental-fsync yes
rdb-save-incremental-fsync yes
jemalloc-bg-thread yes
# 配置 redis 服务
vi /lib/systemd/system/redis.service

[Unit]
Description=redis service port 6379

[Service]
User=Development
Group=Development
Type=forking
ExecStart=/opt/redis-single-point/bin/redis-server /opt/lotus/redis-single-point/conf/redis.conf
Restart=on-success

[Install]
WantedBy=multi-user.target
# 启动服务并检测
systemctl daemon-reload
systemctl start redis
ps -ef|grep redis

echo 'export PATH=$PATH:/opt/redis-single-point/bin' >> /etc/profile
source /etc/profile
redis-cli -h 127.0.0.1 -p 6379
redis>

Search

    Table of Contents