1. 安装位置:
这里选择/opt
cd /opt
2. 下载安装Redis:
wget http://download.redis.io/releases/redis-5.0.7.tar.gz
tar xzf redis-5.0.7.tar.gz
cd redis-5.0.7
make
如果报make或者cc命令无法找到,则执行以下命令:
yum -y install make
yum install gcc
安装好gcc和make后,需要将原来解压出的文件删除,重新解压一遍,命令如下:
rm -rf redis-5.0.7
tar xzf redis-5.0.7.tar.gz
cd redis-5.0.7
make
make完成会出现:Hint: It’s a good idea to run ‘make test’ 😉
此时执行
make test
进行测试,如果出现 “You need tcl 8.5 or newer in order to run the Redis test” 提示
cd /opt
wget http://downloads.sourceforge.net/tcl/tcl8.6.10-src.tar.gz
sudo tar xzvf tcl8.6.10-src.tar.gz -C /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install
服务器下载没有速度,可以考虑手动下载然后传到服务器:tcl8610-src.zip
unzip tcl8610-src.zip
mv tcl8.6.10/ /usr/local/
cd /usr/local/tcl8.6.1/unix/
sudo ./configure
sudo make
sudo make install
此时再进行make test即可:
cd /opt/redis-5.0.7
make test
3. 配置Redis
cd /opt/redis-5.0.7
vi redis.conf
移动光标找到对应字段,然后按i键进行编辑,编辑完后按Esc键,然后输入:wq进行保存。
# 首先,将IP绑定localhost给注销掉,这样就可以接受来自任何IP的请求:
# bind 127.0.0.1
# 然后将保护模式关闭,保护模式会在没有绑定特定IP并且没有设置密码的情况下,只接受本地的请求。
protected-mode no
# 这里改为yes,使服务成为后台应用,这样关闭现在的终端也能运行:
daemonize yes
# 如果有需要,可以设置Redis连接密码,将下面字段foobared改为自己的密码,并取消注释。
# requirepass foobared
4. 运行Redis服务
/opt/redis-5.0.7/src/redis-server /opt/redis-5.0.7/redis.conf
查看Redis进程:
ps -ef | grep redis
5. 查看Redis
此处推荐一个免费好用的客户端:Another Redis Desktop Manager