当前位置:网站首页>Install and configure redis in the Linux environment, and set the boot auto start
Install and configure redis in the Linux environment, and set the boot auto start
2022-06-29 09:51:00 【XR inadvertently】
1. Download from the official website tar package , Address :https://redis.io/download

2. Uploaded to the /usr/local Directory and extract
tar -zxvf redis-6.0.7.tar.gz3. install gcc Environmental Science
because redis By C language-written , Its operation requires C Environmental Science , So we need to install gcc. The installation command is as follows ( Select one or all ):
yum -y install gcc gcc-c++ libstdc++-devel
yum install gcc-c++4. If the following errors are reported during installation :
Compile error zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: No such file or directory
perhaps
server.c:2403:11: error :‘struct redisServer’ There is no name ‘assert_line’ Members of server.assert_line = 0;
The first error is solved as follows :
Carry out orders :
make MALLOC=libcThe second error is solved as follows :
[[email protected] redis-6.0.7]# gcc -v # see gcc edition
[[email protected] redis-6.0.7]# yum -y install centos-release-scl # Upgrade to 9.1 edition
[[email protected] redis-6.0.7]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils
[[email protected] redis-6.0.7]# scl enable devtoolset-9 bash
The above is temporarily enabled , If you want to use it for a long time gcc 9.1 Words :
[[email protected]t redis-6.0.7]# echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile5. Enter into /usr/local/redis-6.0.7/ Under the table of contents , perform make Command to compile and install

6. Get into /usr/local/redis-6.0.7/src Under the table of contents , Perform the following installation :
[[email protected] src]# make install
7. For the convenience of management , take Redis In the document conf Configuration files and common commands are moved to a unified file
(1) establish bin and etc Folder
[[email protected] redis-6.0.7]# mkdir bin
[[email protected] redis-6.0.7]# mkdir etc
(2) take redis-6.0.7 In the catalog redis.conf Move to redis-6.0.7 In the catalog etc Under the folder . take src Under the directory mkreleasehdr.sh、redis-benchmark、redis-check-aof、redis-cli、redis-server Move to /usr/local/redis-6.0.7/bin/ Under the table of contents
[[email protected] redis-6.0.7]# mv redis.conf ./etc
[[email protected] src]# mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server ../bin8. edit /usr/local/redis-6.0.7/etc/redis.conf The configuration file , Set up background startup redis service
[[email protected] redis-6.0.7]# cd etc
[[email protected] etc]# vim redis.conf Modify the following properties :
Put... In the file daemonize Attribute to yes( Indicates the need to run in the background )
daemonize yes
hold redis.conf In the configuration file bind 127.0.0.1 Comment out this line , there bind It means that only the specified network segment can remotely access this redis, When the notes are off , There is no such limitation .
#bind 127.0.0.1
hold redis.conf In the configuration file protected-mode Set to no( The default setting is yes Of , Prevents remote access , stay redis3.2.3 After version )
protected-mode no
modify Redis Default password ( The default password is empty ), Find this line in the configuration file # requirepass foobared, Delete the previous comment symbol #, And put foobared Change to your own password perhaps Another line requirepass Your own code
requirepass 123456
9. Configure power on self start
Enter folder , Write a self starting script
[[email protected] ~]# vim /etc/init.d/redisThe script is as follows :
#!/bin/sh
# chkconfig: 2345 10 90
# description: Start and Stop redis
REDISPORT=6379 # Default port
EXEC=/usr/local/redis-6.0.7/bin/redis-server #EXEC:redis Where the folder is located redis-server Location path
CLIEXEC=/usr/local/redis-6.0.7/bin/redis-cli #CLIEXEC:redis Where the folder is located redis-cli Location path
PIDFILE=/var/run/redis_${REDISPORT}.pid
CONF="/usr/local/redis-6.0.7/etc/redis.conf" #CONF:redis The configuration file used for startup
case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed"
else
echo "Starting Redis server..."
$EXEC $CONF &
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE does not exist, process is not running"
else
PID=$(cat $PIDFILE)
echo "Stopping ..."
$CLIEXEC -p $REDISPORT shutdown
while [ -x /proc/${PID} ]
do
echo "Waiting for Redis to shutdown ..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart)
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Please use start or stop or restart as first argument"
;;
esacWhen it's done , Add permissions :
[[email protected] ~]# chmod 777 /etc/init.d/redisSet power on self start :
[[email protected] ~]# chkconfig redis onstart-up redis command :
[[email protected] ~]# service redis start10. open RedisDesktopManager, Test whether the service is on as well as Can I access it remotely Redis

Many children report unknown errors during installation , Remind you to install the prerequisites first , such as gcc The environment has to be upgraded gcc Version, etc. .
边栏推荐
- JS获取手机型号和系统版本
- After installing anaconda, you need to enter a password to start jupyterlab
- How to set Google Chrome as the default browser
- Segmentation of Head and Neck Tumours Using Modified U-net
- Self cultivation (XXI) servlet life cycle, service method source code analysis, thread safety issues
- KiCad学习笔记--快捷键
- 微信小程序实现store功能
- The 23 most useful elasticsearch search techniques you must know
- Pytorch summary learning series - broadcast mechanism
- Chapter 12 signals (II) - examples of producers and consumers
猜你喜欢

UE4 material UV texture does not stretch with model scale

通用分页框架

The former security director of Uber faced fraud allegations and concealed the data leakage event

Data governance: data standard management (Part III)

Automatic Multi-Organ SegmVentation on Abdominal CT With Dense V-Networks

Yotact real-time instance segmentation

UE4 材质UV纹理不随模型缩放拉伸

SPI drive of lsm6dsl

MATLAB小技巧(21)矩阵分析--偏最小二乘回归

Gd32f4xx Ethernet chip (ENC28J60) driver migration
随机推荐
数据可视化:数据可视化的意义
Deep Learning-based Automated Delineation of Head and Neck Malignant Lesions from PET Images
云管理平台:OpenStack架构设计及详细解读
Slider validation code
数据治理:元数据管理(第二篇)
User level threads and kernel level threads
Hystrix熔断器:服务熔断与服务降级
The former security director of Uber faced fraud allegations and concealed the data leakage event
Mysql5.7 installation tutorial in centos7 under Linux
Self cultivation (XXI) servlet life cycle, service method source code analysis, thread safety issues
How to set Google Chrome as the default browser
kdevelop新建工程
Is it safe to open an account for stock speculation? Is it reliable?
Idea auto completion
云管理平台:9大开源云管理平台(CMP)
Visual assist plug-in settings for UE4 vs
General part: cognition, design and best practice of prototype design
Student增删gaih
Surveiller l'utilisation du pool de connexion des sources de données
【NOI模拟赛】为NOI加点料(重链剖分,线段树)