下载redis安装包,在root目录下执行
wget http://download.redis.io/releases/redis-5.0.4.tar.gz
解压redis安装包
tar -zxvf redis-5.0.4.tar.gz
进入redis目录
cd redis-5.0.4
编译
make
make之后 提示你make test下 那你就make test下
不出意外报错了吧,报错如下:
the used_memory of replica is much larger than master. Master:43866080 Replica:127752160
虚惊一场,这是警告 你可以不管 继续下一步
make install
redis配置修改
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启动
直接启动
```cd到redis所在的目录后 redis-server 后面加你的配置文件
## 直接关闭
[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启动
service redis start
redis关闭
service redis stop
redis添加到开机自动启动
chkconfig --add redis
## 额外相关操作
echo $PATH 看环境变量有哪些
/代表查找
n 代表下一个
cp 拷贝
shift+a 插入模式
```