大家好,现在开始来一个例子,我们先手动安装一下redis 4.0.1稳定版!
复制下面的步骤,你会非常容易的完成安装。
在这里,我们把redis的默认端口改为了7000,因为这个配置在后续的应用中是作为Redis集群的形式存在的。
mkdir -p /home/tools mkdir -p /etc/redis mkdir -p /var/log/redis mkdir -p /data/redis/7000 cd /home/tools yum -y install vim wget net-tools ruby-devel ruby ruby-rdoc tcl gcc gcc-c++ curl libyaml-devel make automake unzip wget -c http://download.redis.io/releases/redis-stable.tar.gz tar zxvf redis-stable.tar.gz cd /home/tools/redis-stable && make && make install #Install Rvm gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 curl -L get.rvm.io | bash -s stable source /usr/local/rvm/scripts/rvm #Install Ruby rvm install 2.3.3 gem install redis \cp /home/tools/redis-stable/src/redis-trib.rb /usr/local/bin/ #Config redis cat >/etc/redis/nodes-7000.conf<<EOF port 7000 bind 0.0.0.0 daemonize yes pidfile /var/run/redis_7000.pid logfile /var/log/redis/7000.log cluster-enabled yes cluster-config-file nodes-7000.conf cluster-node-timeout 5000 cluster-slave-validity-factor 10 appendonly yes dir /data/redis/7000 dbfilename dump-7000.rdb appendfilename "appendonly-7000.aof" EOF #Configure startup scripts cat >/etc/init.d/redis_7000<<EOF #!/bin/bash # chkconfig: - 85 15 EXEC="/usr/local/bin/redis-server" PIDFILE="/var/run/redis_7000.pid" CONF="/etc/redis/nodes-7000.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 sleep 1 echo "Redis has been started" fi ;; stop) if [ ! -f \$PIDFILE ] then echo "\$PIDFILE does not exist, process is not running." else PID=\$(cat \$PIDFILE) echo "Stopping Redis Server…" while [ -x /proc/\${PID} ] do kill -9 \$PID && rm -rf \$PIDFILE sleep 2 done echo "Redis stopped." fi ;; restart) \$0 stop \$0 start ;; status) if [ ! -f \$PIDFILE ];then echo "Redis is not running!" else echo "Redis is alreday running!" fi ;; *) echo "Usage: \$0 {start|stop|restart|status}" >&2 exit 1 esac EOF #Start Redis service /etc/init.d/redis_7000 start
转载于:https://blog.51cto.com/jinyan2049/1957929