天天看點

Redis6安裝

作者:潇灑sword

Redis6安裝

Redis是c語言開發的,安裝redis需要c語言的編譯環境。

安裝redis6最主要的一點是要用GCC5以上,而CentOS7的GCC版本為4.8.x, 是以安裝之前必須更新GCC。

1.安裝新版本的gcc軟體包及依賴包

[root@TimeSync ~]# yum -y install centos-release-scl scl-utils-build

[root@TimeSync ~]# yum -y install devtoolset-9-gcc devtoolset-9-gcc-c++ devtoolset-9-binutils

#臨時啟用,退出shell後會恢複原系統gcc版本:

[root@TimeSync ~]# scl enable devtoolset-9 bash

#永久啟用:

[root@TimeSync ~]# echo "source /opt/rh/devtoolset-9/enable" >> /etc/profile

2.設定系統參數

[root@TimeSync ~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled

[root@TimeSync ~]# echo 511 > /proc/sys/net/core/somaxconn

[root@TimeSync ~]# echo vm.overcommit_memory=1 >> /etc/sysctl.conf

[root@TimeSync ~]# echo net.core.somaxconn= 1024 >> /etc/sysctl.conf

[root@TimeSync ~]# sysctl -p

[root@TimeSync ~]# ulimit -n 65535

3.檢視安裝後的gcc版本

[root@TimeSync ~]# scl enable devtoolset-9 bash

[root@TimeSync ~]# gcc --version

gcc (GCC) 9.3.1 20200408 (Red Hat 9.3.1-2)

Copyright (C) 2019 Free Software Foundation, Inc.

This is free software; see the source for copying conditions. There is NO

warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

4.解壓redis安裝包

tar -zxvf redis-6.0.10.tar.gz -C /usr/local && mv redis-6.0.10 redis

cd redis

make && make test

make PREFIX=/usr/local/redis/ install

5.建立配置檔案目錄

mkdir -p /usr/local/redis/etc

指令安裝目錄:/usr/local/redis/bin

redis-benchmark: 性能測試工具,可以在自己本子運作,看看自己本子性能如何

redis-check-aof: 修複有問題的AOF檔案,rdb和aof後面講

redis-check-dump:修複有問題的dump.rdb檔案

redis-sentinel: Redis叢集使用

redis-server: Redis伺服器啟動指令

redis-cli: 用戶端使用操作入口

6.啟動redis

[root@TimeSync redis]# /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf

Redis6安裝

129524:C 19 Oct 2022 14:15:30.326 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo

129524:C 19 Oct 2022 14:15:30.326 # Redis version=6.0.16, bits=64, commit=00000000, modified=0, pid=129524, just started

129524:C 19 Oct 2022 14:15:30.326 # Configuration loaded

129524:M 19 Oct 2022 14:15:30.327 # Server initialized

129524:M 19 Oct 2022 14:15:30.327 * Loading RDB produced by version 6.0.16

129524:M 19 Oct 2022 14:15:30.327 * RDB age 1 seconds

129524:M 19 Oct 2022 14:15:30.327 * RDB memory usage when created 0.77 Mb

129524:M 19 Oct 2022 14:15:30.327 * DB loaded from disk: 0.000 seconds

129524:M 19 Oct 2022 14:15:30.327 * Ready to accept connections

^C129524:signal-handler (1666160151) Received SIGINT scheduling shutdown...

129524:M 19 Oct 2022 14:15:51.955 # User requested shutdown...

129524:M 19 Oct 2022 14:15:51.955 * Saving the final RDB snapshot before exiting.

129524:M 19 Oct 2022 14:15:51.998 * DB saved on disk

129524:M 19 Oct 2022 14:15:51.998 * Removing the pid file.

129524:M 19 Oct 2022 14:15:51.998 # Redis is now ready to exit, bye bye...

[root@TimeSync redis]#

7.檢視程序和端口

[root@TimeSync bin]# netstat -lantup |grep redis

tcp 0 0 127.0.0.1:6379 0.0.0.0:* LISTEN 129534/redis-server

[root@TimeSync bin]# ps -ef |grep redis |grep -v grep

root 129534 53547 0 14:18 pts/1 00:00:00 redis-server 127.0.0.1:6379

[root@TimeSync bin]#

繼續閱讀