mac redis boot from the start

To make Redis to start automatically when you start, I'm using launchd.
Create a simple xml file in / Library / LaunchDaemons in

sudo came /Library/LaunchDaemons/redis-server.plist

Put this in the redis-server.plist

Note: The
first implementation of which redis redis View installation location
then execute sudo find / -name redis.conf view reids.conf position
and then fill in the following code correct

<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>redis-server</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/redis-server</string>
        <string>/usr/local/etc/redis.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
</dict>
</plist>

Repeat, if you are not in / usr / local / bin install redis-server, you need to change the path in the xml file. Also, if you do not use redis.conf, or it is not installed in / usr / local / etc, remove the appropriate update. If you do not redis.conf, you can simply delete it from the xml file can be.

Redis.server.plist will now be loaded into launchd in.

sudo launchctl load /Library/LaunchDaemons/redis-server.plist

You only need to do once, by now you should control your launchd redis server.

Use this command to start the Redis.

sudo launchctl start redis-server

If you do it right, start redis-cli client and enter "ping". You should connect and receive "PONG" response. If you do not, go to the / usr / local / bin and try to run "sudo ./redis-server". It should start. If not, fix the error being generated. If it really works, now try to use redis.conf file: "sudo ./redis-server ../etc/redis.conf." Repair any errors reported If this does not start Redis, please. If it does start, run and try again redis-cli "ping" test.

Guess you like

Origin www.cnblogs.com/panxiangfu/p/12207946.html