centOS上安裝redis

來源:互聯網
上載者:User

標籤:

1.安裝tcl支援

yum install tcl

  

2.安裝redis我們以最新的2.8.9為例

$ wget http://download.redis.io/releases/redis-2.8.9.tar.gz$ tar xzf redis-2.8.9.tar.gz$ cd redis-2.8.9$ make$ make test$ make install

 

測試通過後安裝,安裝後會自動把redis-server,redis-cli,redis-benchmark,redis-check-aof,redis-check-dump複製到/usr/local/bin目錄下。

編輯redis.conf檔案

vi redis.conf

修改daemonize no改成yes。

我們手動複製redis.conf到/etc目錄下

cp redis.conf /etc

編寫自init.d指令碼。

內容如下:

############################chkconfig: 2345 10 90#description: Start and Stop redisPATH=/usr/local/bin:/sbin:/usr/bin:/bin   REDISPORT=6379EXEC=/usr/local/bin/redis-serverREDIS_CLI=/usr/local/bin/redis-cli   PIDFILE=/var/run/redis.pidCONF="/etc/redis.conf"   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 does not exist, process is not running"        else                PID=$(cat $PIDFILE)                echo "Stopping ..."                $REDIS_CLI -p $REDISPORT SHUTDOWN                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 1esac##############################

可以通過winscp上傳到/etc/init.d/目錄下

修改許可權,可以運行

chmod +x /etc/init.d/redis

設定開機自動啟動服務

sudo chkconfig redis on

 

啟動服務:

service redis start

停止服務:

service redis stop

 

配置防火牆開啟對應的連接埠:

vi /etc/sysconfig/iptables
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT

 重啟防火牆

service iptables restar

centOS上安裝redis

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.