Home Database Redis How to deploy redis on linux

How to deploy redis on linux

May 30, 2023 pm 04:08 PM
linux redis

1. Download the Linux version of redis from the official website

2. Copy to the Linux server and decompress it to the specified directory

3. After decompression, get the redis folder-----Move to The file location you know

4. Note: redis is written in c language and needs to rely on the c language environment

yum install gcc-c++ tcl
Copy after login

Enter the redis installation directory

Execute

make---------------编译redis
注意:redis6以上版本make编译可能报错,需要升级gcc版本
#第一步
sudo yum install centos-release-scl
#第二步
sudo yum install devtoolset-7-gcc*
#第三步
scl enable devtoolset-7 bash
Copy after login

Finally proceed

make install
Copy after login

5.redis default installation pathuse/local/bin

After compilation and installation, it will be in this directory

redis- server server

redis-cli client

6. We can copy the configuration file: redis.conf file in the redis installation directory to: use/local/redisconf/redis.con

Note: redisconf is a folder we created ourselves to place the configuration file. An error causes the program to fail to start (make a backup)

7. After completing the above steps, you can start redis

redis-server /usr/local/rediscong/redis.conf
redis-cli----启动客户端
Copy after login

8Some configuration analysis in the redis.conf file

bind 127.0.0.1 -::1 
指定 redis 只接收来自于该 IP 地址的请求
在配置文件redis.conf中,默认的bind 接口是127.0.0.1,也就是本地回环地址。这样的话,访问redis服务只能通过本机的客户端连接,而无法通过远程连接,
这样可以避免将redis服务暴露于危险的网络环境中,防止一些不安全的人随随便便通过远程
连接到redis服务。
如果bind选项为空的话,那会接受所有来自于可用网络接口的连接。
(绑定的是服务器上网卡的ip,不是谁要连接绑定谁的ip,绑定服务器网卡连接后,远程访问只要通过这个网卡地址来的Redis请求,都可以访问redis)

远程连接可采取指定多个IP方式,例:bind 192.168.11.129 127.0.0.1
或者:bind 0.0.0.0----服务器上所有的ipv4地址
Copy after login
daemonize---此配置有两个值 yes/no 
守护进程(daemon)是一类在后台运行的特殊进程,用于执行特定的系统任务。很多守护进程在系统引导的时候启动,并且一直运行直到系统关闭。另一些只在需要的时候才启动,完成任务后就自动结束
当daemonize yes代表开启守护线程---守护进程开启后台启动
当daemonize no 代表关闭守护线程
Copy after login
protected-mode---此配置有两个值 yes/no 
保护模式
当protected-mode yes代表开启保护模式---(当没有为redis显示指定bind且没有设置密码时,此时redis就认为是不安全的,当开启保护模式后,保护模式的作用是只允许本地回环地址127.0.0.1和::1(ipv6回环地址的表示形式)访问。)
当protected-mode no 代表关闭保护模式
Copy after login
requirepass password ---设置密码
在配置文件中设置密码需要重启redis服务
客户端启动
1:redis-cli---进入命令行
2:auth password---输入密码
在客户端修改redis密码
修改密码:config set requirepass password
查看密码:config get requirepass
Copy after login

Connection failure may occur when using RedisDesktopManager to connect to the redis service

The method to solve this problem is as follows

1. Make sure bind is set in the configuration file

2. You need to set a password when turning on protected mode

3. Modification of the configuration file requires restarting the service

redis startup and shutdown

redis的启动命令
redis-server  /usr/local/rediscong/redis.conf
如在/user/local/rediscong/目录下输入命令redis-server  /usr/local/rediscong/redis.conf ,那么redis备份文件就在/user/local/rediscong/dump.rdb
redis关闭命令
进入客户端redis-cli 
执行shutdown
Copy after login

The above is the detailed content of How to deploy redis on linux. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

How to switch Chinese mode with vscode How to switch Chinese mode with vscode Apr 15, 2025 pm 11:39 PM

VS Code To switch Chinese mode: Open the settings interface (Windows/Linux: Ctrl, macOS: Cmd,) Search for "Editor: Language" settings Select "Chinese" in the drop-down menu Save settings and restart VS Code

What is the main purpose of Linux? What is the main purpose of Linux? Apr 16, 2025 am 12:19 AM

The main uses of Linux include: 1. Server operating system, 2. Embedded system, 3. Desktop operating system, 4. Development and testing environment. Linux excels in these areas, providing stability, security and efficient development tools.

How to run java code in notepad How to run java code in notepad Apr 16, 2025 pm 07:39 PM

Although Notepad cannot run Java code directly, it can be achieved by using other tools: using the command line compiler (javac) to generate a bytecode file (filename.class). Use the Java interpreter (java) to interpret bytecode, execute the code, and output the result.

How to use VSCode How to use VSCode Apr 15, 2025 pm 11:21 PM

Visual Studio Code (VSCode) is a cross-platform, open source and free code editor developed by Microsoft. It is known for its lightweight, scalability and support for a wide range of programming languages. To install VSCode, please visit the official website to download and run the installer. When using VSCode, you can create new projects, edit code, debug code, navigate projects, expand VSCode, and manage settings. VSCode is available for Windows, macOS, and Linux, supports multiple programming languages ​​and provides various extensions through Marketplace. Its advantages include lightweight, scalability, extensive language support, rich features and version

vscode Previous Next Shortcut Key vscode Previous Next Shortcut Key Apr 15, 2025 pm 10:51 PM

VS Code One-step/Next step shortcut key usage: One-step (backward): Windows/Linux: Ctrl ←; macOS: Cmd ←Next step (forward): Windows/Linux: Ctrl →; macOS: Cmd →

How to type multiple lines of comments in vscode How to type multiple lines of comments in vscode Apr 15, 2025 pm 11:57 PM

VS Code The methods of multi-line commenting are: 1. Shortcut keys (Ctrl K C or Cmd K C); 2. Manually add comment symbols (/ /); 3. Select menu ("Comment Block"); 4. Use extensions; 5. Recursive comments (/* /) and block comments ({/ and /}). Multi-line comments help improve code readability and maintainability, but overuse should be avoided.

How to set shortcut keys for sublime How to set shortcut keys for sublime Apr 16, 2025 am 09:15 AM

To set the shortcut keys for Sublime Text, follow these steps: Open the shortcut key settings file Key Bindings - User. Add shortcut key settings using the format { "keys": ["key combination"], "command": "command" }. Save changes. Reload the shortcut key settings for the changes to take effect.

How to check the warehouse address of git How to check the warehouse address of git Apr 17, 2025 pm 01:54 PM

To view the Git repository address, perform the following steps: 1. Open the command line and navigate to the repository directory; 2. Run the "git remote -v" command; 3. View the repository name in the output and its corresponding address.

See all articles