Redis学习笔记(3)-XShell连接CentOSMini,并安装Redis

使用XShell远程连接CentOSMini

点击download下载XShell5.0。
下载之后安装。配置XShell。

配置XShell前的准备

打开VM,启动CentOSMini。CentOSMini启动之后进入Terminal。

[root@localhost ~]# ip addr

输入命令ip addr ,回车查看inet地址。

切换回Windows,打开CMD,输入命令ipconfig,回车查看IPv4地址。

>ipconfig

比对两个ip地址是否在同一IP段,即IP地址形式如{1}.{2}.{3}.{4},比对1,2,3部分是否相同,相同即为同一IP段,此为XShell连通虚拟机安装的CentOSMini的前提。

配置XShell

打开XShell,点击对话->新建,弹窗如图
配置1
输入名称,自己任意起名,这里我起名CentOSMini。
主机框输入,查询到的CentOSMini的inet地址。
端口号,默认22,如果端口被占用可能导致连接失败。
点击用户身份验证,输入CentOSMini的账户和密码
配置2
配置完成,尝试连接。如果连接失败,请自行排查原因。
默认连接成功,开始安装Redis。

安转Redis

以下配置,默认用户都未完成,如果已经完成,再次执行不会有影响。

加载插件gcc

[root@localhost ~]# yum gcc

加载插件wget

[root@localhost ~]# yum wget

下载及安装Redis

Redis安装包网址
最新的安装包为redis-3.0.7.tar.gz

[root@localhost ~]#wget http://download.redis.io/releases/redis-3.0.7.tar.gz
[root@localhost ~]#tar zxvf redis-3.0.7.tar.gz
[root@localhost ~]# cd redis-3.0.7
[root@localhost redis-3.0.7]# make MALLOC=libc

启动Redis

[root@localhost redis-3.0.7]# src/redis-server
14891:C 27 Apr 13:10:08.132 # Warning: no config file specified, using the default config. In order to specify a config file use src/redis-server /path/to/redis.conf
14891:M 27 Apr 13:10:08.132 * Increased maximum number of open files to 10032 (it was originally set to 1024).
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 3.0.7 (00000000/0) 64 bit
  .-`` .-```.  ```/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 14891
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

14891:M 27 Apr 13:10:08.134 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
14891:M 27 Apr 13:10:08.134 # Server started, Redis version 3.0.7
14891:M 27 Apr 13:10:08.134 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
14891:M 27 Apr 13:10:08.134 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
14891:M 27 Apr 13:10:08.135 * DB loaded from disk: 0.001 seconds
14891:M 27 Apr 13:10:08.135 * The server is now ready to accept connections on port 6379

测试Redis

在XShell,打开一个新的终端标签

[root@localhost ~]# ls
anaconda-ks.cfg  redis-3.0.7  redis-3.0.7.tar.gz
[root@localhost ~]# cd redis-3.0.7
[root@localhost redis-3.0.7]# src/redis-cli
127.0.0.1:6379> KEYS *
1) "user:1"
2) "test"
3) "Manager"
4) "name"
127.0.0.1:6379> 

退出Redis命令行

[root@localhost redis-3.0.7]# src/redis-cli
127.0.0.1:6379> quit
[root@localhost redis-3.0.7]# 

关闭Redis

Redis命令行下

[root@localhost redis-3.0.7]# src/redis-cli
127.0.0.1:6379> shutdown

非Redis命令行下

[root@localhost redis-3.0.7]# src/redis-cli shutdown
原文地址:https://www.cnblogs.com/AlienXu/p/6875966.html