$cd src $ ./redis-cli redis>set foo bar OK redis> get foo "bar"
redis绿色安装
安装到指定目录
1 2 3 4 5 6 7 8
# 安装到 /usr/local/redis
installpath=/usr/local/redis mkdir -p $installpath cd redis-5.0.5 make MALLOC=libc make PREFIX=$installpath install \cp -f redis.conf $installpath
功能测试(耗时较长,非必须执行)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
在安装成功之后,可以运行测试,确认Redis的功能是否正常 [root@localhost ~]# make test
出现报错: hadoop@stormspark:~/workspace/redis2.6.13/src$ make test You need tcl 8.5or newer in order to run the Redis test make: *** [test] Error 1
解决方式 yum install -y tcl
重新执行测试 [root@localhost ~]# make test
......
\o/ All tests passed without errors!
Cleanup: may take some time... OK
修改配置文件
1 2 3 4 5
installpath=/usr/local/redis sed -i'/^bind/c#bind 127.0.0.1'"$installpath/redis.conf" sed -i'/^protected-mode/cprotected-mode no'"$installpath/redis.conf" sed -i'/^logfile/clogfile "'$installpath'/redis.log"'"$installpath/redis.conf" sed -i'/^pidfile/cpidfile "'$installpath'/redis.pid"'"$installpath/redis.conf"
#!/bin/sh #Configurations injected by install_server below....
EXEC=/usr/local/redis/bin/redis-server CLIEXEC=/usr/local/redis/bin/redis-cli PIDFILE=/usr/local/redis/redis.pid CONF="/usr/local/redis/redis.conf" REDISPORT="6379" ############### # SysV Init Information # chkconfig: - 58 74 # description: redis_6379 is the redis daemon. ### BEGIN INIT INFO # Provides: redis_6379 # Required-Start: $network $local_fs $remote_fs # Required-Stop: $network $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Should-Start: $syslog $named # Should-Stop: $syslog $named # Short-Description: start and stop redis_6379 # Description: Redis daemon ### END INIT INFO
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 shutdown while [ -x /proc/${PID} ] do echo"Waiting for Redis to shutdown ..." sleep 1 done echo"Redis stopped" fi ;; status) PID=$(cat $PIDFILE) if [ ! -x /proc/${PID} ] then echo'Redis is not running' else echo"Redis is running ($PID)" fi ;; restart) $0 stop $0 start ;; *) echo"Please use start, stop, restart or status as first argument" ;; esac