Redis 官网:https://redis.io/
Redis 在线测试:http://try.redis.io/
Redis菜鸟教程: https://www.runoob.com/redis/redis-tutorial.html




root@ubuntu:/mydata/redis/conf# cd /mnt
root@ubuntu:/mnt# ls
hgfs
root@ubuntu:/mnt# cd hgfs
root@ubuntu:/mnt/hgfs# ls
myshare
root@ubuntu:/mnt/hgfs# cd myshare
root@ubuntu:/mnt/hgfs/myshare# ls
redis-4.0.0.tar.gz
root@ubuntu:/mnt/hgfs/myshare#
root@ubuntu:/mnt/hgfs/myshare# tar -zxvf redis-4.0.0.tar.gz -C /usr/local

root@ubuntu:/mnt/hgfs/myshare# cd /usr/local
root@ubuntu:/usr/local# ls

sudo apt-get install gcc-c++

root@ubuntu:/usr/local# ls
arm bin etc games include lib man redis-4.0.0 sbin share src
root@ubuntu:/usr/local# ls
arm bin etc games include lib man redis-4.0.0 sbin share src
root@ubuntu:/usr/local# cd redis-4.0.0
root@ubuntu:/usr/local/redis-4.0.0# ls
00-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
root@ubuntu:/usr/local/redis-4.0.0# make

root@ubuntu:/usr/local/redis-4.0.0# cd src
root@ubuntu:/usr/local/redis-4.0.0/src# ls
root@ubuntu:/usr/local/redis-4.0.0/src# make install


redis-server:启动redis服务
redis-cli:客户端
root@ubuntu:/usr/local/redis-4.0.0/src# cd ..
root@ubuntu:/usr/local/redis-4.0.0# ls

cat redis.conf

root@ubuntu:/usr/local/redis-4.0.0/src# ./redis-server
端口号:6379
Pid(进程号):不固定

./redis-cli

默认情况下是 no

修改为yes,可以后台服务


root@ubuntu:/usr/local/redis-4.0.0# src/redis-server ./redis.conf



redis在默认情况下是不需要密码的(配置文件呈现注释状态)

打开命令行 设置密码为123456

root@ubuntu:/usr/local/redis-4.0.0# ps -ef | grep redi

kill -9 进程名
root@ubuntu:/usr/local/redis-4.0.0# src/redis-server ./redis.conf
src/redis-cli -h localhost -p 6379
执行keys * 命令发现 需要认证密码

auth 密码


exit
src/redis-cli -h localhost -p 6379 -a 123456

使用windos的redis-cli连接虚拟机的redis服务
root@ubuntu:/usr/local/redis-4.0.0# ifconfig

redis-cli -h 192.168.192.128 -p 6379

发现无法连接,是因为没有修改redis的配置文件的远程链接
发现配置文件默认连接的主机是 bind 127.0.0.1


root@ubuntu:/usr/local/redis-4.0.0# ls
00-RELEASENOTES CONTRIBUTING deps Makefile README.md runtest runtest-sentinel src utils
BUGS COPYING INSTALL MANIFESTO redis.conf runtest-cluster sentinel.conf tests
root@ubuntu:/usr/local/redis-4.0.0# vim redis.conf
root@ubuntu:/usr/local/redis-4.0.0# ps -ef | grep redis
systemd+ 137239 137220 0 11:55 ? 00:00:24 redis-server *:6379
root 142116 136919 0 16:22 pts/0 00:00:00 grep --color=auto redis
root@ubuntu:/usr/local/redis-4.0.0# kill -9 137239
root@ubuntu:/usr/local/redis-4.0.0# ps -ef | grep redis
root 142228 136919 0 16:22 pts/0 00:00:00 grep --color=auto redis
root@ubuntu:/usr/local/redis-4.0.0# src/redis-server ./redis.conf
142265:C 16 Nov 16:23:50.015 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
142265:C 16 Nov 16:23:50.015 # Redis version=4.0.0, bits=64, commit=00000000, modified=0, pid=142265, just started
142265:C 16 Nov 16:23:50.015 # Configuration loaded
root@ubuntu:/usr/local/redis-4.0.0# ps -ef | grep redis
systemd+ 142219 142194 0 16:22 ? 00:00:00 redis-server *:6379
root 142268 136919 0 16:23 pts/0 00:00:00 grep --color=auto redis



发现成功连接