前提安装c的环境:
yum install cpp
yum install binutils
yum install glibc
yum install glibc-kernheaders
yum install glibc-common
yum install glibc-devel
yum install gcc
yum install make
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
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加入到开机启动
vi /etc/rc.local //在里面添加内容:/usr/local/redis/bin/redis-server
/usr/local/redis/etc/redis.conf (意思就是开机调用这段开启redis的命令)
7.开启redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
8.修改redis.conf不然只有本机才能访问
把 bind 127.0.0.1 注释掉
设置密码 requirepass foobared去掉注释并改成 requirepass+密码
9.放开防火墙
在/etc/sysconfig/iptables中加一行
-A INPUT -m state --state NEW -m tcp -p tcp --dport 6379 -j ACCEPT
常用命令
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解压文件夹
网友评论