CentOS7.8安装Redis6.0.8集群6台云主机3主3从

CentOS-7安装redis-6.x版本最主要的一点是gcc 版本需要5.0以上, 所以安装之前必须升级gcc ,这里直接升级到9.3.x版本

使用命令gcc查看安装版本:

gcc -v


升级GCC有两个办法:手动编译 和 从源安装,这里直接使用yum源安装:

#升级到gcc 9.3:

yum -y install centos-release-scl
yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

#需要注意的是scl命令启用只是临时的,退出shell或重启就会恢复原系统gcc版本。(不建议使用)

scl enable devtoolset-9 bash

#如果要长期使用gcc 9.3的话:(这里推荐使用这种方式,后面编译好通过)

echo "source /opt/rh/devtoolset-9/enable" >>/etc/profile

source /etc/profile

#这样退出shell重新打开就是新版的gcc了

完成上面的操作后再次查看gcc版本:

[root@instance-8clll2ps ~]# gcc -v
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/opt/rh/devtoolset-9/root/usr/libexec/gcc/x86_64-redhat-linux/9/lto-wrapper
Target: x86_64-redhat-linux
Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,lto --prefix=/opt/rh/devtoolset-9/root/usr --mandir=/opt/rh/devtoolset-9/root/usr/share/man --infodir=/opt/rh/devtoolset-9/root/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --with-linker-hash-style=gnu --with-default-libstdcxx-abi=gcc4-compatible --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-9.3.1-20200408/obj-x86_64-redhat-linux/isl-install --disable-libmpx --enable-gnu-indirect-function --with-tune=generic --with-arch_32=x86-64 --build=x86_64-redhat-linux
Thread model: posix
gcc version 9.3.1 20200408 (Red Hat 9.3.1-2) (GCC) 
[root@instance-8clll2ps ~]# 

下载并编译安装Redis-6.0.8(目前最新稳定版本2020-10-15):

#下载Redis6.0.8源码包
wget http://download.redis.io/releases/redis-6.0.8.tar.gz

#解压Redis源码包
tar -zxvf redis-6.0.8.tar.gz

#进入解压后的目录
cd redis-6.0.8

#指定Redis安装目录 编译并安装
make PREFIX=/usr/local/redis install 

#编译成功后:
LINK redis-server
    INSTALL redis-sentinel
    CC redis-cli.o
    LINK redis-cli
    CC redis-benchmark.o
    LINK redis-benchmark
    INSTALL redis-check-rdb
    INSTALL redis-check-aof

Hint: It's a good idea to run 'make test' ;)

    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
    INSTALL install
make[1]: Leaving directory `/usr/local/redis-6.0.8/src'


#创建配置文件目录
mkdir /usr/local/redis/conf/

#复制配置文件到Redis安装目录中
cp redis.conf /usr/local/redis/conf/

#编辑环境变量文件
vim /etc/profile

#添加下面两行内容
export REDIS=/usr/local/redis
export PATH=:$PATH:$REDIS/bin

#退出并保存 按键盘上的 ESC 按键 输入 :wq
ESC :wq

#让环境变量文件生效
source /etc/profile

#启动Redis
redis-server /usr/local/redis/conf/redis.conf

#启动成功:
[root@iz2ze8gdumvqb40facpgopz redis]# redis-server /usr/local/redis/conf/redis.conf
10083:C 15 Oct 2020 16:04:22.078 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
10083:C 15 Oct 2020 16:04:22.078 # Redis version=6.0.8, bits=64, commit=00000000, modified=0, pid=10083, just started
10083:C 15 Oct 2020 16:04:22.078 # Configuration loaded
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.0.8 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                   
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6379
 |    `-._   `._    /     _.-'    |     PID: 10083
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           http://redis.io        
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               

10083:M 15 Oct 2020 16:04:22.079 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
10083:M 15 Oct 2020 16:04:22.079 # Server initialized
10083:M 15 Oct 2020 16:04:22.079 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
10083:M 15 Oct 2020 16:04:22.079 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo madvise > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled (set to 'madvise' or 'never').
10083:M 15 Oct 2020 16:04:22.079 * Ready to accept connections
^C10083:signal-handler (1602749066) Received SIGINT scheduling shutdown...
10083:M 15 Oct 2020 16:04:26.487 # User requested shutdown...
10083:M 15 Oct 2020 16:04:26.487 * Saving the final RDB snapshot before exiting.
10083:M 15 Oct 2020 16:04:26.488 * DB saved on disk
10083:M 15 Oct 2020 16:04:26.488 * Removing the pid file.

在每台云主机上都进行上述操作:

启动警告

WARNING overcommit_memory is set to 0!

#编辑配置文件
vim /etc/sysctl.conf

#添加这一行
vm.overcommit_memory=1

#保存并退出 按键盘上的 ESC 键 输入 :wq
ESC :wq

#使配置生效
sysctl -p

WARNING you have Transparent Huge Pages (THP) support enabled in your kernel.

echo never > /sys/kernel/mm/transparent_hugepage/enabled

#编辑启动脚本
vim /etc/rc.local

if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi

#保存并退出 按键盘上的 ESC 键 输入 :wq
ESC :wq

WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn

#编辑配置文件
vim /etc/sysctl.conf

#添加这一行
net.core.somaxconn=1024

#保存并退出 按键盘上的 ESC 键 输入 :wq
ESC :wq

#使配置生效
sysctl -p

至此任务完成了一半,接下来进行配置文件修改:

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值