Thorough Redis series (1): Redis installation under Linux

Redis series articles:

Thorough Redis series (1): Redis installation under Linux

Thorough Redis series (2): Detailed usage of Redis six data types

See Through Redis Series (3): Redis pipeline, publish/subscribe, things, expiration time detailed introduction

See through the Redis series (4): Bloom filter in detail

Thorough Redis series (5): RDB and AOF persistence detailed introduction

Thorough Redis Series (6): A detailed introduction to master-slave replication

Thorough Redis Series (7): A detailed introduction to the sentinel mechanism

See Through Redis Series (8): Detailed introduction to clusters

Thorough Redis series (9): Redis proxy twemproxy and predixy detailed introduction

Thorough Redis series (10): Detailed introduction to Redis memory model

Thorough Redis Series (11): Detailed introduction to Jedis and Lettuce clients

Understanding of package management tools under Linux

Generally speaking, well-known Linux systems are basically divided into two categories:

  1. RedHat series: Redhat, Centos, Fedora, etc.
  2. Debian series: Debian, Ubuntu, etc.

RedHat series-package management tool yum

Debian series-package management tool apt-get

Install wget

wget is a tool for downloading files, we use to download things from the Internet:

sudo apt-get install wget

Download the redis installation package

// 新建存放下载文件的目录
mkdir soft
// 切换到此目录下面
cd soft
// 用wget来下载安装包
wget http://download.redis.io/releases/redis-6.0.6.tar.gz

Unzip the installation package

tar xf redis-6.0.6.tar.gz

Execute make file

// 切换到redis包下
cd redis-6.0.6
// 执行make文件
make

If an error is reported, it proves that there is no gcc environment. You need to install gcc first, and then execute make distclean to clear the error files that were just installed, and then execute make

sudo apt-get install gcc
make distclean
make

Then after successful execution of make, we switch to src, you can see that the executable file is generated

installation

Install to the opt/redis directory

sudo make install PREFIX=/opt/redis

Configure environment variables

sudo gedit /etc/profile

Open the profile file and add the following content:

export REDIS_HOME=/opt/redis
export PATH=$PATH:$REDIS_HOME/bin

Then refresh the environment variables

source /etc/profile

Execute the install_server.sh script

cd /soft/redis-6.0.6/utils
sudo ./install_server.sh

The following errors may occur when running the script:

This systems seems to use systemd.
Please take a look at the provided example service unit files in this directory, and adapt and install them. Sorry!

Open install_server.sh and comment out the following:

#_pid_1_exe="$(readlink -f /proc/1/exe)"
#if [ "${_pid_1_exe##*/}" = systemd ]
#then
#	echo "This systems seems to use systemd."
#	echo "Please take a look at the provided example service unit files in this #directory, and adapt and install them. Sorry!"
#	exit 1
#fi
#unset _pid_1_exe

Then execute again

sudo ./install_server.sh

Output

Please select the redis port for this instance: [6379] 

There can be multiple redis instances (processes) in a physical machine, distinguished by port, and then the following will show you to configure the port, the default port is: 6379, if you use the default port, directly press Enter to execute the next step

Please select the redis config file name [/etc/redis/6379.conf] 

The configuration file for generating this Redis instance is stored in /etc/redis/6379.conf

Then we continue to press Enter

Please select the redis log file name [/var/log/redis_6379.log]

The log file that generated this Reids operation is stored in /var/log/redis_6379.log

Keep pressing Enter

Please select the data directory for this instance [/var/lib/redis/6379] 

File /var/lib/redis/6379 to store data

Continue to enter

Please select the redis executable path []

Need to enter the path of redis-server, we enter the path configured above:

Please select the redis executable path [] /opt/redis/bin/redis-server

Keep pressing Enter

Selected config:
Port           : 6381
Config file    : /etc/redis/6381.conf
Log file       : /var/log/redis_6381.log
Data dir       : /var/lib/redis/6381
Executable     : /opt/redis/bin/redis-server
Cli Executable : /opt/redis/bin/redis-cli

Prompt out the configuration we selected above, continue to press Enter

Copied /tmp/6381.conf => /etc/init.d/redis_6381
Installing service...
Success!
Starting Redis server...
Installation successful!

Prompt us that the installation was successful and helped me start the redis server

View the running status of redis server

We have successfully installed the above and started the redis server automatically, then we enter

service redis_6379 status

Command to view the running status:

Insert picture description here

Start or stop redis instance

service redis_6379 start
service redis_6379 stop

Multi-instance installation

There can be multiple redis instances in a physical machine, distinguished by port.

We only need to repeatedly execute the above install_server.shscript to install multiple redis instances.

I have installed the redis 6380 6381 instance again, and they are all started. We can check the currently running redis instance with the following command:

ps -fe | grep redis

Insert picture description here

Guess you like

Origin blog.csdn.net/u013277209/article/details/111669419