redis虚拟机模拟集群,节点,增加多端口命令

<div class="single-title">Redis启动多端口,运行多实例


<div class="single-content">

使用redis在同一台机器上,启用多个端口,实现多个实例,完成集群的模拟实现。

  • 启动多实例

redis默认启动端口为6379,我们可以使用 --port 来指定多个端口,如下,在linux终端命令:


查看启动的redis实例:


QQ截图20150401095044.png

  • 使用实例

使用其中一个redis实例:

<span class="lit"><span class="lit">127.0<span class="pun"><span class="pun">.<span class="lit"><span class="lit">0.1<span class="pun"><span class="pun">:<span class="lit"><span class="lit">6380<span class="pun"><span class="pun">><span class="pln"><span class="pln"> keys <span class="str"><span class="str">'*'<span class="pln"><span class="pln">

<span class="pun"><span class="pun">(<span class="pln"><span class="pln">empty list <span class="kwd"><span class="kwd">or<span class="pln"><span class="pln"> <span class="kwd"><span class="kwd">set<span class="pun"><span class="pun">)<span class="pln"><span class="pln">

<span class="lit"><span class="lit">127.0<span class="pun"><span class="pun">.<span class="lit"><span class="lit">0.1<span class="pun"><span class="pun">:<span class="lit"><span class="lit">6380<span class="pun"><span class="pun">><span class="pln"><span class="pln"> <span class="kwd"><span class="kwd">set<span class="pln"><span class="pln"> foo hello

OK

<span class="lit"><span class="lit">127.0<span class="pun"><span class="pun">.<span class="lit"><span class="lit">0.1<span class="pun"><span class="pun">:<span class="lit"><span class="lit">6380<span class="pun"><span class="pun">><span class="pln"><span class="pln"> keys <span class="str"><span class="str">'*'<span class="pln"><span class="pln">

<span class="lit"><span class="lit">1<span class="pun"><span class="pun">)<span class="pln"><span class="pln"> <span class="str"><span class="str">"foo"<span class="pln"><span class="pln">

<span class="lit"><span class="lit">127.0<span class="pun"><span class="pun">.<span class="lit"><span class="lit">0.1<span class="pun"><span class="pun">:<span class="lit"><span class="lit">6380<span class="pun"><span class="pun">><span class="pln"><span class="pln"> <span class="kwd"><span class="kwd">set<span class="pln"><span class="pln"> foo1 hello

OK

<span class="lit"><span class="lit">127.0<span class="pun"><span class="pun">.<span class="lit"><span class="lit">0.1<span class="pun"><span class="pun">:<span class="lit"><span class="lit">6380<span class="pun"><span class="pun">><span class="pln"><span class="pln"> keys <span class="str"><span class="str">'*'<span class="pln"><span class="pln">

<span class="lit"><span class="lit">1<span class="pun"><span class="pun">)<span class="pln"><span class="pln"> <span class="str"><span class="str">"foo1"<span class="pln"><span class="pln">

<span class="lit"><span class="lit">2<span class="pun"><span class="pun">)<span class="pln"><span class="pln"> <span class="str"><span class="str">"foo"<span class="pln"><span class="pln">

<span class="lit"><span class="lit">127.0<span class="pun"><span class="pun">.<span class="lit"><span class="lit">0.1<span class="pun"><span class="pun">:<span class="lit"><span class="lit">6380<span class="pun"><span class="pun">><span class="pln"><span class="pln"> <span class="kwd"><span class="kwd">get<span class="pln"><span class="pln"> foo1

<span class="str"><span class="str">"hello"<span class="pln"><span class="pln">

<span class="lit"><span class="lit">127.0<span class="pun"><span class="pun">.<span class="lit"><span class="lit">0.1<span class="pun"><span class="pun">:<span class="lit"><span class="lit">6380<span class="pun"><span class="pun">>

完成了redis多端口,多实例的部署和使用了

redis 的关闭如下:


指定端口实例


相关文章

一,安装: 1.1.将redis压缩包放到 /opt 下。 2.解压 3.进入目录执行 make 4.执行 make install 5.在 /...
1.我们使用缓存时的业务流程大概为: 当我们查询一条数据时,先去查询缓存,如果缓存有就直接返回,如果...
1、redis主从 1.1、redis主从复制过程 - Slave 与 master 建立连接,发送 sync 同步命令 - Master 会启...
1、集群的概念 集群是一组相互独立的、通过高速网络互联的计算机,它们构成了一个组,并以单一系统的模...
1、什么是 NoSQL? NoSQL(NoSQL = Not Only SQL ),意为反 SQL 运动,是一项全新的数据库革命性运动,2...
Redis 是一个支持持久化的内存数据库,也就是说需要经常将内存中的数据同步到硬盘来保证持久化。 1、RD...