一、安装Redis
1.获取redis资源
wget http://download.redis.io/releases/redis-4.0.8.tar.gz
2.解压
tar xzvf redis-4.0.8.tar.gz
3.安装
cd redis-4.0.8
make
cd src
make install PREFIX=/usr/local/redis
(如果有执行出错,先安装gcc。安装命令为:yum -y install gcc automake autoconf libtool make 。
若出现【zmalloc.h:50:31: 致命错误:jemalloc/jemalloc.h:没有那个文件或目录】,则运行命令make MALLOC=libc)
4.移动配置文件到安装目录下
cd ../
mkdir /usr/local/redis/etc
mv redis.conf /usr/local/redis/etc
5.配置redis为后台启动
vi /usr/local/redis/etc/redis.conf //将daemonize no 改成daemonize yes
6.开启redis desktop manager远程连接的配置
将第70行的bind注释,第90行将protected-mode改为no
7.设置密码
取消第502行的注释,并修改密码
8.将redis加入到开机启动
vi /etc/rc.local //在里面添加内容:/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf (意思就是开机调用这段开启redis的命令)
9.开启redis
usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
10.重启redis
#首先查询到redis的pid后,kill掉,然后重启
[[email protected] bin]# ps -ef|grep redis|grep -v grep
root 20940 1 0 12:12 ? 00:00:18 ./redis-server *:6379
[[email protected] bin]# kill -9 20940
[[email protected] bin]# ./redis-server redis.conf
10.常用命令
redis-server /usr/local/redis/etc/redis.conf //启动redis
pkill redis //停止redis
二、卸载redis:
rm -rf /usr/local/redis //删除安装目录
rm -rf /usr/bin/redis-* //删除所有redis相关命令脚本
rm -rf /root/download/redis-4.0.4 //删除redis解压文件夹