アリクラウドCentOS 6.8にRedisをインストールする

3500 ワード

    CentOS 6.8   Redis

1、redisをダウンロードする次のコマンドを使用してredisをダウンロードする:wgethttp://download.redis.io/releases/redis-3.2.0.tar.gz
2、コンパイルインストールtar xzf redis-3.2.0.tar.gz cd redis-3.2.0 make make testですが、make testコマンドを実行するとエラーが発生しました.You need tcl 8.5 or newer in order to run the Redis test make:***[test]Error 1理由はtcl 3がインストールされていないため、tclをインストールして次のコマンドを実行してtclをインストールする:wgethttp://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz # sudo tar xzvf tcl8.6.1-src.tar.gz -C/usr/local/cd/usr/local/tcl8.6.1/unix/sudo ./configure sudo make sudo make install 4、インストール完了後、make test cd src make install PREFIX=/usr/local/redis 5、インストールディレクトリにプロファイルをコピーするcd.../mkdir/usr/local/redis/etc cp redis.conf/usr/local/redis/etc 6、redisをバックグラウンドにvi/usr/local/redis/etc/redisを起動するように構成する.conf//daemonize noをdaemonize yes 7に変更し、init起動ファイルvim/etc/initを新規作成します.d/redisの内容は以下の通りである.
#!/bin/sh #redis Startup script for Redis Server

#chkconfig: - 80 12 #description: Redis is an open source, advanced key-value store.

#processname: redis-server #config: /etc/redis.conf #pidfile: /var/run/redis.pid source /etc/init.d/functions BIN="/usr/local/redis/bin" CONFIG="/usr/local/redis/redis.conf" PIDFILE="/var/run/redis.pid" ###Read configuration [ -r “KaTeX parse error: Expected 'EOF', got '&' at position 14: SYSCONFIG" ] &̲& source "SYSCONFIG” RETVAL=0 prog=“redis-server” desc=“Redis Server” start() { if [ -e P I D F I L E ] ; t h e n e c h o " PIDFILE ];then echo " PIDFILE];thenecho"desc already running…" exit 1 fi echo -n $"Starting $desc: " daemon B I N / BIN/ BIN/prog C O N F I G R E T V A L = CONFIG RETVAL= CONFIGRETVAL=? echo [ KaTeX parse error: Expected 'EOF', got '&' at position 16: RETVAL -eq 0 ] &̲& touch /var/lo…prog return $RETVAL } stop() { echo -n $"Stop $desc: " killproc p r o g R E T V A L = prog RETVAL= progRETVAL=? echo [ KaTeX parse error: Expected 'EOF', got '&' at position 16: RETVAL -eq 0 ] &̲& rm -f /var/lo…prog $PIDFILE return $RETVAL } restart() { stop start } case " 1 " i n s t a r t ) s t a r t ; ; s t o p ) s t o p ; ; r e s t a r t ) r e s t a r t ; ; c o n d r e s t a r t ) [ − e / v a r / l o c k / s u b s y s / 1" in start) start ;; stop) stop ;; restart) restart ;; condrestart) [ -e /var/lock/subsys/ 1"instart)start;;stop)stop;;restart)restart;;condrestart)[−e/var/lock/subsys/prog ] && restart RETVAL=$? ;; status) status p r o g R E T V A L = prog RETVAL= progRETVAL=? ;; *) echo $“Usage: $0 {start|stop|restart|condrestart|status}” RETVAL=1 esac exit $RETVAL 8、権限chmod+x/etc/initを修正する.d/redis環境変数を修正し、redis-cli等の実行を容易にする 9、vim/etc/profile/etc/profile/etc/profileファイルにredis関連コマンドの実行パス/usr/local/redis/bin:export PATH=/usr/local/redis/bin:$PATHを追加し、有効なsource/etc/profile 10を更新し、起動サービスsudo chkconfig redisを設定し、設定が有効かどうかを確認する。root@qingguan redis-3.2.0]# sudo chkconfig redis on service redis does not support chkconfig [[email protected]]#chkconfig--list redis service redis does not support chkconfig問題解決方法は以下の通りである。 次の2行の注釈を/etc/initに置く必要があります。d/redisファイルの前のコメント: #chkconfig:2345 90 10#description:Redis is a persistent key-value database上の注記は、redisサービスが実行レベル2,3,4,5で起動または停止されなければならないことを意味し、起動の優先度は90であり、閉鎖の優先度は10である。 11、サービスの起動または停止:/usr/local/redis/bin/redis-server/usr/local/redis/etc/redis.conf 検証は以下の通りです:ps axuf|grep redis