1、创建目录

/opt/softWare/redis5.0.5

2、解压压缩包

[root@master redis5.0.5]# tar -zxvf redis-5.0.5.tar.gz

3、编译安装

[root@master redis5.0.5]# cd redis-5.0.5/

[root@master redis-5.0.5]# ls
00-RELEASENOTES  CONTRIBUTING  deps     Makefile   README.md   runtest          runtest-moduleapi  sentinel.conf  tests
BUGS             COPYING       INSTALL  MANIFESTO  redis.conf  runtest-cluster  runtest-sentinel   src            utils

[root@master redis-5.0.5]# make && make install PREFIX=/opt/softWare/redis5.0.5/redis-5.0.5

4、修改配置文件

#绑定主机iP
bind 192.168.xxx.21
#设置端口号
port 6379
#启用后台运行
daemonize yes
#修改redis库的数量,默认16
databases 32
#设置redis密码
requirepass 123456

5、启动

[root@master redis-5.0.5]# cd bin/
[root@master bin]# ls
redis-benchmark  redis-check-aof  redis-check-rdb  redis-cli  redis-sentinel  redis-server
[root@master bin]# ./redis-server ../redis.conf 
7089:C 31 Mar 2020 08:53:08.776 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
7089:C 31 Mar 2020 08:53:08.776 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=7089, just started
7089:C 31 Mar 2020 08:53:08.776 # Configuration loaded
[root@master bin]# netstat -lnp | grep 6379
tcp        0      0 192.168.xxx.21:6379     0.0.0.0:*               LISTEN      7090/./redis-server 

6、客户端连接

[root@master bin]# ./redis-cli -h 192.168.xxx.21 -a 123456
Warning: Using a password with '-a' or '-u' option on the command line interface may not be safe.
192.168.xxx.21:6379> DBSIZE
(integer) 0
192.168.xxx.21:6379> select 31
OK
192.168.xxx.21:6379[31]> DBSIZE
(integer) 0
192.168.xxx.21:6379[31]> set aa AA
OK
192.168.xxx.21:6379[31]> get aa
"AA"
192.168.xxx.21:6379[31]>

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