[Linux][Redis][03]Sentinel

#修改配置文件
IP=`ifconfig eth0 | grep "inet " | awk '{ print $2}'` #ifconfig | grep inet | awk '{ print $2}' | head -n 1
echo "port 26379" > /etc/sentinel.conf
echo "bind ${IP}" >> /etc/sentinel.conf
echo "dir \"/var/log/redis\"" >> /etc/sentinel.conf
echo "sentinel myid 59d96dece48d60eeedfa3f8d3c75bfd890ed021d" >> /etc/sentinel.conf
echo "logfile \"/var/log/redis/sentinel.log\"" >> /etc/sentinel.conf
echo "daemonize yes" >> /etc/sentinel.conf
echo "loglevel notice" >> /etc/sentinel.conf
echo "sentinel monitor mymaster ${IP} 6379 2" >> /etc/sentinel.conf
echo "sentinel down-after-milliseconds mymaster 10000" >> /etc/sentinel.conf
echo "sentinel config-epoch mymaster 43" >> /etc/sentinel.conf
echo "sentinel leader-epoch mymaster 43" >> /etc/sentinel.conf
echo "sentinel known-slave mymaster ${IP} 6379" >> /etc/sentinel.conf
echo "sentinel known-slave mymaster ${IP} 6379" >> /etc/sentinel.conf
echo "sentinel known-sentinel mymaster ${IP} 26379 631b722590e104862dd904410b1b40672ceb6cae" >> /etc/sentinel.conf
echo "sentinel known-sentinel mymaster ${IP} 26379 d00bd557fa3cbae4c836e6079b1086ca524d203d" >> /etc/sentinel.conf
echo "sentinel current-epoch 43" >> /etc/sentinel.conf
echo "maxclients 4064" >> /etc/sentinel.conf

# 修改配置文件属性
chown redis:redis /etc/redis -R

# Redis Sentinel 服务开机运行
IP=`ifconfig eth0 | grep "inet " | awk '{ print $2}'` #ifconfig | grep inet | awk '{ print $2}' | head -n 1
echo "[Unit]" > /usr/lib/systemd/system/redis-sentinel.service
echo "Description=Redis Sentinel" >> /usr/lib/systemd/system/redis-sentinel.service
echo "After=network.target" >> /usr/lib/systemd/system/redis-sentinel.service
echo "[Service]" >> /usr/lib/systemd/system/redis-sentinel.service
echo "Type=forking" >> /usr/lib/systemd/system/redis-sentinel.service
echo "ExecStart=/usr/local/bin/redis-sentinel /etc/redis/sentinel.conf" >> /usr/lib/systemd/system/redis-sentinel.service
echo "ExecStop=/usr/local/bin/redis-cli -h ${IP} -p 26379 shutdown" >> /usr/lib/systemd/system/redis-sentinel.service
echo "User=redis" >> /usr/lib/systemd/system/redis-sentinel.service
echo "Group=redis" >> /usr/lib/systemd/system/redis-sentinel.service
echo "[Install]" >> /usr/lib/systemd/system/redis-sentinel.service
echo "WantedBy=multi-user.target" >> /usr/lib/systemd/system/redis-sentinel.service

posted @ 2017-05-26 17:55  wuzhenzhou  阅读(134)  评论(0编辑  收藏  举报