当前位置:网站首页>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. .
边栏推荐
- Chapter 12 signals (II) - examples of producers and consumers
- How to do unit test well
- Fully Automated Delineation of Gross Tumor Volume for Head and Neck Cancer on PET-CT Using Deep Lear
- Kicad learning notes - shortcut keys
- Surveiller l'utilisation du pool de connexion des sources de données
- Gross Tumor Volume Segmentation for Head and Neck Cancer Radiotherapy using Deep Dense Multi-modalit
- UE4 remove the mask transparent white edge in the material
- Official STM32 chip package download address stm32f10x stm32f40x Download
- 微信小程序实现数据侦听器watch,包含销毁watch和子属性的watch
- Implementation of multi key state machine based on STM32 standard library
猜你喜欢
随机推荐
Simplicity studio does not recognize the new JLINK V9 solution
Easyexcl export 1million lines of EXECL report font error solution
After installing anaconda, you need to enter a password to start jupyterlab
Leetcode skimming -- teponacci sequence
UE4 动画重定向
Gross Tumor Volume Segmentation for Head and Neck Cancer Radiotherapy using Deep Dense Multi-modalit
c语言printf大家族系列
Print service IP setting scheme
InvalidConnectionAttributeException异常处理
1.4 机器学习方法之回归问题
证券账号开户安全吗?是靠谱的吗?
The former security director of Uber faced fraud allegations and had concealed data leakage incidents
数据治理:元数据管理(第二篇)
Pytorch learning summary - memory cost of operation
UE4 compile a single file (VS and editor start respectively)
programing language
Data warehouse: layered architecture of Finance / banking
Slider validation code
Is it safe to open an account for stock speculation? Is it reliable?
【技术开发】酒精测试仪解决方案开发设计








