centos7 redis5 compile and install

Redis download the installation package, perform in the root directory

wget http://download.redis.io/releases/redis-5.0.4.tar.gz

Extracting installation package redis

tar -zxvf redis-5.0.4.tar.gz

Enter redis directory

cd redis-5.0.4

Compile

 make

After suggesting that you make make test case under you make test

Not surprisingly, being given it, being given as follows:

the used_memory of replica is much larger than master. Master:43866080 Replica:127752160

A false alarm, it is a warning that you can continue to the next step regardless of

make install

redis configuration changes

cd  /usr/local/redis/
## 将/usr/local/redis/bin加入到PATH中
echo "export PATH=$PATH:/usr/local/redis/bin" > /etc/profile.d/redis_bin.sh

source /etc/profile.d/redis_bin.sh 


## 创建配置文件目录
mkdir /usr/local/redis/etc

## 拷贝配置文件
cp /root/redis-5.0.5/redis.conf   /usr/local/redis/etc/


## 默认情况下,Redis服务不会在后台静默执行,需要通过使用&显示指定后台执行或改redis配置文件
vim  /usr/local/redis/etc/redis.conf

## 将daemonize的值改为yes
daemonize yes

## 将bind 127.0.0.1改为bind 0.0.0.0
bind 0.0.0.0

## 将requirepass foobared 去掉#改成自己的密码
requirepass  123456root

redis start

Direct start

`` `Cd to the directory where the back redis redis-server add your profile

## 直接关闭

[root@master ~]# ps -ef|grep redis
root 15659 1 0 14:20 ? 00:00:00 /usr/local/redis/bin/redis-server 0.0.0.0:6379
root 15665 10964 0 14:21 pts/1 00:00:00 grep --color=auto redis
[root@master ~]# kill -9 15659

## 系统启动

## 编辑启动脚本

vim /etc/init.d/redis

!/bin/sh

chkconfig: 2345 10 90

description: Start and Stop redis

Simple Redis init.d script conceived to work on Linux systems

as it does use of the /proc filesystem.

REDISPORT=6379
EXEC=/usr/local/redis/bin/redis-server
CLIEXEC=/usr/local/redis/bin/redis-cli

PIDFILE=/run/redis_6379.pid
CONF=/usr/local/redis/etc/redis.conf
AUTH=123456root

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 -a $AUTH 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 start

service redis start

redis Close

service redis stop

Add to redis at startup

chkconfig --add redis

## 额外相关操作

echo $ PATH environment variable to see what
/ means find
the next n represents a
cp copy
shift + a insert mode
`

Guess you like

Origin www.cnblogs.com/pp8080/p/12111453.html