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

前端之家收集整理的这篇文章主要介绍了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 的关闭如下:


指定端口实例


猜你在找的Redis相关文章