Linux安装redis
链接:https://pan.baidu.com/s/1i1zB6PgFjHau7eS64qqT5A
提取码:d3ak
1:将redis压缩包上传到/usr/local/mysoft目录下
2:cd /usr/local/local/mysoft 进入mysoft目录
[root@localhost bin]# cd /usr/local/mysoft/ [root@localhost mysoft]# ls apache-maven-3.5.4 apache-tomcat-7.0.93 jdk1.8.0_212 mysql redis-4.0.9.tar.gz
3:tar -zxvf redis-4.0.9.tar.gz 解压redis压缩包
4:解压完成后ls,发现mysoft目录下多了一个redis-4.0.9目录,它就是解压后的文件夹
[root@localhost mysoft]# ls
apache-maven-3.5.4 apache-tomcat-7.0.93 jdk1.8.0_212 mysql redis-4.0.9 redis-4.0.9.tar.gz
5:cd redis-4.0.9/ 进入解压后的redis目录
root@localhost mysoft]# cd redis-4.0.9/ [root@localhost redis-4.0.9]# ls 00-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
7:make
[root@localhost redis-4.0.9]# make cd src && make all make[1]: 进入目录“/usr/local/mysoft/redis-4.0.9/src” CC Makefile.dep make[1]: 离开目录“/usr/local/mysoft/redis-4.0.9/src” make[1]: 进入目录“/usr/local/mysoft/redis-4.0.9/src”
8:make install PREFIX='/usr/local/mysoft/redis-4.0.9/6379' 将redis安装到/usr/local/mysoft/redis-4.0.9/6379目录下
[root@localhost redis-4.0.9]# make install PREFIX='/usr/local/mysoft/redis-4.0.9/6379' cd src && make install make[1]: 进入目录“/usr/local/mysoft/redis-4.0.9/src” CC Makefile.dep make[1]: 离开目录“/usr/local/mysoft/redis-4.0.9/src” make[1]: 进入目录“/usr/local/mysoft/redis-4.0.9/src”
9:安装完成后ls,发现当前目录(即/usr/local/mysoft/redis-4.0.9)下多了个6379文件夹
[root@localhost redis-4.0.9]# ls 00-RELEASENOTES BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests 6379 CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
10:cp redis.conf /usr/local/mysoft/redis-4.0.9/6379/bin/ 将当前目录下的redis.conf文件拷贝到6379的bin目录下
[root@localhost redis-4.0.9]# cp redis.conf /usr/local/mysoft/redis-4.0.9/6379/bin/
11:cd /usr/local/mysoft/redis-4.0.9/6379/bin/ 进入6379的bin目录下
[root@localhost redis-4.0.9]# cd /usr/local/mysoft/redis-4.0.9/6379/bin/
[root@localhost bin]# ls
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis.conf redis-sentinel redis-server
12:vim redis.conf 编辑redis配置文件,改动如下
- bind 127.0.0.1 # 将这行代码注释,监听所有的ip地址,外网可以访问
- protected-mode yes # 把yes改成no,允许外网访问
- daemonize no # 把no改成yes,允许后台运行
13:./redis-server redis.conf 在6379/bin目录下启动redis服务
[root@localhost bin]# ./redis-server redis.conf 13039:C 01 May 13:49:03.346 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 13039:C 01 May 13:49:03.346 # Redis version=4.0.9, bits=64, commit=00000000, modified=0, pid=13039, just started 13039:C 01 May 13:49:03.346 # Configuration loaded
14:ps -ef|grep redis 查看redis状态,如果出现以下内容,说明你的redis服务以及成功开启
[root@localhost bin]# ps -ef|grep redis root 13040 1 0 13:49 ? 00:00:00 ./redis-server *:6379 root 13045 2304 0 13:49 pts/0 00:00:00 grep --color=auto redis
15:./redis-cli 同样在6379的bin目录下开启redis客户端
[root@localhost bin]# ./redis-cli
127.0.0.1:6379>
16:config set requirepass 244622 设置redis客户端密码
127.0.0.1:6379> config set requirepass 244622
OK
17:auth 244622 进行登录认证
127.0.0.1:6379> auth 244622
OK
18:config rewrite 保存修改
127.0.0.1:6379> config rewrite
OK
19:set name zs 向redis中存一个值
127.0.0.1:6379> set name zs
OK
20:get name 取出存入的值
127.0.0.1:6379> get name
"zs"
21:打开远程连接工具,测试连接
22:如果以上步骤一切正常,说明你的redis安装并启动成功