一:下載redismysql
官網地址:http://redis.io/
redis
wget http://download.redis.io/redis-stable.tar.gztar xzf redis-stable.tar.gzcd redis-stablemake MALLOC=libcmake install
2、測試是否安裝成功sql
注意:redis服務默認端口號是6379,請設置防火牆保持該端口能夠訪問,設置好後能夠在客戶端使用telnet命令測試數據庫
telnet 172.19.32.xx 6379
啓動redis服務測試
redis-server
redis-server redis.conf
redis-cli SHUTDOWN
redis-cli -h 127.0.0.1 -p 6379
redis-cli PING
cp redis.conf /etc
# chkconfig: 2345 90 10# description: Redis is a persistent key-value databasePATH=/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##############################
vi /etc/init.d/redis
chmod +x /etc/init.d/redis
chkconfig redis on
service redis start #或者 /etc/init.d/redis startservice redis stop #或者 /etc/init.d/redis stop
redis-cli redis 127.0.0.1:6379> set foo 123OKredis 127.0.0.1:6379> get foo"123"redis 127.0.0.1:6379> exit