I love Homebrew, but sometimes it really gets me down, you know?Especially when I have to deal with launchctl.
launchctl loads and unloads services that start at login. In OS X, theseservices are represented by files ending with .plist (which stands for“property list”). These plists are usually stored in either~/Library/LaunchAgents or /Library/LaunchAgents. You load them (i.e. tellthem to start at login) with launchctl load $PATH_TO_LIST and unload them withlaunchctl unload $PATH_TO_LIST. Loading a plist tells the program itrepresents (e.g. redis) to start at login, while unloading it tells theprogram not to start at login.
- Using Homebrew will save you lot of times in setting up and configuring the development environment on macOS. If you don’t have it in your Mac, try installing using the guideline here. Optional: If you don’t update your packages for a long time. Update them using.
- Brew install redis@4.0 3️⃣、配置环境变量. 打开.bashprofile文件: open -e /.bashprofile 将Redis环境变量加入后如下: 使.bashprofile生效: source /.bashprofile 4️⃣、启动Redis(以下启动方式,teminal窗口关闭后服务不会停止) brew services start redis@4.0 5️⃣、查看本地运行的服务.
- Redis is an open source (BSD licensed), in-memory data structure store, used as a database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries, bitmaps, hyperloglogs and geospatial indexes with radius queries. Redis has built-in replication, Lua scripting, LRU eviction, transactions and different levels of on-disk.
- Alias redisstart='sudo launchctl start io.redis.redis-server' alias redisstop='sudo launchctl stop io.redis.redis-server' then you can just start and stop redis by typing redisstart and redisstop. Another way you can go about this is adding redis as a background service.
This post-install message from Homebrew may look familiar:



Doing all that takes too long, and I can never remember where Homebrew plistsare. Fortunately, Homebrew includes a lovely interface for managing this withoutusing ln, launchctl or knowing where plists are.

brew services
First, install brew services by tapping homebrew/services (one time):
Brew Run Redis
Here’s an example usage:
Behind the scenes, brew services start is doing everything in the post-installmessage above. First it runs ln -sfv ... for you. Then it runs launchctl load~/Library/LaunchAgents/homebrew.mxcl.mysql.plist. It Just Works.
Let’s say MySQL’s acting funky. We can easily restart it:
Now let’s see everything we’ve loaded:
Its simple, you can start the redis server using following cmd # run in background redis-server /usr/local/etc/redis.conf (path to redis config) & it worked for me. Error is simple ur using wrong config file, whatever the config mentioned is redis version 4.0, but you are running with 3.2.
Brew Redis Cli
Note that the list of services includes services you started with launchctlload, not just services you loaded with brew services.
Let’s say we uninstalled MySQL and Homebrew didn’t remove the plist for somereason (it usually removes it for you). There’s a command for you:
Kachow.

Brew Install Redis
Hidden Homebrew commands
Homebrew ships with a whole bunch of commands that don’t show up in brew--help. You can see a list of them in the Homebrew git repo. Each fileis named like brew-COMMAND, and you run them with brew command. I recommendbrew beer.
Brew Start Redistricting
What’s next
Mac Start Redis
If you liked this, I recommend reading through Homebrew’s Tips andTricks. You can also try out another Homebrew extension forinstalling Mac apps: homebrew-cask.
