简单易懂快速上手Linux配置Redis
1.准备工作
想要在Linux上安装redis,需要先在Linux上安装一些依赖库(运行环境):gcc、gcc-c++
如果你的电脑上已经安装过这两个依赖环境,而且版本不匹配,使用以下命令进行卸载:
yum -y remove gcc gcc-c++
使用root账号登陆Linux,在命令行执行下面的命令 进行安装
yum -y install gcc gcc-c++
2.下载安装包
http://download.redis.io/releases/
3.解压压缩包
tar -zxvf redis-4.0.1.tar.gz
4.为解压好的路径重命名
mv redis-4.0.1 redis
5.编译redis源码 进入redis路径下,执行如下命令
make
6.安装redis程序 在第四步的同一路径下,运行以下命令
make install
7.启动redis服务端启动
[root@system redis]# cd /usr/local/redis/
[root@system redis]# ./bin/redis-server /etc/redis.conf
[root@system redis]# ps axu | grep redis
8.客户端启动
redis-cli [-h 127.0.0.1] [-p 6379]
127.0.0.1:6379> ping
开机自动启动Redis
vi etc/rc.d/rc.local
在文件中加入,当中文件及路径以实际为主
/usr/redis/src/redis-server /usr/redis/redis.conf
/usr/redisdeploy/redis6395/logs/redis.log
port 6380
bind 0.0.0.0
protected-mode no
daemonize yes
loglevel notice
logfile "E:/Redis/Logs/redis6380_log.txt"
appendonly yes
appendfilename "appendonly.6380.aof"
cluster-enabled yes
cluster-config-file nodes.6380.conf
cluster-node-timeout 15000