redis 6 稳定版本已经发布,增加了新的多线程依赖,赶紧体验下,本次安装采用的redis版本是redis-6.0.1
首先下载redis-6.0.1安装包 redis-6.0.1
下载完成之后,解压安装:
tar -xzvf redis-6.0.1.tar.gz
cd redis-6.0.1
make
发现无法编译,报如下问题:
make[1]: Entering directory `/home/hanxueming/redis-6.0.1/src'
CC Makefile.dep
make[1]: Leaving directory `/home/hanxueming/redis-6.0.1/src'
make[1]: Entering directory `/home/hanxueming/redis-6.0.1/src'
CC adlist.o
cc1: error: unrecognized command line option "-std=c11"
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory `/home/hanxueming/redis-6.0.1/src'
make: *** [all] Error 2
开始按照提示错误查找解决方案:
https://blog.csdn.net/LeoHan163/article/details/106074497
按照执行完之后还是不行,后来发现,redis6 必须 gcc >= 4.9,下载gcc 4.9.4:
http://ftp.gnu.org/gnu/gcc/
这里面需要下载一些依赖,如果没有外网,我已经上传了一份,依赖已经放进去了,可以去我的资源里面找 gcc-4.9.4.包含依赖tar.gz 直接编译就行:
tar -xzvf gcc-4.9.4.tar.gz
cd gcc-4.9.4
./configure --prefix=/usr/local/gcc --enable-bootstrap --enable-checking=release --enable-languages=c,c++ --disable-multilib
make && make install
调整gcc相关指令路径:
mv /usr/bin/gcc /usr/bin/gcc-4.4.7
ln -s /usr/local/gcc/bin/gcc /usr/bin/gc
/usr/bin/gcc -v
mv /usr/bin/g++ /usr/bin/g++-4.4.7
ln -s /usr/local/gcc/bin/g++ /usr/bin/g++
mv /usr/bin/c++ /usr/bin/c++-4.4.7
ln -s /usr/local/gcc/bin/c++ /usr/bin/c++
再次编译redis,成功:

至此 redis-6.0.1安装完成。
在redis-6.0.1/目录下面,有redis.conf配置文件,其中多线程配置在:
################################ THREADED I/O #################################
# Redis is mostly single threaded, however there are certain threaded
# operations such as UNLINK, slow I/O accesses and other things that are
# performed on side threads.
#
# Now it is also possible to handle Redis clients socket reads and writes
# in different I/O threads. Since especially writing is so slow, normally
# Redis users use pipelining in order to speedup the Redis performances per
# core, and spawn multiple instances in order to scale more. Using I/O
# threads it is possible to easily speedup two times Redis without resorting
# to pipelining nor sharding of the instance.
#
# By default threading is disabled, we suggest enabling it only in machines
# that have at least 4 or more cores, leaving at least one spare core.
# Using more than 8 threads is unlikely to help much. We also recommend using
# threaded I/O only if you actually have performance problems, with Redis
# instances being able to use a quite big percentage of CPU time, otherwise
# there is no point in using this feature.
#
# So for instance if you have a four cores boxes, try to use 2 or 3 I/O
# threads, if you have a 8 cores, try to use 6 threads. In order to
# enable I/O threads use the following configuration directive:
#
# io-threads 4
io-threads 4
#
# Setting io-threads to 1 will just use the main thread as usually.
# When I/O threads are enabled, we only use threads for writes, that is
# to thread the write(2) syscall and transfer the client buffers to the
# socket. However it is also possible to enable threading of reads and
# protocol parsing using the following configuration directive, by setting
# it to yes:
#
# io-threads-do-reads no
io-threads-do-reads yes
#
# Usually threading reads doesn't help much.
#
# NOTE 1: This configuration directive cannot be changed at runtime via
# CONFIG SET. Aso this feature currently does not work when SSL is
# enabled.
#
# NOTE 2: If you want to test the Redis speedup using redis-benchmark, make
# sure you also run the benchmark itself in threaded mode, using the
# --threads option to match the number of Redis theads, otherwise you'll not
# be able to notice the improvements.
启动redis:
./src/redis-server redis.conf
本文详细记录了Redis 6.0.1版本的安装过程,解决编译错误并配置多线程依赖。由于默认GCC版本不支持新特性,需升级至GCC 4.9.4。文中分享了解决方案,包括编译、安装及配置步骤,最终实现Redis多线程读写操作。

1万+

被折叠的 条评论
为什么被折叠?



