yum clean allyum makecache fastyum -y install gcc gcc-c++ tcl#redis 内核参数优化cat >> /etc/sysctl.conf << "EOF"net.core.somaxconn = 2048net.ipv4.tcp_max_syn_backlog = 2048vm.overcommit_memory = 1EOFsysctl -pcat > /etc/security/limits.conf << "EOF"root soft nofile 65535root hard nofile 65535* soft nofile 65535* hard nofile 65535EOFcd /usr/local/srcwget http://download.redis.io/releases/redis-5.0.9.tar.gztar xvf redis-5.0.9.tar.gzcd redis-5.0.9makemake PREFIX=/usr/local/redis installmkdir -p /usr/local/redis/{etc,logs,data}egrep -v "^$|^#" ./redis.conf >/usr/local/redis/etc/redis.confsed -i "s/bind 127.0.0.1/bind 0.0.0.0/g" /usr/local/redis/etc/redis.confsed -i "s/daemonize no/daemonize yes/g" /usr/local/redis/etc/redis.confsed -i "s/dir \.\//dir \/usr\/local\/redis\/data/g" /usr/local/redis/etc/redis.confsed -i "s/logfile \"\"/logfile \"\/usr\/local\/redis\/logs\/redis.log\"/g" /usr/local/redis/etc/redis.conf#设置redis密码echo 'requirepass ysj666' >>/usr/local/redis/etc/redis.conf#PATH配置echo "export PATH=\${PATH}:/usr/local/redis/bin" >>/etc/profilesource /etc/profilevim /etc/init.d/redis#!/bin/sh## Simple Redis init.d script conceived to work on Linux systems# as it does use of the /proc filesystem.### BEGIN INIT INFO# Provides: redis_6379# Default-Start: 2 3 4 5# Default-Stop: 0 1 6# Short-Description: Redis data structure server# Description: Redis data structure server. See https://redis.io### END INIT INFOREDISPORT=6379EXEC=/usr/local/redis/bin/redis-serverCLIEXEC=/usr/local/redis/bin/redis-cliPIDFILE=/var/run/redis_${REDISPORT}.pidCONF="/usr/local/redis/etc/redis.conf"PASSWD="ysj666"case "$1" in start) if [ -f $PIDFILE ] then echo "$PIDFILE exists, process is already running or crashed" else echo "Starting Redis server..." $EXEC $CONF fi ;; stop) if [ ! -f $PIDFILE ] then echo "$PIDFILE does not exist, process is not running" else PID=$(cat $PIDFILE) echo "Stopping ..." $CLIEXEC -p $REDISPORT -a $PASSWD shutdown while [ -x /proc/${PID} ] do echo "Waiting for Redis to shutdown ..." sleep 1 done echo "Redis stopped" fi ;; *) echo "Please use start or stop as first argument" ;;esacchmod +x /etc/init.d/redissystemctl enable redissystemctl start redis/sbin/chkconfig redis on