Redis安装
说明:使用以下脚本,将redis安装包放在同级目录下即可开始安装
xxx.sh install # 安装redis
xxx.sh unintall # 卸载redis
安装包获取:链接:https://pan.baidu.com/s/1r-cl1bmI9QZhiEql5NlQtQ?pwd=qi5i
给脚本授权
chmod +x xxx.sh
执行脚本,开始安装 xxx.sh install
#!/bin/bash
# description 安装redis至/home/目录下
install_redis() {
mkdir -p /home/redis/logs
# 根据需要修改解压路径
tar -zxf ./redis-stack-server-6.2.2-v4.rhel7.x86_64.tar.gz -C /home/
echo "export PATH=/home/redis/bin:$PATH" >>/etc/profile
mv /home/redis-stack-server-6.2.2-v4/* /home/redis/
rm -rf /home/redis-stack-server-6.2.2-v4
source /etc/profile
cat >/home/redis/etc/redis-stack.conf <<EOF
protected-mode no
requirepass Lz!2023@aD
logfile "/home/redis/logs/redis.log"
appendonly yes
port 16379
tcp-backlog 511
timeout 0
tcp-keepalive 300
daemonize yes
supervised no
pidfile /home/redis/redis_6379.pid
loglevel notice
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 /home/redis/
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
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
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
EOF
# 启动redis
# /home/redis/bin/redis-server /etc/redis/etc/redis-stack.conf
cat >/etc/systemd/system/redis.service <<EOF
[Unit]
Description=RedisService
[Service]
ExecStart=/home/redis/bin/redis-server /home/redis/etc/redis-stack.conf --daemonize no --supervised systemd
Restart=on-failure
RestartSec=15
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl start redis
systemctl enable redis
}
uninstall_redis() {
systemctl stop redis
rm -rf /home/redis
}
redis_param=$1
case $redis_param in
install | INSTALL)
install_redis
;;
uninstall | UNINSTALL)
uninstall_redis
;;
*)
echo "usage: redis_install.sh install|INSTALL|unistall|UNINSTALL."
;;
esac
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列:基于图像分类模型对图像进行分类
· go语言实现终端里的倒计时
· 如何编写易于单元测试的代码
· 10年+ .NET Coder 心语,封装的思维:从隐藏、稳定开始理解其本质意义
· .NET Core 中如何实现缓存的预热?
· 25岁的心里话
· 闲置电脑爆改个人服务器(超详细) #公网映射 #Vmware虚拟网络编辑器
· 基于 Docker 搭建 FRP 内网穿透开源项目(很简单哒)
· 零经验选手,Compose 一天开发一款小游戏!
· 一起来玩mcp_server_sqlite,让AI帮你做增删改查!!