〇、解决方案
升级homebrew,命令如下:
brew update-reset
一、问题现象
通过命令brew install redis
安装Redis,异常如下:
fatal: not in a git directoryWarning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update!Warning: You are using macOS 14.We do not provide support for this pre-release version.It is expected behaviour that some formulae will fail to build in this pre-release version.It is expected behaviour that Homebrew will be buggy and slow.Do not create any issues about this on Homebrew's GitHub repositories.Do not create any issues even if you think this message is unrelated.Any opened issues will be immediately closed without response.Do not ask for help from MacHomebrew on Twitter.You may ask for help in Homebrew's discussions but are unlikely to receive a response.Try to figure out the problem yourself and submit a fix as a pull request.We will review it but may or may not accept it.==> Downloading https://www.openssl.org/source/openssl-1.1.1s.tar.gzAlready downloaded: /Users/heyday/Library/Caches/Homebrew/downloads/c475ad5547bf6708c42aaf180620e38a33a1798ae3c6a59725b6bf60f52f2249--openssl-1.1.1s.tar.gz==> Downloading https://download.redis.io/releases/redis-7.0.5.tar.gzAlready downloaded: /Users/heyday/Library/Caches/Homebrew/downloads/1901d254697ab7e72b48bc6e85b1375acbbcfb740ee1eab1358b21ffa211c8ba--redis-7.0.5.tar.gz==> Installing dependencies for redis: openssl@1.1==> Installing redis dependency: openssl@1.1Error: An exception occurred within a child process:FormulaUnreadableError: perl: unknown or unsupported macOS version: :dunno
二、尝试解决
参考博文MAC 升级后brew报错后,运行命令brew update-reset
,结果如下:
==> Fetching /opt/homebrew...remote: Enumerating objects: 27472, done.remote: Counting objects: 100% (3242/3242), done.remote: Total 27472 (delta 3242), reused 3242 (delta 3242), pack-reused 24230Receiving objects: 100% (27472/27472), 10.60 MiB | 13.25 MiB/s, done.Resolving deltas: 100% (18433/18433), completed with 1014 local objects.From https://mirrors.ustc.edu.cn/brew aea140c04..e57a87cfemaster -> origin/master * [new tag] 3.6.14 -> 3.6.14 * [new tag] 3.6.15 -> 3.6.15 * [new tag] 3.6.16 -> 3.6.16......* [new tag] 4.1.7-> 4.1.7 * [new tag] 4.1.8-> 4.1.8 * [new tag] 4.1.9-> 4.1.9==> Resetting /opt/homebrew...branch 'master' set up to track 'origin/master'.Reset branch 'master'Your branch is up to date with 'origin/master'.==> Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-cask...remote: Enumerating objects: 113910, done.remote: Counting objects: 100% (8170/8170), done.remote: Total 113910 (delta 8170), reused 8170 (delta 8170), pack-reused 105740Receiving objects: 100% (113910/113910), 57.91 MiB | 22.36 MiB/s, done.Resolving deltas: 100% (85215/85215), completed with 1709 local objects.From https://mirrors.ustc.edu.cn/homebrew-cask d0ac851913..3233b1b002master -> origin/master==> Resetting /opt/homebrew/Library/Taps/homebrew/homebrew-cask...branch 'master' set up to track 'origin/master'.Reset branch 'master'Your branch is up to date with 'origin/master'.==> Fetching /opt/homebrew/Library/Taps/homebrew/homebrew-core...remote: Enumerating objects: 330567, done.remote: Counting objects: 100% (19485/19485), done.remote: Total 330567 (delta 19485), reused 19485 (delta 19485), pack-reused 311082Receiving objects: 100% (330567/330567), 148.87 MiB | 4.08 MiB/s, done.Resolving deltas: 100% (244544/244544), completed with 3769 local objects.From https://mirrors.ustc.edu.cn/homebrew-core cd5dc44cfa5..f348ed27b41master -> origin/master==> Resetting /opt/homebrew/Library/Taps/homebrew/homebrew-core...branch 'master' set up to track 'origin/master'.Reset branch 'master'Your branch is up to date with 'origin/master'.Warning: No remote 'origin' in /opt/homebrew/Library/Taps/homebrew/homebrew-services, skipping update and reset!
查看homebrew版本(brew --version
),结果为:
Homebrew 4.1.15Homebrew/homebrew-core (git revision f348ed27b41; last commit 2023-10-10)Homebrew/homebrew-cask (git revision 3233b1b002; last commit 2023-10-09)
最终解决
上述brew update-reset
升级命令即为该问题的解决办法。homebrew升级完成后,重新运行Redis安装命令brew install redis
,结果如下:
==> Downloading https://formulae.brew.sh/api/formula.jws.json############################################################################################################################################################################## 100.0%==> Downloading https://formulae.brew.sh/api/cask.jws.json############################################################################################################################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/redis/manifests/7.2.1-1############################################################################################################################################################################## 100.0%==> Fetching dependencies for redis: ca-certificates and openssl@3==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-08-22############################################################################################################################################################################## 100.0%==> Fetching ca-certificates==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/blobs/sha256:a331e92e7a759571296581f029e5cc2ec7cee70cd92dc0b5f8eb76095f94a21a############################################################################################################################################################################## 100.0%==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.1.3############################################################################################################################################################################## 100.0%==> Fetching openssl@3==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/blobs/sha256:fd6e90e00f1c395feb60d0244eb66583caab494f8e0a0988afaa838511265d98############################################################################################################################################################################## 100.0%==> Fetching redis==> Downloading https://ghcr.io/v2/homebrew/core/redis/blobs/sha256:53943e914be8be83327314d5e23a550f4b6ee31cb4ebebe85e27aa1bce80968a############################################################################################################################################################################## 100.0%==> Installing dependencies for redis: ca-certificates and openssl@3==> Installing redis dependency: ca-certificates==> Downloading https://ghcr.io/v2/homebrew/core/ca-certificates/manifests/2023-08-22Already downloaded: /Users/heyday/Library/Caches/Homebrew/downloads/a8cd32e30cae0b7335779e93a6554f294f09485802fc253a3a8be441337a6115--ca-certificates-2023-08-22.bottle_manifest.json==> Pouring ca-certificates--2023-08-22.arm64_sonoma.bottle.tar.gz==> Downloading https://formulae.brew.sh/api/formula.jws.json-=O=-# # # #==> Regenerating CA certificate bundle from keychain, this may take a while.../opt/homebrew/Cellar/ca-certificates/2023-08-22: 3 files, 221.7KB==> Installing redis dependency: openssl@3==> Downloading https://ghcr.io/v2/homebrew/core/openssl/3/manifests/3.1.3Already downloaded: /Users/heyday/Library/Caches/Homebrew/downloads/f038f540886a6a94c000296efb3058dc47e867eef00f0c6836b8ff310bc04daa--openssl@3-3.1.3.bottle_manifest.json==> Pouring openssl@3--3.1.3.arm64_sonoma.bottle.tar.gz/opt/homebrew/Cellar/openssl@3/3.1.3: 6,495 files, 28.4MB==> Installing redis==> Pouring redis--7.2.1.arm64_sonoma.bottle.1.tar.gz==> CaveatsTo start redis now and restart at login:brew services start redisOr, if you don't want/need a background service you can just run:/opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf==> Summary/opt/homebrew/Cellar/redis/7.2.1: 14 files, 2.4MB==> Running `brew cleanup redis`...Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).Removing: /Users/heyday/Library/Caches/Homebrew/redis--7.0.5.tar.gz... (2.8MB)Removing: /Users/heyday/Library/Caches/Homebrew/redis--7.0.5... (1003.0KB)==> Caveats==> redisTo start redis now and restart at login:brew services start redisOr, if you don't want/need a background service you can just run:/opt/homebrew/opt/redis/bin/redis-server /opt/homebrew/etc/redis.conf
至此,Redis已安装成功!
三、启动服务
接下来就要启动Redis服务,并登录客户端,测试简单实用。
使用redis-server
命令启动Redis服务。启动结果如下:
18066:C 10 Oct 2023 16:14:48.320 * oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo18066:C 10 Oct 2023 16:14:48.320 * Redis version=7.2.1, bits=64, commit=00000000, modified=0, pid=18066, just started18066:C 10 Oct 2023 16:14:48.320 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf18066:M 10 Oct 2023 16:14:48.320 * Increased maximum number of open files to 10032 (it was originally set to 256).18066:M 10 Oct 2023 16:14:48.320 * monotonic clock: POSIX clock_gettime_._ _.-``__ ''-._ _.-```.`_.''-._ Redis 7.2.1 (00000000/0) 64 bit.-`` .-```.```\/_.,_ ''-._ (', .-`| `,) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 |`-._ `._/ _.-'| PID: 18066`-._`-._`-./_.-'_.-'|`-._`-._`-.__.-'_.-'_.-'| |`-._`-.__.-'_.-'| https://redis.io `-._`-._`-.__.-'_.-'_.-'|`-._`-._`-.__.-'_.-'_.-'| |`-._`-.__.-'_.-'|`-._`-._`-.__.-'_.-'_.-' `-._`-.__.-'_.-' `-.__.-' `-.__.-' 18066:M 10 Oct 2023 16:14:48.321 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.18066:M 10 Oct 2023 16:14:48.322 * Server initialized18066:M 10 Oct 2023 16:14:48.322 * Ready to accept connections tcp
四、登录客户端
通过redis-cli -p 6379(或redis-cli)
登录客户端,测试结果:
127.0.0.1:6379> hset office id 16 name finance(integer) 2127.0.0.1:6379> hget office(error) ERR wrong number of arguments for 'hget' command127.0.0.1:6379> hget office id"16"127.0.0.1:6379> hget office name"finance"127.0.0.1:6379> set a 'bbb'OK127.0.0.1:6379> get a"bbb"
通过info
命令查看Redis信息,结果为:
127.0.0.1:6379> info# Serverredis_version:7.2.1redis_git_sha1:00000000redis_git_dirty:0redis_build_id:7b8617dd94058f85redis_mode:standaloneos:Darwin 23.0.0 arm64arch_bits:64monotonic_clock:POSIX clock_gettimemultiplexing_api:selectatomicvar_api:c11-builtingcc_version:4.2.1process_id:18066process_supervised:norun_id:ebee4f34c6d4a9765df9b2af8076613a363a4b4etcp_port:6379server_time_usec:1696927718666614uptime_in_seconds:2030uptime_in_days:0hz:10configured_hz:10lru_clock:2428902executable:/opt/homebrew/opt/redis-serverconfig_file:io_threads_active:0listener0:name=tcp,bind=*,bind=-::*,port=6379# Clientsconnected_clients:1cluster_connections:0maxclients:10000client_recent_max_input_buffer:16client_recent_max_output_buffer:0blocked_clients:0tracking_clients:0clients_in_timeout_table:0total_blocking_keys:0total_blocking_keys_on_nokey:0# Memoryused_memory:914816used_memory_human:893.38Kused_memory_rss:7110656used_memory_rss_human:6.78Mused_memory_peak:1130576used_memory_peak_human:1.08Mused_memory_peak_perc:80.92%used_memory_overhead:771176used_memory_startup:769024used_memory_dataset:143640used_memory_dataset_perc:98.52%allocator_allocated:895120allocator_active:7078912allocator_resident:7078912total_system_memory:68719476736total_system_memory_human:64.00Gused_memory_lua:31744used_memory_vm_eval:31744used_memory_lua_human:31.00Kused_memory_scripts_eval:0number_of_cached_scripts:0number_of_functions:0number_of_libraries:0used_memory_vm_functions:32768used_memory_vm_total:64512used_memory_vm_total_human:63.00Kused_memory_functions:216used_memory_scripts:216used_memory_scripts_human:216Bmaxmemory:0maxmemory_human:0Bmaxmemory_policy:noevictionallocator_frag_ratio:7.91allocator_frag_bytes:6183792allocator_rss_ratio:1.00allocator_rss_bytes:0rss_overhead_ratio:1.00rss_overhead_bytes:31744mem_fragmentation_ratio:7.94mem_fragmentation_bytes:6215536mem_not_counted_for_evict:0mem_replication_backlog:0mem_total_replication_buffers:0mem_clients_slaves:0mem_clients_normal:1824mem_cluster_links:0mem_aof_buffer:0mem_allocator:libcactive_defrag_running:0lazyfree_pending_objects:0lazyfreed_objects:0# Persistenceloading:0async_loading:0current_cow_peak:0current_cow_size:0current_cow_size_age:0current_fork_perc:0.00current_save_keys_processed:0current_save_keys_total:0rdb_changes_since_last_save:3rdb_bgsave_in_progress:0rdb_last_save_time:1696925688rdb_last_bgsave_status:okrdb_last_bgsave_time_sec:-1rdb_current_bgsave_time_sec:-1rdb_saves:0rdb_last_cow_size:0rdb_last_load_keys_expired:0rdb_last_load_keys_loaded:0aof_enabled:0aof_rewrite_in_progress:0aof_rewrite_scheduled:0aof_last_rewrite_time_sec:-1aof_current_rewrite_time_sec:-1aof_last_bgrewrite_status:okaof_rewrites:0aof_rewrites_consecutive_failures:0aof_last_write_status:okaof_last_cow_size:0module_fork_in_progress:0module_fork_last_cow_size:0# Statstotal_connections_received:2total_commands_processed:11instantaneous_ops_per_sec:0total_net_input_bytes:527total_net_output_bytes:409203total_net_repl_input_bytes:0total_net_repl_output_bytes:0instantaneous_input_kbps:0.00instantaneous_output_kbps:0.00instantaneous_input_repl_kbps:0.00instantaneous_output_repl_kbps:0.00rejected_connections:0sync_full:0sync_partial_ok:0sync_partial_err:0expired_keys:0expired_stale_perc:0.00expired_time_cap_reached_count:0expire_cycle_cpu_milliseconds:62evicted_keys:0evicted_clients:0total_eviction_exceeded_time:0current_eviction_exceeded_time:0keyspace_hits:6keyspace_misses:0pubsub_channels:0pubsub_patterns:0pubsubshard_channels:0latest_fork_usec:0total_forks:0migrate_cached_sockets:0slave_expires_tracked_keys:0active_defrag_hits:0active_defrag_misses:0active_defrag_key_hits:0active_defrag_key_misses:0total_active_defrag_time:0current_active_defrag_time:0tracking_total_keys:0tracking_total_items:0tracking_total_prefixes:0unexpected_error_replies:0total_error_replies:5dump_payload_sanitizations:0total_reads_processed:17total_writes_processed:21io_threaded_reads_processed:0io_threaded_writes_processed:0reply_buffer_shrinks:2reply_buffer_expands:0eventloop_cycles:19625eventloop_duration_sum:2617787eventloop_duration_cmd_sum:2100instantaneous_eventloop_cycles_per_sec:9instantaneous_eventloop_duration_usec:292acl_access_denied_auth:0acl_access_denied_cmd:0acl_access_denied_key:0acl_access_denied_channel:0# Replicationrole:masterconnected_slaves:0master_failover_state:no-failovermaster_replid:ab7606e5334f65e93b29c63f072666c60ab8186bmaster_replid2:0000000000000000000000000000000000000000master_repl_offset:0second_repl_offset:-1repl_backlog_active:0repl_backlog_size:1048576repl_backlog_first_byte_offset:0repl_backlog_histlen:0# CPUused_cpu_sys:2.177440used_cpu_user:0.937600used_cpu_sys_children:0.000000used_cpu_user_children:0.000000# Modules# Errorstatserrorstat_ERR:count=5# Clustercluster_enabled:0# Keyspacedb0:keys=2,expires=0,avg_ttl=0
可见,版本是7.2.1,还是目前最新的稳定版。