Install redis online on Linux and enable remote access

foreword

Today, a previous project needs to be adjusted, but because the project rediscan’t be connected, the project can be started, but it can’t be logged in, it needs to be cached token, and I don’t want to touch the historical code. I have installed too many things on this machine and I can’t handle it. I originally k8sbuilt one in the cluster, but the port can be used universally, but redisthe client cannot connect. If time is urgent, install one first linux.

install redis

Download the installation package

Download redisthe installation package

wget http://download.redis.io/releases/redis-4.0.8.tar.gz

Unzip the installation package

Unzip the installation package to the current directory

tar xzvf redis-4.0.8.tar.gz

Move to the unzipped directory

cd redis-4.0.8

Install

Execute the following command to install redis

make
cd src
make install PREFIX=/usr/local/redis

Create a storage directory for configuration files

mkdir /usr/local/redis/etc

Transfer the configuration file to installthe following directory

mv ../redis.conf /usr/local/redis/etc

start redis

Execute the following command to startredis

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

Configure external access

Because redisexternal access is not enabled by default, we cannot access the service on a non-local machine after startup redis, so we need to configure enabled redisremote access.

Open the server port

This step is unnecessary if the server port is already open

open 6379ports

iptables -A INPUT -p tcp --dport 6379 -j ACCEPT

Check open ports

/etc/init.d/iptables status

Modify the configuration file

After the server port is opened, redisthe remote access configuration is also opened, and the configuration file is modified

vi /usr/local/redis/etc/redis.conf 

Find bindthe configuration item

insert image description here

Comment this configuration item, and then find protected-modethe configuration item

insert image description here

Save the configuration and restart after changing yesit tonoredis

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

redisAfter restarting, remote access is enabled


Configure boot

If you need to configure booting, you need to add the following configuration

background start

Change the startup mode of redis to start in the background, /usr/local/redis/etc/redis.confjust modify this configuration file

Execute the modification command

vi /usr/local/redis/etc/redis.conf

find daemonize nothis config

insert image description here
will nobe modified to yesthen save the configuration file

Start the startup script

To start the startup is /etc/rc.localto add the above startup command to this file

edit this file

vi /etc/rc.local

Add the above startup command at the bottom of the configuration

insert image description here

save configuration file

Guess you like

Origin blog.csdn.net/AnNanDu/article/details/127209034