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,点击对话->新建,弹窗如图

输入名称,自己任意起名,这里我起名CentOSMini。
主机框输入,查询到的CentOSMini的inet地址。
端口号,默认22,如果端口被占用可能导致连接失败。
点击用户身份验证,输入CentOSMini的账户和密码

配置完成,尝试连接。如果连接失败,请自行排查原因。
默认连接成功,开始安装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

 

全部评论

相关推荐

06-26 18:30
门头沟学院 Java
据说名字越长别人越关...:你问问这里面有多少是正经候选人,而不是乱打招呼的
点赞 评论 收藏
分享
05-11 11:48
河南大学 Java
程序员牛肉:我是26届的双非。目前有两段实习经历,大三上去的美团,现在来字节了,做的是国际电商的营销业务。希望我的经历对你有用。 1.好好做你的CSDN,最好是直接转微信公众号。因为这本质上是一个很好的展示自己技术热情的证据。我当时也是烂大街项目(网盘+鱼皮的一个项目)+零实习去面试美团,但是当时我的CSDN阅读量超百万,微信公众号阅读量40万。面试的时候面试官就告诉我说觉得我对技术挺有激情的。可以看看我主页的美团面试面经。 因此花点时间好好做这个知识分享,最好是单拉出来搞一个板块。各大公司都极其看中知识落地的能力。 可以看看我的简历对于博客的描述。这个帖子里面有:https://www.nowcoder.com/discuss/745348200596324352?sourceSSR=users 2.实习经历有一些东西删除了,目前看来你的产出其实很少。有些内容其实很扯淡,最好不要保留。有一些点你可能觉得很牛逼,但是面试官眼里是减分的。 你还能负责数据库表的设计?这个公司得垃圾成啥样子,才能让一个实习生介入数据库表的设计,不要写这种东西。 一个公司的财务审批系统应该是很稳定的吧?为什么你去了才有RBAC权限设计?那这个公司之前是怎么处理权限分离的?这些东西看着都有点扯淡了。 还有就是使用Redis实现轻量级的消息队列?那为什么这一块不使用专业的MQ呢?为什么要使用redis,这些一定要清楚, 就目前看来,其实你的这个实习技术还不错。不要太焦虑。就是有一些内容有点虚了。可以考虑从PR中再投一点产出
投递美团等公司9个岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务