foreword
Today, a previous project needs to be adjusted, but because the project redis
can’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 k8s
built one in the cluster, but the port can be used universally, but redis
the client cannot connect. If time is urgent, install one first linux
.
install redis
Download the installation package
Download redis
the 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 install
the 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 redis
external 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 redis
remote access.
Open the server port
This step is unnecessary if the server port is already open
open 6379
ports
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, redis
the remote access configuration is also opened, and the configuration file is modified
vi /usr/local/redis/etc/redis.conf
Find bind
the configuration item
Comment this configuration item, and then find protected-mode
the configuration item
Save the configuration and restart after changing yes
it tono
redis
pkill redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
redis
After 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.conf
just modify this configuration file
Execute the modification command
vi /usr/local/redis/etc/redis.conf
find daemonize no
this config
will no
be modified to yes
then save the configuration file
Start the startup script
To start the startup is /etc/rc.local
to 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
save configuration file