Centos 7 Redis 5の詳細チュートリアルをインストールし、自己起動を構成
3454 ワード
Redisのインストール
ファイルの解凍
tar xvf redis-5.0.4.tar.gz
rm -rf redis-5.0.4.tar.gz #
redisディレクトリのインストールに入ります
cd redis-5.0.4/
make && make install
プロファイルredisを変更します。conf
vi redis.conf
#
# bind 127.0.0.1
# no,
protected-mode no
:wq
フロント起動(バックグラウンドに変更することを推奨)
redis-server redis.conf
バックグラウンド起動
vi redis.conf #
# yes,
daemonize yes
テスト
redis-server redis.conf #
redis-cli #
POSTの設定
vi /etc/init.d/redis
#!/bin/sh
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/home/leyou/redis-5.0.4/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 1
esac
ファイル権限の付与
chmod 755 /etc/init.d/redis
chkconfig --add /etc/init.d/redis
chkconfig redis on
開始
redis-server redis.conf
redis-cli
開発ポート
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload
tar xvf redis-5.0.4.tar.gz
rm -rf redis-5.0.4.tar.gz #
cd redis-5.0.4/
make && make install
vi redis.conf
#
# bind 127.0.0.1
# no,
protected-mode no
:wq
redis-server redis.conf
vi redis.conf #
# yes,
daemonize yes
redis-server redis.conf #
redis-cli #
vi /etc/init.d/redis
#!/bin/sh
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/local/bin/redis-server
REDIS_CLI=/usr/local/bin/redis-cli
PIDFILE=/var/run/redis.pid
CONF="/home/leyou/redis-5.0.4/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 1
esac
chmod 755 /etc/init.d/redis
chkconfig --add /etc/init.d/redis
chkconfig redis on
redis-server redis.conf
redis-cli
firewall-cmd --zone=public --add-port=6379/tcp --permanent
firewall-cmd --reload