Redis基礎系列-0x001:安裝與連線測試

followWinter發表於2018-05-15

0x001:mac上安裝
mac上安裝使用homebrew即可,安裝中有許多重要的資訊,所以這裡不做省略,並在以下的輸出中做一些註釋。

# 輸入
$ brew install redis

# 輸出
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/redis-4.0.9.high_sierra.bot
######################################################################## 100.0%
==> Pouring redis-4.0.9.high_sierra.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/redis-benchmark
Target /usr/local/bin/redis-benchmark
already exists. You may want to remove it:
  rm `/usr/local/bin/redis-benchmark`

To force the link and overwrite all conflicting files:
  brew link --overwrite redis

To list all files that would be deleted:
  brew link --overwrite --dry-run redis

Possible conflicting files are:
# 這裡是一些工具的位置,又需要可以直接從下面路徑找到相應工具
/usr/local/bin/redis-benchmark
/usr/local/bin/redis-check-aof
/usr/local/bin/redis-check-rdb
/usr/local/bin/redis-cli
/usr/local/bin/redis-sentinel -> /usr/local/bin/redis-server
/usr/local/bin/redis-server
==> Caveats
To have launchd start redis now and restart at login:
  brew services start redis
Or, if you don`t want/need a background service you can just run:
# 這裡是啟動服務端的方法,其中包含了預設配置檔案的位置
  redis-server /usr/local/etc/redis.conf
==> Summary
?  /usr/local/Cellar/redis/4.0.9: 13 files, 2.8MB

0x002:啟動服務端
看到以下redis圖示圖案說明啟動成功,並且可以從輸出中看出啟動的程式號和埠號

# 輸入
$ redis-server

# 輸出
...
# 省略部分輸出
...
                _._                                                  
           _.-``__ ``-._                                             
      _.-``    `.  `_.  ``-._           Redis 4.0.8 (00000000/0) 64 bit
  .-`` .-```.  ```/    _.,_ ``-._                                   
 (    `      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|`` _.-`|     Port: 6379 # 埠
 |    `-._   `._    /     _.-`    |     PID: 72438 # 程式
  `-._    `-._  `-./  _.-`    _.-`                                   
 |`-._`-._    `-.__.-`    _.-`_.-`|                                  
 |    `-._`-._        _.-`_.-`    |           http://redis.io        
  `-._    `-._`-.__.-`_.-`    _.-`                                   
 |`-._`-._    `-.__.-`    _.-`_.-`|                                  
 |    `-._`-._        _.-`_.-`    |                                  
  `-._    `-._`-.__.-`_.-`    _.-`                                   
      `-._    `-.__.-`    _.-`                                       
          `-._        _.-`                                           
              `-.__.-`                                               

...
...

0x0003 啟動客戶端

# 輸出
$ redis-cli

# 輸出,進入`redis`互動介面
127.0.0.1:6379> 

0x004 測試

# 輸入
127.0.0.1:6379> PING
# 輸出
PONG

0x005 注意

以上測試都是基於基本配置,不涉及更改配置和遠端連線的情況。

相關文章