centOS安裝redis3.0.6
1. 安裝
尋找一個初始安裝目錄
cd /usr/local/share/applications
wget http://download.redis.io/releases/redis-3.0.6.tar.gz
tar zxvf redis-3.0.6.tar.gz
cd redis-3.0.6
cd /src
make&make install
make test
如果顯示
You need tcl 8.5 or newer in order to run the Redis test
make: *** [test] Error 1
表示需要安裝tcl
安裝tcl
wget http://downloads.sourceforge.net/tcl/tcl8.5.12-src.tar.gz
tar zxvf tcl8.5.12-src.tar.gz
cd tcl8.5.12/unix
./configure options
make
make test
make install
2. 設定redis為開機自啟動的系統服務
修改redis安裝根目錄下的redis.conf檔案,修改下列這段
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in /var/run/redis.pid when daemonized.
daemonize yes
執行命令
cp redis.conf /etc
rename redis.conf 6379.conf(建議重新命名為埠,方便做redis叢集配置)
cp redis-benchmark redis-cli redis-server /usr/bin/
如果沒有/var/rdb/
則建立該目錄
mkdir /var/rdb/
新建reids自啟動指令碼
新建檔案redis,放入/etc/init.d目錄下
redis啟動指令碼內容示例:
#!/bin/sh
# chkconfig: 2345 90 10
# Simple Redis init.d script conceived to work on Linux systems
# as it does use of the /proc filesystem.
REDISPORT=6379
EXEC=/usr/bin/redis-server
CLIEXEC=/usr/bin/redis-cli
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/etc/${REDISPORT}.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
;;
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
;;
*)
echo "Please use start or stop as first argument"
;;
esac
賦予許可權
chmod +x /etc/init.d/redis
加入到系統服務中
如果沒有redis
chkconfig --add redis
如果有
chkconfig redis on
嘗試啟動或停止redis
service redis start
service redis stop
重啟系統
reboot
兩種確認redis是否已開機自啟動的方法
ps -ef | grep redis
結果
或輸入
redis-cli
輸入ping返回PONG即redis執行OK
相關文章
- centos安裝nodeCentOS
- centos 安裝pyenvCentOS
- CentOS 安裝 dockerCentOSDocker
- CentOS安裝jdkCentOSJDK
- CentOS Docker 安裝CentOSDocker
- Centos 安裝 JenkinsCentOSJenkins
- centOS安裝rabbitMQCentOSMQ
- CentOS 安裝 mavenCentOSMaven
- Jenkins CentOS 安裝JenkinsCentOS
- CentOS安裝gitCentOSGit
- CentOS 安裝 JDKCentOSJDK
- CentOS安裝GraphicsMagickCentOS
- Centos 安裝RedisCentOSRedis
- CentOS 安裝ErlangCentOS
- 【CentOS】CentOS7安裝PostgreSQLCentOSSQL
- CentOS7安裝php、安裝MySqlCentOSPHPMySql
- Centos7安裝安裝部署dockerCentOSDocker
- Centos7.9安裝解除安裝DockerCentOSDocker
- Linux系統安裝——Centos 7.6安裝LinuxCentOS
- Centos Docker安裝、升級、解除安裝CentOSDocker
- CentOS 安裝 mysql 5.6CentOSMySql
- 安全:centos安裝aideCentOSAIIDE
- centos 7.6 安裝 nginxCentOSNginx
- CentOS Python 3.12安裝CentOSPython
- Centos 安裝 Docker|教程CentOSDocker
- 安裝centOS版本oracleCentOSOracle
- Centos下安裝ffmpegCentOS
- centos 安裝 jdk 8CentOSJDK
- Centos 7 Docker 安裝CentOSDocker
- CentOS 8.4安裝DockerCentOSDocker
- CentOS 上安裝 NginxCentOSNginx
- centos下安裝dockerCentOSDocker
- VMware安裝Linux CentOSLinuxCentOS
- CentOS 7 安裝redisCentOSRedis
- CentOS 7安裝ElasticsearchCentOSElasticsearch
- centos上安裝grafanaCentOSGrafana
- Centos 7安裝iscsiCentOS
- centos 7 安裝 rabbitMqCentOSMQ
- CentOS7安裝rabbitmqCentOSMQ