RedisDesktopManager连接远程Linux系统的Redis服务(图文)

Linux环境:Centos 6.8
Redis服务端版本:3.2.6
Redis客户端下载链接:https://redisdesktop.com/download

省略Linux系统安装Redis教程,网上安装教程很多;建议用tar.gz包安装
Redis官网tar.gz下载地址:wget http://download.redis.io/releases/redis-3.2.6.tar.gz

安装时可能遇到的问题

问题1:make[3]: gcc: Command not found
解决:Centos系统执行yum install gcc;Ubuntu系统执行apt-get install gcc

问题2:zmalloc.h:50:31: error: jemalloc/jemalloc.h: No such file or directory
zmalloc.h:55:2: error: #error “Newer version of jemalloc required”
make[1]: * [adlist.o] Error 1
解决:输入make MALLOC=libc,然后重新编译

安装完之后,进入Redis安装目录

[root@Karle redis-3.2.6]# ll
总用量 208
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root <span class="hljs-number">80406 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-number">00-<span class="hljs-constant">RELEASENOTES
drwxr-xr-x.  2 root root  4096 1&#x6708;   4 2017 bin
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root    <span class="hljs-number">53 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-constant">BUGS
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root  <span class="hljs-number">1805 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-constant">CONTRIBUTING
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root  <span class="hljs-number">1487 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-constant">COPYING
drwxrwxr-x.  7 root root  4096 1&#x6708;   4 2017 deps
drwxr-xr-x.  2 root root  4096 1&#x6708;   4 2017 etc
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root    <span class="hljs-number">11 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-constant">INSTALL
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root   <span class="hljs-number">151 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-constant">Makefile
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root  <span class="hljs-number">4223 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-constant">MANIFESTO
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root  <span class="hljs-number">6834 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 <span class="hljs-constant">README.md
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root <span class="hljs-number">46696 <span class="hljs-number">9&#x6708;  <span class="hljs-number">10 <span class="hljs-number">10<span class="hljs-symbol">:<span class="hljs-number">06 redis.conf &#xFF08;<span class="hljs-constant">Redis&#x914D;&#x7F6E;&#x6587;&#x4EF6;&#xFF09;
-<span class="ruby">rwxrwxr-x.  <span class="hljs-number">1 root root   <span class="hljs-number">271 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 runtest
-<span class="ruby">rwxrwxr-x.  <span class="hljs-number">1 root root   <span class="hljs-number">280 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 runtest-cluster
-<span class="ruby">rwxrwxr-x.  <span class="hljs-number">1 root root   <span class="hljs-number">281 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 runtest-sentinel
-<span class="ruby">rw-rw-r--.  <span class="hljs-number">1 root root  <span class="hljs-number">7606 <span class="hljs-number">12&#x6708;  <span class="hljs-number">6 <span class="hljs-number">2016 sentinel.conf
drwxrwxr-x.  2 root root  4096 9&#x6708;  10 10:08 src (&#x6267;&#x884C;&#x811A;&#x672C;)
drwxrwxr-x. 10 root root  4096 12&#x6708;  6 2016 tests
drwxrwxr-x.  7 root root  4096 12&#x6708;  6 2016 utils</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

进入src目录,执行脚本
[root@Karle src]# ./redis-server

