Mac set Redis boot Start Method Step _redis

Source: Internet
Author: User
Tags redis

Overview

Redis has been installed for some time, each time the operation needs to manually start in the command line Redis, and the window can not be closed, feeling very troublesome, so I would like to set the Redis to boot. Because Google can't open (great gfw AH), so several articles Baidu, follow the tutorial step-by-step or no success, blame themselves too stupid.

These two days I built a VPN, and can use Google, so the problem solved under, now Redis finally can boot up, high.

To set the Redis boot up, I am using the Mac Launchd system, which runs the Redis as a user daemon (username Daemon) process in the background. In simple terms, the user daemon is a non-graphical program that runs in the background as part of the system. The user daemon is not associated with a user account. If you just want to set up a specific user Redis boot up, then you need to use the user agent (username agent) (this I will not, we explore it, then don't forget to tell me next).

Specific steps

Create a plist file

First we need to create a plist file in the/library/launchdaemons directory, using the following command:

Copy Code code as follows:

sudo vim/library/launchdaemons/io.redis.redis-server.plist

Paste the following content into the file created by the previous command
Copy Code code as follows:

<?xml version= "1.0" encoding= "UTF-8"?>
<! 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>io.redis.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>

After pasting, we need to make two changes to the above content: a "redis-server" path, where you need to change to your own installation path (you can use the "which redis-server" command to see the specific path). Another is the path to the Redis configuration file, which is optional, if the configuration file is not used then the second deletion, if the configuration file is used, be sure to change to the correct path.

Load the plist file into the Launchd

After editing the plist file, we need to load the file into Launchd, using the Launchctl command, as follows:

Copy Code code as follows:

sudo launchctl load/library/launchdaemons/io.redis.redis-server.plist

After the reboot, the Redis can boot up. If you do not want to reboot, you can also use the following command:
Copy Code code as follows:

sudo launchctl start io.redis.redis-server

Close Redis

If you want to turn off Redis, use the following command:

Copy Code code as follows:

sudo launchctl stop Io.redis.redis-server

Set Alias

For ease of use, we can set an alias for the open and Close command for Redis:

Copy Code code as follows:

Alias redisstart= ' sudo launchctl start io.redis.redis-server '
Alias redisstop= ' sudo launchctl stop io.redis.redis-server '

Summarize

Waste a little kungfu, finally can let Redis boot up, ^_^. If you encounter any errors, you can go to the console to see the Redis log.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.