#!/bin/bash
echo "安装redis,按任意键继续"
read -n1

yum -y install gcc glibc make*

cd /data/software
curl -O http://down.yadeaiot.net:8000/redis-4.0.0.tar.gz
tar -zxvf redis-4.0.0.tar.gz

mv redis-4.0.0 /usr/local/redis
cd /usr/local/redis

mkdir -p /home/redislog
mkdir -p /home/redisdb

make

cd /usr/local/redis/src
cp redis-benchmark redis-cli redis-server /usr/bin/

sed -i "s@daemonize no@daemonize yes@g" /usr/local/redis/redis.conf
sed -i "s@port 6379@port 5495@g" /usr/local/redis/redis.conf
sed -i "s@bind 127.0.0.1@bind 0.0.0.0@g" /usr/local/redis/redis.conf
sed -i "s@logfile ""@logfile "/home/redislog/run.log"@g" /usr/local/redis/redis.conf
sed -i "s@dir ./@dir /home/redisdb@g" /usr/local/redis/redis.conf
sed -i "s@# maxmemory <bytes>@maxmemory 1991278592@g" /usr/local/redis/redis.conf
sed -i "s@#  notify-keyspace-events Ex@notify-keyspace-events Ex@g" /usr/local/redis/redis.conf
sed -i "s@notify-keyspace-events ""@#notify-keyspace-events ""@g" /usr/local/redis/redis.conf
sed -i "s@# requirepass foobared@requirepass yadea123@g" /usr/local/redis/redis.conf

# 启动


redis-server /usr/local/redis/redis.conf

netstat -anp|grep 5495

echo "redis-server /usr/local/redis/redis.conf &"  >> /etc/rc.d/rc.local
echo "redis安装完成，端口5495，密码为yadea123"
