天天看点

puppet连载18:搭建redis写启动脚本!/bin/bashchkconfig:2345 93 63description:redis star stop调用$real_redis_port =

cd /puppet/soft

wget

http://download.redis.io/releases/redis-3.2.11.tar.gz

mkdir -p /etc/puppet/modules/linuxredis/{manifests,files,templates}

vi /etc/puppet/modules/linuxredis/templates/redis-3.2.11.conf.erb

bind 0.0.0.0

protected-mode yes

port <%= real_redis_port %>

tcp-backlog 511

timeout 0

tcp-keepalive 300

daemonize yes

supervised no

pidfile /var/run/redis_<%= real_redis_port %>.pid

loglevel notice

logfile ""

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 ./

slave-serve-stale-data yes

slave-read-only yes

repl-diskless-sync no

repl-diskless-sync-delay 5

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

aof-load-truncated 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

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

写启动脚本

vim /puppet/soft/redis-3.2.11.sh

!/bin/bash

chkconfig:2345 93 63

description:redis star stop

. /etc/rc.d/init.d/functions

servicename=/data/redis-3.2.11/src/redis-server

serviceconfig=/data/redis-3.2.11/redis.conf

if [ ! -f $servicename ];then

exit 6;

fi

if [ ! -f $serviceconfig ];then

exit 7;

case

puppet连载18:搭建redis写启动脚本!/bin/bashchkconfig:2345 93 63description:redis star stop调用$real_redis_port =

servicename

puppet连载18:搭建redis写启动脚本!/bin/bashchkconfig:2345 93 63description:redis star stop调用$real_redis_port =
puppet连载18:搭建redis写启动脚本!/bin/bashchkconfig:2345 93 63description:redis star stop调用$real_redis_port =

servicename"|grep -Ev "grep|color"|wc -l`

if [

puppet连载18:搭建redis写启动脚本!/bin/bashchkconfig:2345 93 63description:redis star stop调用$real_redis_port =

0 {start|stop|restart|status}"

exit 2

esac

exit $?

vi /etc/puppet/modules/linuxredis/manifests/init.pp

class linuxredis::redis3211 {

puppet连载18:搭建redis写启动脚本!/bin/bashchkconfig:2345 93 63description:redis star stop调用$real_redis_port =

redis_port ? {'' => '6379',default => $redis_port }

exec {"/data":

command => "mkdir /data",

creates => "/data",

path => ["/usr/bin","/usr/sbin","/sbin","/bin"],

}

file {"/data/redis-3.2.11.tar.gz":

source => "puppet:///soft/redis-3.2.11.tar.gz",

ensure => file,

mode => 755,owner => root,group => root,

require => [Exec["/data"],File["/etc/init.d/redis-server"]],

notify => Exec["tar redis-3.2.11.tar.gz"],

file {"/etc/init.d/redis-server":

source => "puppet:///soft/

redis-3.2.11.sh

",

exec {"tar redis-3.2.11.tar.gz":

command => "tar zxvf redis-3.2.11.tar.gz && cd redis-3.2.11 && make && cd src && make install",

cwd => "/data",

refreshonly => true,

notify => Exec["firewallredisport"],

exec {"firewallredisport":

command => "firewall-cmd --add-port=$real_redis_port/tcp --permanent && firewall-cmd --reload",

path => ["/usr/sbin","/usr/bin","/bin","/sbin"],

file {'/data/redis-3.2.11/redis.conf':

content => template("/etc/puppet/modules/linuxredis/templates/redis-3.2.11.conf.erb"),

backup => '.bak',

notify => [Service["redis-server"],Exec["firewallredisport"]],

require => Exec["tar redis-3.2.11.tar.gz"],

service {"redis-server":

ensure => running,

hasrestart => true,

provider => init,

start => "/etc/init.d/redis-server start",

stop => "/etc/init.d/redis-server stop",

restart => "/etc/init.d/redis-server restart",

status => "/etc/init.d/redis-server status",

调用

node 'huangat-test' {

$real_redis_port =

include linuxredis::redis3211

继续阅读