[root@Karle src]# ./redis-server
2745:C 10 Sep 10:16:13.130 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
2745:M 10 Sep 10:16:13.131 * Increased maximum number of open files to 10032 (it was originally <span class="hljs-operator"><span class="hljs-keyword">set <span class="hljs-keyword">to <span class="hljs-number">1024).

                _._
           _.-<span class="hljs-string">__ <span class="hljs-string">''-._
      _.-<span class="hljs-string">    <span class="hljs-string">.  _.  <span class="hljs-string">''-._           Redis <span class="hljs-number">3.2<span class="hljs-number">.6 (<span class="hljs-number">00000000/<span class="hljs-number">0) <span class="hljs-number">64 <span class="hljs-keyword">bit
  .-<span class="hljs-string"> .-<span class="hljs-string"><span class="hljs-string">.  <span class="hljs-string">\/    _.,_ <span class="hljs-string">''-._
 (    <span class="hljs-string">'      ,       .-  | ,    )     Running in standalone mode
 |-._-...- __...-.-._|'<span class="hljs-string"> _.-'|     Port: 6379
 |    -._   <span class="hljs-string">._    /     _.-'    |     PID: 2745
  -._    <span class="hljs-string">-._  -./  _.-<span class="hljs-string">'    _.-'
 |<span class="hljs-string">-._-._    <span class="hljs-string">-.__.-'    _.-'_.-'|
 |    -._<span class="hljs-string">-._        _.-'_.-'    |           http://redis.io
  -._    <span class="hljs-string">-._-.__.-<span class="hljs-string">'_.-'    _.-<span class="hljs-string">'
 |-._-._    -.__.-'    _.-<span class="hljs-string">'_.-'|
 |    <span class="hljs-string">-._-._        _.-<span class="hljs-string">'_.-'    |
  <span class="hljs-string">-._    -._<span class="hljs-string">-.__.-'_.-'    _.-'
      -._    <span class="hljs-string">-.__.-'    _.-'
          -._        _.-<span class="hljs-string">'
              `-.__.-'

<span class="hljs-number">2745:M <span class="hljs-number">10 Sep <span class="hljs-number">10:<span class="hljs-number">16:<span class="hljs-number">13.145 # WARNING: The TCP backlog setting <span class="hljs-keyword">of <span class="hljs-number">511 cannot be enforced because /proc/sys/net/core/somaxconn <span class="hljs-keyword">is <span class="hljs-keyword">set <span class="hljs-keyword">to the lower <span class="hljs-keyword">value <span class="hljs-keyword">of <span class="hljs-number">128.

<span class="hljs-number">2745:M <span class="hljs-number">10 Sep <span class="hljs-number">10:<span class="hljs-number">16:<span class="hljs-number">13.145 # Server started, Redis version <span class="hljs-number">3.2<span class="hljs-number">.6
<span class="hljs-number">2745:M <span class="hljs-number">10 Sep <span class="hljs-number">10:<span class="hljs-number">16:<span class="hljs-number">13.147 # WARNING overcommit_memory <span class="hljs-keyword">is <span class="hljs-keyword">set <span class="hljs-keyword">to <span class="hljs-number">0! Background save may fail under low memory condition. <span class="hljs-keyword">To fix this issue <span class="hljs-keyword">add <span class="hljs-string">'vm.overcommit_memory = 1' <span class="hljs-keyword">to /etc/sysctl.conf <span class="hljs-keyword">and <span class="hljs-keyword">then reboot <span class="hljs-keyword">or run the command <span class="hljs-string">'sysctl vm.overcommit_memory=1' <span class="hljs-keyword">for this <span class="hljs-keyword">to take effect.

<span class="hljs-number">2745:M <span class="hljs-number">10 Sep <span class="hljs-number">10:<span class="hljs-number">16:<span class="hljs-number">13.147 # WARNING you have Transparent Huge Pages (THP) support enabled <span class="hljs-keyword">in your kernel. This will <span class="hljs-keyword">create latency <span class="hljs-keyword">and memory <span class="hljs-keyword">usage issues <span class="hljs-keyword">with Redis. <span class="hljs-keyword">To fix this issue run the command <span class="hljs-string">'echo never > /sys/kernel/mm/transparent_hugepage/enabled' <span class="hljs-keyword">as root, <span class="hljs-keyword">and <span class="hljs-keyword">add it <span class="hljs-keyword">to your /etc/rc.<span class="hljs-keyword">local <span class="hljs-keyword">in <span class="hljs-keyword">order <span class="hljs-keyword">to retain the setting <span class="hljs-keyword">after a reboot. Redis must be restarted <span class="hljs-keyword">after THP <span class="hljs-keyword">is disabled.

<span class="hljs-number">2745:M <span class="hljs-number">10 Sep <span class="hljs-number">10:<span class="hljs-number">16:<span class="hljs-number">13.147 * DB loaded <span class="hljs-keyword">from disk: <span class="hljs-number">0.000 seconds
<span class="hljs-number">2745:M <span class="hljs-number">10 Sep <span class="hljs-number">10:<span class="hljs-number">16:<span class="hljs-number">13.147 * The server <span class="hljs-keyword">is now ready <span class="hljs-keyword">to accept connections <span class="hljs-keyword">on port <span class="hljs-number">6379</span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span>

此时Redis服务已经可以成功启动了;但问题来了,界面一直停留在Redis服务窗口中,按Ctrl+C虽然可以屏蔽服务窗口,但同时也会结束Redis服务。

2745:M 10 Sep 10:23:04.765 # User requested shutdown…

2745:M 10 Sep 10:23:04.765 * Saving the final RDB snapshot before exiting.

2745:M 10 Sep 10:23:04.767 * DB saved on disk
2745:M 10 Sep 10:23:04.767 # Redis is now ready to exit, bye bye…

Redis服务默认是前台运行,需要修改为后台运行;返回上一层目录,修改redis.conf配置文件。找到daemonize(守护进程)配置,默认false。
修改后:

daemonize yes

此时满脸自信地回到src目录执行

[root@Karle src]# ./redis-server

擦,还是前台运行;咋回事?什么毛病?这是咱们修改了配置文件,但没告诉Redis读取最新的配置文件。启动服务的同时读取最新的配置文件

[root@Karle src]# ./redis-server ../redis.conf

下载RedisDesktopManager客户端,输入服务器IP地址,端口(缺省值:6379);点击Test Connection按钮测试连接,噢,My God,连接失败!

RedisDesktopManager连接远程Linux系统的Redis服务(图文)

什么问题呢?原因是Redis默认只支持本地链接,输入进程命令查看得知(127.0.0.1:6379)

[root@Karle src]# ps -ef | grep redis
root 5239 1 0 10:37 ? 00:00:00 ./redis-server 127.0.0.1:6379
root 5244 2321 0 10:37 pts/0 00:00:00 grep redis

问题解决:编辑redis.conf配置文件;注释掉61行本地链接限制以及80行配置修改为no

61 # bind 127.0.0.1
80 protected-mode no

读取最新配置文件并重启,查看Redis进程情况!我再擦,什么鬼,都开放IP链接权限了,怎么还是127.0.0.1:6379!!

[root@Karle src]# ./redis-server ../redis.conf
[root@Karle src]# ps -ef | grep redis
root 5352 1 0 10:59 ? 00:00:00 ./redis-server 127.0.0.1:6379
root 5367 2321 0 11:00 pts/0 00:00:00 grep redis

问题解决:先杀掉Redis进程,src目录下依次执行

[root@Karle src]# redis-cli shutdown
[root@Karle src]# ./redis-server ../redis.conf

再查看进程情况:

[root@Karle src]# ps -ef | grep redis
root 5391 1 0 11:05 ? 00:00:00 ./redis-server *:6379
root 5395 2321 0 11:05 pts/0 00:00:00 grep redis

哇塞,.6379,这意味着已经成功开放IP访问权限了。万事俱备,只欠点击RedisDesktopManager客户端测试链接按钮了。好,走起。
当你充满自信的时候,现实总是给你泼冷水,让你醒过来!链接失败,链接失败,不好意思上传截图!这里发生了什么事?你会不会让我活下去?

[En]

When you are full of confidence, reality always pours cold water on you to wake up! Link failure, link failure, I am embarrassed to upload screenshots! What’s going on here? Will you let me live or not?*

左思右想,突然,我想到一个词——防火墙

[root@Karle src]# service iptables status
&#x8868;&#x683C;&#xFF1A;filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
<span class="hljs-number">1    ACCEPT     <span class="hljs-keyword">all  </span></span>

编辑Linux防火墙
[root@Karle src]# vi /etc/sysconfig/iptables
加入防火墙规则:-A INPUT -m state –state NEW -m tcp -p tcp –dport 6379 -j ACCEPT

[root@Karle src]# service iptables status
&#x8868;&#x683C;&#xFF1A;filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
<span class="hljs-number">1    ACCEPT     <span class="hljs-keyword">all  </span></span>

重启Linux防火墙
[root@Karle src]# service iptables restart

点击Test Connection按钮测试连接,连接成功,大功告成

RedisDesktopManager连接远程Linux系统的Redis服务(图文)

end

Original: https://www.cnblogs.com/curedfisher/p/13728717.html
Author: Curedfisher
Title: RedisDesktopManager连接远程Linux系统的Redis服务(图文)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/10052/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

最近整理资源【免费获取】:   👉 程序员最新必读书单  | 👏 互联网各方向面试题下载 | ✌️计算机核心资源汇总