Redis Configuration - Server Edition


After the server restarts, the command not found is basically hit to solve the problem of
export PATH=/bin:/usr/bin:$PATH

1. Download Redis and upload it to the server folder

First download Redis version 7.0 or above from the official website , and the recommended version suffix is ​​a stable version with an even number
insert image description here

  • Then upload the downloaded file to /optthe folder of the server, here directly use the pagoda panel to upload and decompress
    insert image description here

2. Install Redis

Enter /opt/redis-7.0.9the folder and enter the command

make && make install

Just wait for the installation to succeed. The default installation path is/usr/local/bin
insert image description here

insert image description here

  • redis-benchmark: a performance testing tool, run this command after the service starts to see how your notebook performs
  • redis-check-aof: repair problematic AOF files, rdb and aof will be discussed later
  • redis-check-dump: fix buggy dump.rdb files
  • redis-cli: client, operation entry
  • redis-sentinel: Redis cluster use
  • redis-server: Redis server startup command

3. Modify the configuration file

  • First copy the default redis.conf to a path defined by yourself, such as /myredis B
mkdir /myredis
cp redis.conf /myredis/redis7.conf
  • Modify the redis.conf configuration file in the /myredis directory for initialization settings
cd /myredis/
vim redis7.conf
  • 1. The default daemonize no is changed todaemonize yes
    insert image description here

  • 2. The default protected-mode yesis changed toprotected-mode no
    insert image description here

  • 3. Change the default bind 127.0.0.1 to directly comment out (the default bind 127.0.0.1 can only be accessed by the local machine) or change the local IP address, otherwise it will affect the remote IP connection

insert image description here

  • 4. Add the redis password to requirepass to the password you set yourself
    insert image description here

4. Start the service

/usr/local/binRun under the directory , redis-serverenable the files /myredisunder the directoryredis.conf

redis-server /myredis/redis7.conf 

Note: there is no space in the middle of redis-server,2023年3月14日,在-后加了空格找半天

ps -ef|grep redis|grep -v grep

Use the above command to view the port
insert image description here

5. Connection service

redis-cli -a 1234 -p 6379

The password is the password in the modified configuration file above, the default port is 6379, and the warning warning is ignored, which
insert image description here
insert image description here
means that the Redis server can be used normally, try hellowrold
insert image description here

6. Close the service

  • SHUTDOWNJust use the command directly under the Redis server
  • Single instance shutdown:redis-cli -a 111111 shutdown
  • Multiple instances are closed, and the specified port is closed:redis-cli -p 6379 shutdown

7. Uninstall

  • 1. Stop the redis-server service
  • 2. Delete the redis-related files in the /usr/local/lib directory

Guess you like

Origin blog.csdn.net/qq_54351538/article/details/129537513