redisのlinuxでのインストール開始

2970 ワード

1./usr/localの下にドラッグ
2.解凍
    tar zxf redis-4.0.8.tar.gz
3. mkdir/usr/redis
4.コンパイル
    cd redis-4.0.8/src    make
make完了後redis-4.0.8のSRCディレクトリには実行可能ファイルredis-server、redis-benchmark、redis-cli、redisが4つあります.conf.
この4つのファイルを/usr/redisにコピーします
  mv redis-server/usr/redis  mv redis-benchmark/usr/redis  mv redis-cli/usr/redis  mv redis.conf/usr/redis
5. yum install redis
次にスクリプトを作成
# chkconfig: 2345 10 90  
# description: Start and Stop redis   
  
PATH=/usr/local/bin:/sbin:/usr/bin:/bin   
REDISPORT=6379  
EXEC=/usr/bin/redis-server   
REDIS_CLI=/usr/bin/redis-cli   
 
PIDFILE=/var/run/redis.pid   
CONF="/etc/redis.conf"  
#AUTH="1234"    redis     

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   
                if [ "$?"="0" ]   
                then   
                        echo "Redis is running..."  
                fi   
                ;;   
        stop)   
                if [ ! -f $PIDFILE ]   
                then   
                        echo "$PIDFILE exists, process is not running."  
                else  
                        PID=$(cat $PIDFILE)   
                        echo "Stopping..."  
                       $REDIS_CLI -p $REDISPORT  SHUTDOWN    
                        sleep 2  
                       while [ -x $PIDFILE ]   
                       do  
                                echo "Waiting for Redis to shutdown..."  
                               sleep 1  
                        done   
                        echo "Redis stopped"  
                fi   
                ;;   
        restart|force-reload)   
                ${0} stop   
                ${0} start   
                ;;   
        *)   
               echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2  
                exit 1  
esac

6.権限の設定
    chmod 755 redis
7.POSTの設定
     chkconfig redis on
8.ファイアウォールを永久に閉じる
linux       
#  iptable
/etc/init.d/iptables stop
#  iptables     
/etc/init.d/iptables status
#   iptables      
chkconfig iptables off

9.Linuxの再起動
    reboot