redis的shell安装脚本,实现在linux下本机主从架构

本文涉及的产品
Redis 开源版,标准版 2GB
推荐场景:
搭建游戏排行榜
简介:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/bin/bash
# create by lihuibin
# date 2014-04-15
# desc install redis
basedir=` pwd `
homepath= /usr/local/redis
[ -d $homepath ] && {
echo  "redis already installed "
exit
} || {
         echo  "begin init redis dir"
         for  in  bin etc data log ; do
                 mkdir  -pv $homepath/$i
         done
}
[ -f redis-2.8.8. tar .gz ] || {
echo  "begin to download redis package"
wget http: //download .redis.io /releases/redis-2 .8.8. tar .gz
echo  " download redis package completed"
}
echo  "begin to make source code"
tar  xzf redis-2.8.8. tar .gz
cd  redis-2.8.8
make
echo  "make source code completed"
cd  src
cp  -r redis-benchmark redis-check-aof redis-check-dump redis-sentinel redis-cli redis-server $homepath /bin
[ -f $basedir /redis .conf ] && {
         echo  "start redis-server"
         for  conf  in  redis.conf redis_salve.conf ; do
         cp  $basedir/$conf $homepath /etc/
         $homepath /bin/redis-server  $homepath /etc/ $conf
         done
} || {
  echo  "not found $basedir/redis.conf"
}


主:6379

从:6380

wKioL1NYb6yheqOnAABtT6b2o3w954.jpg


wKioL1NYcL-xS9CIAADHnx_f7eo465.jpg


wKioL1NYcbWxVTwYAADlrek864Y197.jpg


wKiom1NYcd-i3S8EAACr4TySZME947.jpg


主:redis.conf


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
daemonize  yes
pidfile  /var/run/redis .pid
port 6379
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile  "/usr/local/redis/log/redis.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error  yes
rdbcompression  yes
rdbchecksum  yes
dbfilename dump.rdb
dir  /usr/local/redis/data
slave-serve-stale-data  yes
slave- read -only no
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename  "appendonly.aof"
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
notify-keyspace-events  ""
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
aof-rewrite-incremental-fsync  yes


从:redis_salve.conf

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
daemonize  yes
pidfile  /var/run/redis_salve .pid
port 6380
tcp-backlog 511
timeout 0
tcp-keepalive 0
loglevel notice
logfile  "/usr/local/redis/log/redis_slave.log"
databases 16
save 900 1
save 300 10
save 60 10000
stop-writes-on-bgsave-error  yes
rdbcompression  yes
rdbchecksum  yes
dbfilename dump_salve.rdb
dir  /usr/local/redis/data
slave-serve-stale-data  yes
slave- read -only no
repl-disable-tcp-nodelay no
slave-priority 100
appendonly no
appendfilename  "appendonly.aof"
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
notify-keyspace-events  ""
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
aof-rewrite-incremental-fsync  yes
SLAVEOF 127.0.0.1 6379


本文转自birdinroom 51CTO博客,原文链接:http://blog.51cto.com/birdinroom/1401493,如需转载请自行联系原作者
相关文章
|
3月前
|
存储 安全 Unix
七、Linux Shell 与脚本基础
别再一遍遍地敲重复的命令了,把它们写进Shell脚本,就能一键搞定。脚本本质上就是个存着一堆命令的文本文件,但要让它“活”起来,有几个关键点:文件开头最好用#!/usr/bin/env bash来指定解释器,并用chmod +x给它执行权限。执行时也有讲究:./script.sh是在一个新“房间”(子Shell)里跑,不影响你;而source script.sh是在当前“房间”里跑,适合用来加载环境变量和配置文件。
420 9
|
Ubuntu Linux 网络安全
Linux系统初始化脚本
一款支持Rocky、CentOS、Ubuntu、Debian、openEuler等主流Linux发行版的系统初始化Shell脚本,涵盖网络配置、主机名设置、镜像源更换、安全加固等多项功能,适配单/双网卡环境,支持UEFI引导,提供多版本下载与持续更新。
297 0
Linux系统初始化脚本
|
3月前
|
存储 Shell Linux
八、Linux Shell 脚本:变量与字符串
Shell脚本里的变量就像一个个贴着标签的“箱子”。装东西(赋值)时,=两边千万不能有空格。用单引号''装进去的东西会原封不动,用双引号""则会让里面的$变量先“变身”再装箱。默认箱子只能在当前“房间”(Shell进程)用,想让隔壁房间(子进程)也能看到,就得给箱子盖个export的“出口”戳。此外,Shell还自带了$?(上条命令的成绩单)和$1(别人递进来的第一个包裹)等许多特殊箱子,非常有用。
310 3
|
5月前
|
Web App开发 缓存 安全
Linux一键清理系统垃圾:释放30GB空间的Shell脚本实战​
这篇博客介绍了一个实用的Linux系统盘清理脚本,主要功能包括: 安全权限检查和旧内核清理,保留当前使用内核 7天以上日志文件清理和系统日志压缩 浏览器缓存(Chrome/Firefox)、APT缓存、临时文件清理 智能清理Snap旧版本和Docker无用数据 提供磁盘空间使用前后对比和大文件查找功能 脚本采用交互式设计确保安全性,适合定期维护开发环境、服务器和个人电脑。文章详细解析了脚本的关键功能代码,并给出了使用建议。完整脚本已开源,用户可根据需求自定义调整清理策略。
566 0
|
7月前
|
Java Linux
自定义linux脚本用于快速jar包启动、停止、重启
自定义linux脚本用于快速jar包启动、停止、重启
325 29
|
7月前
|
消息中间件 NoSQL Linux
Redis的基本介绍和安装方式(包括Linux和Windows版本),以及常用命令的演示
Redis(Remote Dictionary Server)是一个高性能的开源键值存储数据库。它支持字符串、列表、散列、集合等多种数据类型,具有持久化、发布/订阅等高级功能。由于其出色的性能和广泛的使用场景,Redis在应用程序中常作为高速缓存、消息队列等用途。
920 16
|
7月前
|
Linux Shell
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
Centos或Linux编写一键式Shell脚本删除用户、组指导手册
200 4
|
7月前
|
Linux Shell 数据安全/隐私保护
Centos或Linux编写一键式Shell脚本创建用户、组、目录分配权限指导手册
Centos或Linux编写一键式Shell脚本创建用户、组、目录分配权限指导手册
403 3
|
8月前
|
Linux Shell
在Linux、CentOS7中设置shell脚本开机自启动服务
以上就是在CentOS 7中设置shell脚本开机自启动服务的全部步骤。希望这个指南能帮助你更好地管理你的Linux系统。
631 25
|
8月前
|
安全 Linux
阿里云linux服务器使用脚本通过安全组屏蔽异常海外访问ip
公网网站可能会遭受黑客攻击导致访问异常,使用此脚本可以屏蔽掉异常IP 恢复访问。也可自行设置定时任务定期检测屏蔽。
603 28

热门文章

最新文章