Redis & Sentinel Installation scripts

Source: Internet
Author: User
Tags download redis

#!/bin/bash


# to determine if root user, not root user prompt exits
if [[$EUID-ne 0]]; Then
?? echo "This script. Must be run as root "1>&2
?? Exit 1
fi?# installing the necessary components Yum install-y gcc?#? Download Redis source code cd/tmpwget-p/tmp?http://download.redis.io/releases/redis-3.2.1.tar.gz?# Compare file downloads correctly echo 26c0fc282369121b4e278523fce122910b65fbbf? redis-3.2.1.tar.gz >/tmp/download.txtsha1sum-c Download.txtif [$?-ne 0]
Then
? echo "The Download File isn't Correct, please Download it again."? Exit 0
fi?# compilation Install tar XF redis-3.2.1.tar.gzcd redis-3.2.1makemake install?# Create Group and user Groupadd redisuseradd-g redis redis?# log file storage location mkdir/var/log/redischown?redis:redis/var/log/redis?# Current IP address ip= ' ifconfig eth0 | grep "inet" | awk ' {print $} '? # Redis service booting up run echo "[Unit]" >?/usr/lib/systemd/system/redis.service?
echo "Description=redis persistent key-value database" >>?/usr/lib/systemd/system/redis.service?
echo "After=network.target" >>?/usr/lib/systemd/system/redis.service?
echo "[Service]" >>?/usr/lib/systemd/system/redis.service??
echo "Type=forking" >>?/usr/lib/systemd/system/redis.service??
echo "Execstart=/usr/local/bin/redis-server/etc/redis/redis.conf" >>?/usr/lib/systemd/system/redis.service ?? echo "Execstop=/usr/local/bin/redis-cli-h ${ip} shutdown" >>?/usr/lib/systemd/system/redis.service?? echo "User=redis" >>?/usr/lib/systemd/system/redis.service??
echo "Group=redis" >>?/usr/lib/systemd/system/redis.service??
echo "[Install]" >>?/usr/lib/systemd/system/redis.service?? echo "Wantedby=multi-user.target" >>?/usr/lib/systemd/system/redis.service?# redis Sentinel service starts running 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?# Redis service limit mkdir?/etc/ Systemd/system/redis.service.d/echo "[Service]" >?/etc/systemd/system/redis.service.d/limits.conf?echo " limitnofile=65535 ">>/etc/systemd/system/redis.service.d/limits.conf?# enable start-up Autorun systemctl enabled Redis.servicesystemctl Enable redis-sentinel.service?# disable Selinuxsed-i ' s/selinux=enforcing/selinux=Disable/‘?/etc/selinux/config
# System Optimizationecho "net.core.somaxconn=4096" >>/etc/sysctl.confecho "echo Never >/sys/kernel/mm/transparent_hugepage/ Enabled ">>/etc/rc.localchmod +x/etc/rc.localecho" Vm.overcommit_memory=1 ">>/etc/sysctl.confecho" *? Soft? Nofile? 65535 ">>?/etc/security/limits.confecho"? * hard? Nofile? 65535 ">>?/etc/security/limits.confecho"? * soft? Nproc? 65535 ">>?/etc/security/limits.confecho"? * hard? Nproc? 65535 ">>?/etc/security/limits.confecho" net.ipv4.tcp_tw_recycle=1 "?>>/etc/sysctl.conf?# alias Echo" Alias Redis= ' redis-cli-h ${ip} ' ">>/etc/profileecho" Alias sentinel= ' Redis-cli-h ${ip}-P 26379 ' ">>/etc/profile ? # Modify Time zone/bin/cp/usr/share/zoneinfo/asia/shanghai/etc/localtime? #Redis配置文件存放位置mkdir/etc/redis?# Modify configuration file Redis.confecho "bind ${ip}" >/etc/redis/redis.confecho "Protected-mode no" >>/etc/redis/ Redis.confecho "Tcp-backlog 4096" >>/etc/redis/redis.confecho "timeout" >>/etc/redis/redis.confecho " Tcp-keepalive ">>/etc/redis/redis.confecho" daemonize yes ">>/etc/redis/redis.confecho" supervised Systemd ">>/etc/redis/redis.confecho" Logfile/var/log/redis/redis.log ">>/etc/redis/redis.confecho" Dir/var/log/redis ">>/etc/redis/redis.confecho" maxclients 10000 ">>/etc/redis/redis.confecho" MaxMemory 4G ">>/etc/redis/redis.confecho" Maxmemory-policy volatile-lru ">>/etc/redis/redis.confecho" AppendOnly No ">>/etc/redis/redis.confecho" Slowlog-max-len ">>/etc/redis/redis.confecho" Client-output-buffer-limit slave 512mb 256MB ">>/etc/redis/redis.conf?# Modify configuration file Sentinel.confecho" Port 26379 " >/etc/redis/sentinel.confecho "Bind ${ip}" >>/etc/redis/sentinel.confecho "Dir/var/log/redis" >>/etc /redis/sentinel.confecho "Sentinel Monitor MyMaster ${ip} 6379 2" >>/etc/redis/sentinel.confecho "MaxClients 10" & gt;>/etc/redis/sentinel.confecho "Logfile/var/log/redis/sentinel.log" >>/etc/redis/sentinel.confecho "Daemonize yes" >>/etc/redis/sentinel.confecho "Sentinel Down-after-milliseconds MyMaster ">>/etc/redis/sentinel.confecho" Sentinel Failover-timeout MyMaster 60000 ">>/etc/redis/sentinel.conf

Redis & Sentinel Installation scripts

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.