Detailed steps to install and use Redis under mac system

This article mainly describes the two methods of installing Redis under Mac and the experience of using it: the first one is installed with brew (it may be due to network reasons that I did not download it successfully, and the installation failed); the second one is to download the installation package from the official website. Install (installed successfully)

1. Redis installation and startup

Install with brew
1. Check whether the system has installed Redis

brew info redis

This command will display the redis information under this system. If it is not installed, it will display not install

2. Enter the command to install Redis

brew install redis

It may take a while, the system will automatically install the redis package after downloading it

3. Start redis

brew services start redis

This command will start the redis service in the background, and every time you log in to the system, it will automatically restart

4. If you don't need to start the service in the background, you can use the configuration file to start it:

redis-server /usr/local/etc/redis.conf

This command will read the redis configuration file, and you will also see real-time log printing during redis running. The startup is successful, as shown below:

52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 7.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 52462
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'              

5. To connect to redis,
you need to open a new terminal, and then enter the following command:

# 不需要身份认证时
redis-cli -p 6379 -h 127.0.0.1

# 需要身份认证时,输入如下命令
redis-cli -p 6379 -h 127.0.0.1 -a yourpassword
# or
redis-cli -p 6379 -h 127.0.0.1
# 登录进去之后再进行身份认证
127.0.0.1:6379> auth 0903

Download the installation package from the official website for installation
Download the stable version installation package: Download from the redis official website , select the Stable version to install Latest Stable

After the download is complete, enter the directory of the installation package, and enter the following commands in sequence:

# 移动
sudo mv redis-stable.tar.gz /usr/local
# 切换到目录
cd /usr/local
# 解压
sudo tar zxvf redis-stable.tar.gz
# 切换到redis-stable目录
cd redis-stable
# 编译测试
sudo make test
# 编译安装
sudo make install

Execute sudo make install and see the following result: the installation is successful:

(base) cuixin@cuixindeMacBook-Pro redis-stable % sudo make install
cd src && /Applications/Xcode.app/Contents/Developer/usr/bin/make install
/bin/sh: pkg-config: command not found
    CC Makefile.dep
/bin/sh: pkg-config: command not found
    INSTALL redis-sentinel
    INSTALL redis-check-rdb

Hint: It's a good idea to run 'make test' ;)

    INSTALL redis-server
    INSTALL redis-benchmark
    INSTALL redis-cli

Start and stop of redis
Start redis:redis-server

(base) cuixin@cuixindeMacBook-Pro etc % redis-server 
52462:C 26 Oct 2022 14:35:16.933 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
52462:C 26 Oct 2022 14:35:16.933 # Redis version=7.0.5, bits=64, commit=00000000, modified=0, pid=52462, just started
52462:C 26 Oct 2022 14:35:16.933 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
52462:M 26 Oct 2022 14:35:16.934 * Increased maximum number of open files to 10032 (it was originally set to 2560).
52462:M 26 Oct 2022 14:35:16.934 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 7.0.5 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 52462
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

52462:M 26 Oct 2022 14:35:16.935 # WARNING: The TCP backlog setting of 511 cannot be enforced because kern.ipc.somaxconn is set to the lower value of 128.
52462:M 26 Oct 2022 14:35:16.935 # Server initialized
52462:M 26 Oct 2022 14:35:16.936 * Ready to accept connections

link redis:

(base) cuixin@cuixindeMacBook-Pro redis-stable % redis-cli -p 6379 -h 127.0.0.1
127.0.0.1:6379> set name 'james'
OK
127.0.0.1:6379> get name
"james"
127.0.0.1:6379> 

Reference link: mac installation redis tutorial

Guess you like

Origin blog.csdn.net/qq_34663267/article/details/127532218
Recommended