redis基础

redis基本命令:

启动: 

1.bin目录下 ./redis-server

2.指定配置文件 ./redis-server ../redis.conf (配置所在目录)

关闭服务:

1.ps -ef | grep redis 查询redis的pid kill -9 pid杀掉

2.bin目录下./reids-cil shutdown

开启外网访问:

修改配置文件redis.conf

1.bind 127.0.0.1 改为 bind 0.0.0.0

2.protected-mode yes 改为 protected-mode no

3.加个密码    requirepass xuxiang.123

3.如果你用的是腾讯云或者阿里云要设置安全组。

4。如果还是没有作用可以是reids启动的时候不是用的你改动的reids.conf文件,指定配置文件启动试试

redis配置文件无注释版:

# 保护模式
protected-mode no
# 端口号
port 6379

tcp-backlog 511

bind 0.0.0.0

timeout 0

tcp-keepalive 300

# 守护进程
daemonize yes


pidfile /var/run/redis_6379.pid


loglevel notice


logfile ""


databases 16


always-show-logo no


set-proc-title yes


proc-title-template "{title} {listen-addr} {server-mode}"


# 如果持久化出错,主进程是否停止写入
stop-writes-on-bgsave-error yes

# 是否压缩
rdbcompression yes

# 导入时是否检查
rdbchecksum yes

# 文件名称
dbfilename dump.rdb


rdb-del-sync-files no

# 文件保存路径
# AOF文件的保存位置和RDB文件的位置相同,都是通过dir参数设置的
dir ./



replica-serve-stale-data yes


replica-read-only yes


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


lazyfree-lazy-user-flush no


oom-score-adj no


oom-score-adj-values 0 200 800



disable-thp yes
# appendonly参数开启AOF持久化
appendonly no
# AOF持久化的文件名,默认是appendonly.aof
appendfilename "appendonly.aof"



# 同步策略
# appendfsync always #同步写回
appendfsync everysec #每秒写回
# appendfsync no #操作系统控制的写回

# aof重写期间是否同步
no-appendfsync-on-rewrite no

# 重写触发配置
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
# 加载aof出错如何处理
aof-load-truncated yes

aof-use-rdb-preamble yes

lua-time-limit 5000

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

# 密码
requirepass xuxiang.123

# 周期性执行条件的设置格式为
# save <seconds> <changes>

# 默认的设置为:
# save 900 1
# save 300 10
# save 60 10000

# 以下设置方式为关闭RDB快照功能
# save ""


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值