美文网首页
macos下redis的安装与启动

macos下redis的安装与启动

作者: S_jie | 来源:发表于2023-05-29 21:18 被阅读0次

下载redis

brew install redis

xxx:~ xxx$ brew install redis
Error: 
  homebrew-core is a shallow clone.
To `brew update`, first run:
  git -C /usr/local/Homebrew/Library/Taps/homebrew/homebrew-core fetch --unshallow
This command may take a few minutes to run due to the large size of the repository.
This restriction has been made on GitHub's request because updating shallow
clones is an extremely expensive operation due to the tree layout and traffic of
Homebrew/homebrew-core and Homebrew/homebrew-cask. We don't do this for you
automatically to avoid repeatedly performing an expensive unshallow operation in
CI systems (which should instead be fixed to not use shallow clones). Sorry for
the inconvenience!
==> Downloading https://ghcr.io/v2/homebrew/core/redis/manifests/6.2.5
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/redis/blobs/sha256:fc47114ec011
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sh
######################################################################## 100.0%
==> Pouring redis--6.2.5.big_sur.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-server
/usr/local/bin/redis-check-rdb -> /usr/local/bin/redis-server
/usr/local/bin/redis-cli
/usr/local/bin/redis-sentinel -> /usr/local/bin/redis-server
/usr/local/bin/redis-server
==> Caveats
To start redis:
  brew services start redis
Or, if you don't want/need a background service you can just run:
  /usr/local/opt/redis/bin/redis-server /usr/local/etc/redis.conf
==> Summary
🍺  /usr/local/Cellar/redis/6.2.5: 14 files, 2.0MB

启动redis服务

brew services start redis

xxx:~ xxx$ brew services start redis
==> Successfully started `redis` (label: homebrew.mxcl.redis)
shujiedeMBP:~ shujie$ redis-server
75993:C 30 May 2023 21:01:49.140 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
75993:C 30 May 2023 21:01:49.140 # Redis version=7.0.10, bits=64, commit=00000000, modified=0, pid=75993, just started
75993:C 30 May 2023 21:01:49.140 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
75993:M 30 May 2023 21:01:49.142 * Increased maximum number of open files to 10032 (it was originally set to 2560).
75993:M 30 May 2023 21:01:49.142 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 7.0.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 75993
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

75993:M 30 May 2023 21:01:49.146 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
75993:M 30 May 2023 21:01:49.146 # Server initialized
75993:M 30 May 2023 21:01:49.146 * Ready to accept connections
ps axu | grep redis

^C75993:signal-handler (1685451721) Received SIGINT scheduling shutdown...
75993:M 30 May 2023 21:02:01.292 # User requested shutdown...
75993:M 30 May 2023 21:02:01.292 * Saving the final RDB snapshot before exiting.
75993:M 30 May 2023 21:02:01.316 * DB saved on disk
75993:M 30 May 2023 21:02:01.316 # Redis is now ready to exit, bye bye...

redis-server

xxx:~ xxx$ redis-server
76177:C 30 May 2023 21:10:27.502 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
76177:C 30 May 2023 21:10:27.503 # Redis version=7.0.10, bits=64, commit=00000000, modified=0, pid=76177, just started
76177:C 30 May 2023 21:10:27.503 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
76177:M 30 May 2023 21:10:27.504 * Increased maximum number of open files to 10032 (it was originally set to 2560).
76177:M 30 May 2023 21:10:27.504 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 7.0.10 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 76177
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

76177:M 30 May 2023 21:10:27.508 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
76177:M 30 May 2023 21:10:27.508 # Server initialized
76177:M 30 May 2023 21:10:27.510 * Loading RDB produced by version 7.0.10
76177:M 30 May 2023 21:10:27.510 * RDB age 506 seconds
76177:M 30 May 2023 21:10:27.510 * RDB memory usage when created 1.03 Mb
76177:M 30 May 2023 21:10:27.510 * Done loading RDB, keys loaded: 0, keys expired: 0.
76177:M 30 May 2023 21:10:27.510 * DB loaded from disk: 0.001 seconds
76177:M 30 May 2023 21:10:27.510 * Ready to accept connections

查询redis服务进程

ps axu | grep redis

xxx:~ xxx$ ps axu | grep redis
xxx           75999   0.0  0.0  4268424    740 s001  S+    9:02下午   0:00.01 grep redis
xxx           75987   0.0  0.0  4300100   3552   ??  S     9:01下午   0:00.03 /usr/local/opt/redis/bin/redis-server 127.0.0.1:6379 

链接本地redis服务

redis-cli

xxxx:~ xxx$ redis-cli
127.0.0.1:6379> 

关闭redis服务

redis-cli shutdown

xxx:~ xxx$ redis-cli shutdown

强制关闭
sudo pkill redis-server

xxx:~ xxx$ sudo pkill redis-server

相关文章

网友评论

      本文标题:macos下redis的安装与启动

      本文链接:https://www.haomeiwen.com/subject/dpqsedtx.html