Redis安装

InstallRedis_CentOS7.sh

#!/bin/bash

wget http://download.redis.io/releases/redis-4.0.14.tar.gz
tarName=redis-4.0.14.tar.gz
PORT=6379
     
ConfigSystem()
{
    yum -y install openssh-clients make gcc gcc-c++ lrzsz wget 
    yum -y install rubygems ruby
}
 
InstallRedis()
{   
        mkdir -p /data /data/logs
        mkdir /usr/local/redis
        tar xf ${tarName} -C /usr/local/redis
        unPackName=$(ls /usr/local/redis)
        redisInstallPath=/usr/local/redis/${unPackName}
        
        #Install redis
        cd ${redisInstallPath}/
        make
        make PREFIX=/usr/local/redis  install 
        cp  ${redisInstallPath}/src/redis-trib.rb /usr/local/redis/bin

        echo  "Install config file  "
        mkdir -p /etc/redis
        /bin/cp ${redisInstallPath}/redis.conf /etc/redis/$PORT.conf
        echo  -e '
pidfile /var/run/redis_6379.pid
logfile /data/logs/redis.6379_master.log
protected-mode yes
masterauth "mypass"
requirepass "mypass"
daemonize yes
tcp-backlog 511
timeout 0
tcp-keepalive 60
loglevel notice
databases 16
dir /data
stop-writes-on-bgsave-error no
repl-timeout 60
repl-ping-slave-period 10
repl-disable-tcp-nodelay no
repl-backlog-size 10M
repl-backlog-ttl 7200
slave-serve-stale-data yes
slave-read-only yes
slave-priority 100
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 512mb 128mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
port 6379
maxmemory 512mb
maxmemory-policy volatile-lru
appendonly yes
appendfsync everysec
appendfilename appendonly-6379.aof
dbfilename dump-6379.rdb
aof-rewrite-incremental-fsync yes
no-appendfsync-on-rewrite yes
auto-aof-rewrite-min-size 64m
auto-aof-rewrite-percentage 89
rdbcompression yes
rdbchecksum yes
repl-diskless-sync no
repl-diskless-sync-delay 5
maxclients 10000
hll-sparse-max-bytes 3000
min-slaves-to-write 0
min-slaves-max-lag 10
aof-load-truncated yes
notify-keyspace-events ""
        '> /etc/redis/$PORT.conf
            
        echo  " Install PATH"
        echo  'export PATH=/usr/local/redis/bin:$PATH' >>/root/.bash_profile         

}

StartRedis()
{
        echo  "/usr/local/redis/bin/redis-server /etc/redis/$PORT.conf &"
        echo  '/usr/local/redis/bin/redis-cli -h 192.168.1.101 -p 6379 -a "mypass"'
}

ConfigSystem
InstallRedis
StartRedis

 

InstallRedis_multi.sh

#!/bin/bash

PORT=6380
 
InstallRedis()
{   
        echo  "Install config file  "
        mkdir -p /etc/redis
        echo  -e '
pidfile /var/run/redis_6380.pid
logfile /data/logs/redis.6380_master.log
protected-mode yes
masterauth "mypass"
requirepass "mypass"
daemonize yes
tcp-backlog 511
timeout 0
tcp-keepalive 60
loglevel notice
databases 16
dir /data
stop-writes-on-bgsave-error no
repl-timeout 60
repl-ping-slave-period 10
repl-disable-tcp-nodelay no
repl-backlog-size 10M
repl-backlog-ttl 7200
slave-serve-stale-data yes
slave-read-only yes
slave-priority 100
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 512mb 128mb 60
client-output-buffer-limit pubsub 32mb 8mb 60
hz 10
port 6380
maxmemory 512mb
maxmemory-policy volatile-lru
appendonly yes
appendfsync everysec
appendfilename appendonly-6380.aof
dbfilename dump-6380.rdb
aof-rewrite-incremental-fsync yes
no-appendfsync-on-rewrite yes
auto-aof-rewrite-min-size 64m
auto-aof-rewrite-percentage 89
rdbcompression yes
rdbchecksum yes
repl-diskless-sync no
repl-diskless-sync-delay 5
maxclients 10000
hll-sparse-max-bytes 3000
min-slaves-to-write 0
min-slaves-max-lag 10
aof-load-truncated yes
notify-keyspace-events ""
        '> /etc/redis/$PORT.conf
            
        echo  " Install PATH"
        echo  'export PATH=/usr/local/redis/bin:$PATH' >>/root/.bash_profile         

}

StartRedis()
{
        echo  "/usr/local/redis/bin/redis-server /etc/redis/$PORT.conf &"
        echo  '/usr/local/redis/bin/redis-cli -h 192.168.1.101 -p 6380 -a "mypass"'
}

InstallRedis
StartRedis

 

posted @ 2019-08-12 14:10  AllenHU320  阅读(115)  评论(0编辑  收藏  举报