【Redis】Redis 编译安装配置优化,多实例配置
1、下载redis源码包,并进行解压缩操作
https://download.redis.io/releases/
[root@Redis-Ubuntu-1804-p21:~]# wget https://download.redis.io/releases/redis-5.0.14.tar.gz
--2023-04-13 21:21:40-- https://download.redis.io/releases/redis-5.0.14.tar.gz
Resolving download.redis.io (download.redis.io)... 45.60.125.1
Connecting to download.redis.io (download.redis.io)|45.60.125.1|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2000179 (1.9M) [application/octet-stream]
Saving to: ‘redis-5.0.14.tar.gz’
redis-5.0.14.tar.gz 100%[=================================================================>] 1.91M 3.35MB/s in 0.6s
2023-04-13 21:21:43 (3.35 MB/s) - ‘redis-5.0.14.tar.gz’ saved [2000179/2000179]
[root@Redis-Ubuntu-1804-p21:~]# tar xf redis-5.0.14.tar.gz
[root@Redis-Ubuntu-1804-p21:~]# ls
disk.sh issue os.version redis-5.0.14 redis-5.0.14.tar.gz system_info.sh
2、创建redis用户,创建redis目录结构并授权
[root@Redis-Ubuntu-1804-p21:~]# useradd redis -s /sbin/nologin
[root@Redis-Ubuntu-1804-p21:~]# mkdir /app/redis/{etc,log,data,run} -p
[root@Redis-Ubuntu-1804-p21:~]# chown redis.redis /app/redis/ -R
[root@Redis-Ubuntu-1804-p21:~]# id redis
uid=2006(redis) gid=2006(redis) groups=2006(redis)
[root@Redis-Ubuntu-1804-p21:~]# ll /app/redis/
total 24
drwxr-xr-x 6 redis redis 4096 Apr 13 21:36 ./
drwxr-xr-x 3 root root 4096 Apr 13 21:36 ../
drwxr-xr-x 2 redis redis 4096 Apr 13 21:36 data/
drwxr-xr-x 2 redis redis 4096 Apr 13 21:36 etc/
drwxr-xr-x 2 redis redis 4096 Apr 13 21:36 log/
drwxr-xr-x 2 redis redis 4096 Apr 13 21:36 run/
3、准备编译环境,安装 build-essential (如已具备可忽略)
[root@Redis-Ubuntu-1804-p21:~]# apt-get install build-essential -y
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu cpp cpp-7 dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base libalgorithm-diff-perl
libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbinutils libc-dev-bin libc6 libc6-dev libcc1-0 libcilkrts5
libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-7-dev libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpx2 libquadmath0
libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev manpages-dev
Suggested packages:
binutils-doc cpp-doc gcc-7-locales debian-keyring g++-multilib g++-7-multilib gcc-7-doc libstdc++6-7-dbg gcc-multilib autoconf automake
libtool flex bison gdb gcc-doc gcc-7-multilib libgcc1-dbg libgomp1-dbg libitm1-dbg libatomic1-dbg libasan4-dbg liblsan0-dbg libtsan0-dbg
libubsan0-dbg libcilkrts5-dbg libmpx2-dbg libquadmath0-dbg glibc-doc bzr libstdc++-7-doc
The following NEW packages will be installed:
binutils binutils-common binutils-x86-64-linux-gnu build-essential cpp cpp-7 dpkg-dev fakeroot g++ g++-7 gcc gcc-7 gcc-7-base
libalgorithm-diff-perl libalgorithm-diff-xs-perl libalgorithm-merge-perl libasan4 libatomic1 libbinutils libc-dev-bin libc6-dev libcc1-0
libcilkrts5 libdpkg-perl libfakeroot libfile-fcntllock-perl libgcc-7-dev libgomp1 libisl19 libitm1 liblsan0 libmpc3 libmpx2 libquadmath0
libstdc++-7-dev libtsan0 libubsan0 linux-libc-dev manpages-dev
The following packages will be upgraded:
libc6
1 upgraded, 39 newly installed, 0 to remove and 114 not upgraded.
Need to get 45.7 MB of archives.
After this operation, 165 MB of additional disk space will be used.
Get:1 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc6 amd64 2.27-3ubuntu1.6 [2831 kB]
Get:2 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 binutils-common amd64 2.30-21ubuntu1~18.04.8 [197 kB]
Get:3 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libbinutils amd64 2.30-21ubuntu1~18.04.8 [488 kB]
Get:4 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 binutils-x86-64-linux-gnu amd64 2.30-21ubuntu1~18.04.8 [1839 kB]
Get:5 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 binutils amd64 2.30-21ubuntu1~18.04.8 [3388 B]
Get:6 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc-dev-bin amd64 2.27-3ubuntu1.6 [71.9 kB]
Get:7 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 linux-libc-dev amd64 4.15.0-208.220 [997 kB]
Get:8 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libc6-dev amd64 2.27-3ubuntu1.6 [2587 kB]
Get:9 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc-7-base amd64 7.5.0-3ubuntu1~18.04 [18.3 kB]
Get:10 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libisl19 amd64 0.19-1 [551 kB]
Get:11 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libmpc3 amd64 1.1.0-1 [40.8 kB]
Get:12 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 cpp-7 amd64 7.5.0-3ubuntu1~18.04 [8591 kB]
Get:13 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 cpp amd64 4:7.4.0-1ubuntu2.3 [27.7 kB]
Get:14 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcc1-0 amd64 8.4.0-1ubuntu1~18.04 [39.4 kB]
Get:15 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgomp1 amd64 8.4.0-1ubuntu1~18.04 [76.5 kB]
Get:16 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libitm1 amd64 8.4.0-1ubuntu1~18.04 [27.9 kB]
Get:17 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libatomic1 amd64 8.4.0-1ubuntu1~18.04 [9192 B]
Get:18 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libasan4 amd64 7.5.0-3ubuntu1~18.04 [358 kB]
Get:19 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 liblsan0 amd64 8.4.0-1ubuntu1~18.04 [133 kB]
Get:20 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libtsan0 amd64 8.4.0-1ubuntu1~18.04 [288 kB]
Get:21 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libubsan0 amd64 7.5.0-3ubuntu1~18.04 [126 kB]
Get:22 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libcilkrts5 amd64 7.5.0-3ubuntu1~18.04 [42.5 kB]
Get:23 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libmpx2 amd64 8.4.0-1ubuntu1~18.04 [11.6 kB]
Get:24 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libquadmath0 amd64 8.4.0-1ubuntu1~18.04 [134 kB]
Get:25 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libgcc-7-dev amd64 7.5.0-3ubuntu1~18.04 [2378 kB]
Get:26 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc-7 amd64 7.5.0-3ubuntu1~18.04 [9381 kB]
Get:27 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 gcc amd64 4:7.4.0-1ubuntu2.3 [5184 B]
Get:28 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libstdc++-7-dev amd64 7.5.0-3ubuntu1~18.04 [1471 kB]
Get:29 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++-7 amd64 7.5.0-3ubuntu1~18.04 [9697 kB]
Get:30 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 g++ amd64 4:7.4.0-1ubuntu2.3 [1568 B]
Get:31 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 libdpkg-perl all 1.19.0.5ubuntu2.4 [212 kB]
Get:32 http://cn.archive.ubuntu.com/ubuntu bionic-updates/main amd64 dpkg-dev all 1.19.0.5ubuntu2.4 [607 kB]
Get:33 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 build-essential amd64 12.4ubuntu1 [4758 B]
Get:34 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libfakeroot amd64 1.22-2ubuntu1 [25.9 kB]
Get:35 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 fakeroot amd64 1.22-2ubuntu1 [62.3 kB]
Get:36 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-diff-perl all 1.19.03-1 [47.6 kB]
Get:37 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-diff-xs-perl amd64 0.04-5 [11.1 kB]
Get:38 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libalgorithm-merge-perl all 0.08-3 [12.0 kB]
Get:39 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 libfile-fcntllock-perl amd64 0.22-3build2 [33.2 kB]
Get:40 http://cn.archive.ubuntu.com/ubuntu bionic/main amd64 manpages-dev all 4.15-1 [2217 kB]
Fetched 45.7 MB in 35s (1308 kB/s)
Extracting templates from packages: 100%
Preconfiguring packages ...
(Reading database ... 103420 files and directories currently installed.)
Preparing to unpack .../libc6_2.27-3ubuntu1.6_amd64.deb ...
Unpacking libc6:amd64 (2.27-3ubuntu1.6) over (2.27-3ubuntu1.5) ...
Setting up libc6:amd64 (2.27-3ubuntu1.6) ...
Selecting previously unselected package binutils-common:amd64.
(Reading database ... 103420 files and directories currently installed.)
Preparing to unpack .../00-binutils-common_2.30-21ubuntu1~18.04.8_amd64.deb ...
Unpacking binutils-common:amd64 (2.30-21ubuntu1~18.04.8) ...
Selecting previously unselected package libbinutils:amd64.
Preparing to unpack .../01-libbinutils_2.30-21ubuntu1~18.04.8_amd64.deb ...
Unpacking libbinutils:amd64 (2.30-21ubuntu1~18.04.8) ...
Selecting previously unselected package binutils-x86-64-linux-gnu.
Preparing to unpack .../02-binutils-x86-64-linux-gnu_2.30-21ubuntu1~18.04.8_amd64.deb ...
Unpacking binutils-x86-64-linux-gnu (2.30-21ubuntu1~18.04.8) ...
Selecting previously unselected package binutils.
Preparing to unpack .../03-binutils_2.30-21ubuntu1~18.04.8_amd64.deb ...
Unpacking binutils (2.30-21ubuntu1~18.04.8) ...
Selecting previously unselected package libc-dev-bin.
Preparing to unpack .../04-libc-dev-bin_2.27-3ubuntu1.6_amd64.deb ...
Unpacking libc-dev-bin (2.27-3ubuntu1.6) ...
Selecting previously unselected package linux-libc-dev:amd64.
Preparing to unpack .../05-linux-libc-dev_4.15.0-208.220_amd64.deb ...
Unpacking linux-libc-dev:amd64 (4.15.0-208.220) ...
Selecting previously unselected package libc6-dev:amd64.
Preparing to unpack .../06-libc6-dev_2.27-3ubuntu1.6_amd64.deb ...
Unpacking libc6-dev:amd64 (2.27-3ubuntu1.6) ...
Selecting previously unselected package gcc-7-base:amd64.
Preparing to unpack .../07-gcc-7-base_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking gcc-7-base:amd64 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package libisl19:amd64.
Preparing to unpack .../08-libisl19_0.19-1_amd64.deb ...
Unpacking libisl19:amd64 (0.19-1) ...
Selecting previously unselected package libmpc3:amd64.
Preparing to unpack .../09-libmpc3_1.1.0-1_amd64.deb ...
Unpacking libmpc3:amd64 (1.1.0-1) ...
Selecting previously unselected package cpp-7.
Preparing to unpack .../10-cpp-7_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking cpp-7 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package cpp.
Preparing to unpack .../11-cpp_4%3a7.4.0-1ubuntu2.3_amd64.deb ...
Unpacking cpp (4:7.4.0-1ubuntu2.3) ...
Selecting previously unselected package libcc1-0:amd64.
Preparing to unpack .../12-libcc1-0_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libcc1-0:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libgomp1:amd64.
Preparing to unpack .../13-libgomp1_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libgomp1:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libitm1:amd64.
Preparing to unpack .../14-libitm1_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libitm1:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libatomic1:amd64.
Preparing to unpack .../15-libatomic1_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libatomic1:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libasan4:amd64.
Preparing to unpack .../16-libasan4_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking libasan4:amd64 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package liblsan0:amd64.
Preparing to unpack .../17-liblsan0_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking liblsan0:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libtsan0:amd64.
Preparing to unpack .../18-libtsan0_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libtsan0:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libubsan0:amd64.
Preparing to unpack .../19-libubsan0_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking libubsan0:amd64 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package libcilkrts5:amd64.
Preparing to unpack .../20-libcilkrts5_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking libcilkrts5:amd64 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package libmpx2:amd64.
Preparing to unpack .../21-libmpx2_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libmpx2:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libquadmath0:amd64.
Preparing to unpack .../22-libquadmath0_8.4.0-1ubuntu1~18.04_amd64.deb ...
Unpacking libquadmath0:amd64 (8.4.0-1ubuntu1~18.04) ...
Selecting previously unselected package libgcc-7-dev:amd64.
Preparing to unpack .../23-libgcc-7-dev_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking libgcc-7-dev:amd64 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package gcc-7.
Preparing to unpack .../24-gcc-7_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking gcc-7 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package gcc.
Preparing to unpack .../25-gcc_4%3a7.4.0-1ubuntu2.3_amd64.deb ...
Unpacking gcc (4:7.4.0-1ubuntu2.3) ...
Selecting previously unselected package libstdc++-7-dev:amd64.
Preparing to unpack .../26-libstdc++-7-dev_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking libstdc++-7-dev:amd64 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package g++-7.
Preparing to unpack .../27-g++-7_7.5.0-3ubuntu1~18.04_amd64.deb ...
Unpacking g++-7 (7.5.0-3ubuntu1~18.04) ...
Selecting previously unselected package g++.
Preparing to unpack .../28-g++_4%3a7.4.0-1ubuntu2.3_amd64.deb ...
Unpacking g++ (4:7.4.0-1ubuntu2.3) ...
Selecting previously unselected package libdpkg-perl.
Preparing to unpack .../29-libdpkg-perl_1.19.0.5ubuntu2.4_all.deb ...
Unpacking libdpkg-perl (1.19.0.5ubuntu2.4) ...
Selecting previously unselected package dpkg-dev.
Preparing to unpack .../30-dpkg-dev_1.19.0.5ubuntu2.4_all.deb ...
Unpacking dpkg-dev (1.19.0.5ubuntu2.4) ...
Selecting previously unselected package build-essential.
Preparing to unpack .../31-build-essential_12.4ubuntu1_amd64.deb ...
Unpacking build-essential (12.4ubuntu1) ...
Selecting previously unselected package libfakeroot:amd64.
Preparing to unpack .../32-libfakeroot_1.22-2ubuntu1_amd64.deb ...
Unpacking libfakeroot:amd64 (1.22-2ubuntu1) ...
Selecting previously unselected package fakeroot.
Preparing to unpack .../33-fakeroot_1.22-2ubuntu1_amd64.deb ...
Unpacking fakeroot (1.22-2ubuntu1) ...
Selecting previously unselected package libalgorithm-diff-perl.
Preparing to unpack .../34-libalgorithm-diff-perl_1.19.03-1_all.deb ...
Unpacking libalgorithm-diff-perl (1.19.03-1) ...
Selecting previously unselected package libalgorithm-diff-xs-perl.
Preparing to unpack .../35-libalgorithm-diff-xs-perl_0.04-5_amd64.deb ...
Unpacking libalgorithm-diff-xs-perl (0.04-5) ...
Selecting previously unselected package libalgorithm-merge-perl.
Preparing to unpack .../36-libalgorithm-merge-perl_0.08-3_all.deb ...
Unpacking libalgorithm-merge-perl (0.08-3) ...
Selecting previously unselected package libfile-fcntllock-perl.
Preparing to unpack .../37-libfile-fcntllock-perl_0.22-3build2_amd64.deb ...
Unpacking libfile-fcntllock-perl (0.22-3build2) ...
Selecting previously unselected package manpages-dev.
Preparing to unpack .../38-manpages-dev_4.15-1_all.deb ...
Unpacking manpages-dev (4.15-1) ...
Setting up libquadmath0:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up libgomp1:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up libatomic1:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up libcc1-0:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up libtsan0:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up linux-libc-dev:amd64 (4.15.0-208.220) ...
Setting up libdpkg-perl (1.19.0.5ubuntu2.4) ...
Setting up liblsan0:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up gcc-7-base:amd64 (7.5.0-3ubuntu1~18.04) ...
Setting up binutils-common:amd64 (2.30-21ubuntu1~18.04.8) ...
Setting up libfile-fcntllock-perl (0.22-3build2) ...
Setting up libmpx2:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up libfakeroot:amd64 (1.22-2ubuntu1) ...
Setting up libalgorithm-diff-perl (1.19.03-1) ...
Setting up libmpc3:amd64 (1.1.0-1) ...
Setting up libc-dev-bin (2.27-3ubuntu1.6) ...
Setting up manpages-dev (4.15-1) ...
Setting up libc6-dev:amd64 (2.27-3ubuntu1.6) ...
Setting up libitm1:amd64 (8.4.0-1ubuntu1~18.04) ...
Setting up libisl19:amd64 (0.19-1) ...
Setting up libasan4:amd64 (7.5.0-3ubuntu1~18.04) ...
Setting up libbinutils:amd64 (2.30-21ubuntu1~18.04.8) ...
Setting up libcilkrts5:amd64 (7.5.0-3ubuntu1~18.04) ...
Setting up libubsan0:amd64 (7.5.0-3ubuntu1~18.04) ...
Setting up fakeroot (1.22-2ubuntu1) ...
update-alternatives: using /usr/bin/fakeroot-sysv to provide /usr/bin/fakeroot (fakeroot) in auto mode
Setting up libgcc-7-dev:amd64 (7.5.0-3ubuntu1~18.04) ...
Setting up cpp-7 (7.5.0-3ubuntu1~18.04) ...
Setting up libstdc++-7-dev:amd64 (7.5.0-3ubuntu1~18.04) ...
Setting up libalgorithm-merge-perl (0.08-3) ...
Setting up libalgorithm-diff-xs-perl (0.04-5) ...
Setting up binutils-x86-64-linux-gnu (2.30-21ubuntu1~18.04.8) ...
Setting up cpp (4:7.4.0-1ubuntu2.3) ...
Setting up binutils (2.30-21ubuntu1~18.04.8) ...
Setting up gcc-7 (7.5.0-3ubuntu1~18.04) ...
Setting up g++-7 (7.5.0-3ubuntu1~18.04) ...
Setting up gcc (4:7.4.0-1ubuntu2.3) ...
Setting up dpkg-dev (1.19.0.5ubuntu2.4) ...
Setting up g++ (4:7.4.0-1ubuntu2.3) ...
update-alternatives: using /usr/bin/g++ to provide /usr/bin/c++ (c++) in auto mode
Setting up build-essential (12.4ubuntu1) ...
Processing triggers for man-db (2.8.3-2ubuntu0.1) ...
Processing triggers for libc-bin (2.27-3ubuntu1.5) ...
[root@Redis-Ubuntu-1804-p21:~]#
4、切换解压的到redis目录下,进行编译安装到目录 /app/redis
[root@Redis-Ubuntu-1804-p21:~]# cd redis-5.0.14/ [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# make PREFIX=/app/redis/ install cd src && make install make[1]: Entering directory '/root/redis-5.0.14/src' rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark (cd ../deps && make distclean) make[2]: Entering directory '/root/redis-5.0.14/deps' (cd hiredis && make clean) > /dev/null || true (cd linenoise && make clean) > /dev/null || true (cd lua && make clean) > /dev/null || true (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true (rm -f .make-*) make[2]: Leaving directory '/root/redis-5.0.14/deps' (rm -f .make-*) echo STD=-std=c99 -pedantic -DREDIS_STATIC= >> .make-settings echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings echo OPT=-O2 >> .make-settings echo MALLOC=libc >> .make-settings echo CFLAGS= >> .make-settings echo LDFLAGS= >> .make-settings echo REDIS_CFLAGS= >> .make-settings echo REDIS_LDFLAGS= >> .make-settings echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC= -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src >> .make-settings echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings (cd ../deps && make hiredis linenoise lua) make[2]: Entering directory '/root/redis-5.0.14/deps' (cd hiredis && make clean) > /dev/null || true (cd linenoise && make clean) > /dev/null || true (cd lua && make clean) > /dev/null || true (cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true (rm -f .make-*) (echo "" > .make-cflags) (echo "" > .make-ldflags) MAKE hiredis cd hiredis && make static make[3]: Entering directory '/root/redis-5.0.14/deps/hiredis' cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb hiredis.c hiredis.c: In function ‘createArrayObject’: hiredis.c:142:44: warning: comparison between signed and unsigned integer expressions [-Wsign-compare] if (SIZE_MAX / sizeof(redisReply*) < elements) return NULL; /* Don't overflow */ ^ cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb sds.c cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb async.c cc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb read.c ar rcs libhiredis.a net.o hiredis.o sds.o async.o read.o make[3]: Leaving directory '/root/redis-5.0.14/deps/hiredis' MAKE linenoise cd linenoise && make make[3]: Entering directory '/root/redis-5.0.14/deps/linenoise' cc -Wall -Os -g -c linenoise.c make[3]: Leaving directory '/root/redis-5.0.14/deps/linenoise' MAKE lua cd lua/src && make all CFLAGS="-O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' " MYLDFLAGS="" AR="ar rcu" make[3]: Entering directory '/root/redis-5.0.14/deps/lua/src' cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lapi.o lapi.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lcode.o lcode.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o ldebug.o ldebug.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o ldo.o ldo.c ldo.c: In function ‘f_parser’: ldo.c:496:7: warning: unused variable ‘c’ [-Wunused-variable] int c = luaZ_lookahead(p->z); ^ cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o ldump.o ldump.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lfunc.o lfunc.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lgc.o lgc.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o llex.o llex.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lmem.o lmem.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lobject.o lobject.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lopcodes.o lopcodes.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lparser.o lparser.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lstate.o lstate.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lstring.o lstring.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o ltable.o ltable.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o ltm.o ltm.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lundump.o lundump.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lvm.o lvm.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lzio.o lzio.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o strbuf.o strbuf.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o fpconv.o fpconv.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lauxlib.o lauxlib.c lauxlib.c: In function ‘luaL_loadfile’: lauxlib.c:577:4: warning: this ‘while’ clause does not guard... [-Wmisleading-indentation] while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) ; ^~~~~ lauxlib.c:578:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘while’ lf.extraline = 0; ^~ cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lbaselib.o lbaselib.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o ldblib.o ldblib.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o liolib.o liolib.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lmathlib.o lmathlib.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o loslib.o loslib.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o ltablib.o ltablib.c ltablib.c: In function ‘addfield’: ltablib.c:137:3: warning: this ‘if’ clause does not guard... [-Wmisleading-indentation] if (!lua_isstring(L, -1)) ^~ ltablib.c:140:5: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘if’ luaL_addvalue(b); ^~~~~~~~~~~~~ cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lstrlib.o lstrlib.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o loadlib.o loadlib.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o linit.o linit.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lua_cjson.o lua_cjson.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lua_struct.o lua_struct.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lua_cmsgpack.o lua_cmsgpack.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lua_bit.o lua_bit.c ar rcu liblua.a lapi.o lcode.o ldebug.o ldo.o ldump.o lfunc.o lgc.o llex.o lmem.o lobject.o lopcodes.o lparser.o lstate.o lstring.o ltable.o ltm.o lundump.o lvm.o lzio.o strbuf.o fpconv.o lauxlib.o lbaselib.o ldblib.o liolib.o lmathlib.o loslib.o ltablib.o lstrlib.o loadlib.o linit.o lua_cjson.o lua_struct.o lua_cmsgpack.o lua_bit.o # DLL needs all object files ar: `u' modifier ignored since `D' is the default (see `U') ranlib liblua.a cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o lua.o lua.c cc -o lua lua.o liblua.a -lm liblua.a(loslib.o): In function `os_tmpname': loslib.c:(.text+0x290): warning: the use of `tmpnam' is dangerous, better use `mkstemp' cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o luac.o luac.c cc -O2 -Wall -DLUA_ANSI -DENABLE_CJSON_GLOBAL -DREDIS_STATIC='' -c -o print.o print.c cc -o luac luac.o print.o liblua.a -lm make[3]: Leaving directory '/root/redis-5.0.14/deps/lua/src' make[2]: Leaving directory '/root/redis-5.0.14/deps' CC adlist.o CC quicklist.o CC ae.o CC anet.o CC dict.o CC server.o CC sds.o CC zmalloc.o CC lzf_c.o CC lzf_d.o CC pqsort.o CC zipmap.o CC sha1.o CC ziplist.o CC release.o CC networking.o CC util.o CC object.o CC db.o CC replication.o CC rdb.o CC t_string.o CC t_list.o CC t_set.o CC t_zset.o CC t_hash.o CC config.o CC aof.o CC pubsub.o CC multi.o CC debug.o CC sort.o CC intset.o CC syncio.o CC cluster.o CC crc16.o CC endianconv.o CC slowlog.o CC scripting.o CC bio.o CC rio.o CC rand.o CC memtest.o CC crc64.o CC bitops.o CC sentinel.o CC notify.o CC setproctitle.o CC blocked.o CC hyperloglog.o CC latency.o CC sparkline.o CC redis-check-rdb.o CC redis-check-aof.o CC geo.o CC lazyfree.o CC module.o CC evict.o CC expire.o CC geohash.o CC geohash_helper.o CC childinfo.o CC defrag.o CC siphash.o CC rax.o CC t_stream.o CC listpack.o CC localtime.o CC lolwut.o CC lolwut5.o 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 '/root/redis-5.0.14/src' [root@Redis-Ubuntu-1804-p21:redis-5.0.14]#
[root@Redis-Ubuntu-1804-p21:redis-5.0.14]# [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# tree /app/redis /app/redis ├── bin │ ├── redis-benchmark │ ├── redis-check-aof │ ├── redis-check-rdb │ ├── redis-cli │ ├── redis-sentinel -> redis-server │ └── redis-server ├── data ├── etc ├── log └── run
安装过程如出现下方报错提示,返回第3步重新安装编译环境,或安装 gcc
[root@Redis-Ubuntu-1804-p21:redis-5.0.14]# make PREFIX=/app/redis/ install
cd src && make install
make[1]: Entering directory '/root/redis-5.0.14/src'
CC Makefile.dep
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-rdb redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html Makefile.dep dict-benchmark
(cd ../deps && make distclean)
make[2]: Entering directory '/root/redis-5.0.14/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory '/root/redis-5.0.14/deps'
(rm -f .make-*)
echo STD=-std=c99 -pedantic -DREDIS_STATIC='' >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
echo CFLAGS= >> .make-settings
echo LDFLAGS= >> .make-settings
echo REDIS_CFLAGS= >> .make-settings
echo REDIS_LDFLAGS= >> .make-settings
echo PREV_FINAL_CFLAGS=-std=c99 -pedantic -DREDIS_STATIC='' -Wall -W -Wno-missing-field-initializers -O2 -g -ggdb -I../deps/hiredis -I../deps/linenoise -I../deps/lua/src -DUSE_JEMALLOC -I../deps/jemalloc/include >> .make-settings
echo PREV_FINAL_LDFLAGS= -g -ggdb -rdynamic >> .make-settings
(cd ../deps && make hiredis linenoise lua jemalloc)
make[2]: Entering directory '/root/redis-5.0.14/deps'
(cd hiredis && make clean) > /dev/null || true
(cd linenoise && make clean) > /dev/null || true
(cd lua && make clean) > /dev/null || true
(cd jemalloc && [ -f Makefile ] && make distclean) > /dev/null || true
(rm -f .make-*)
(echo "" > .make-cflags)
(echo "" > .make-ldflags)
MAKE hiredis
cd hiredis && make static
make[3]: Entering directory '/root/redis-5.0.14/deps/hiredis'
gcc -std=c99 -pedantic -c -O3 -fPIC -Wall -W -Wstrict-prototypes -Wwrite-strings -g -ggdb net.c
make[3]: gcc: Command not found
Makefile:156: recipe for target 'net.o' failed
make[3]: *** [net.o] Error 127
make[3]: Leaving directory '/root/redis-5.0.14/deps/hiredis'
Makefile:45: recipe for target 'hiredis' failed
make[2]: *** [hiredis] Error 2
make[2]: Leaving directory '/root/redis-5.0.14/deps'
Makefile:199: recipe for target 'persist-settings' failed
make[1]: [persist-settings] Error 2 (ignored)
CC adlist.o
/bin/sh: 1: cc: not found
Makefile:257: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 127
make[1]: Leaving directory '/root/redis-5.0.14/src'
Makefile:9: recipe for target 'install' failed
make: *** [install] Error 2
[root@Redis-Ubuntu-1804-p21:redis-5.0.14]#
重新编译安装出现 zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory 报错,执行 make MALLOC=libc PREFIX=/app/redis/ install
[root@Redis-Ubuntu-1804-p21:redis-5.0.14]# make PREFIX=/app/redis/ install
cd src && make install
make[1]: Entering directory '/root/redis-5.0.14/src'
CC adlist.o
In file included from adlist.c:34:0:
zmalloc.h:50:10: fatal error: jemalloc/jemalloc.h: No such file or directory
#include <jemalloc/jemalloc.h>
^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Makefile:257: recipe for target 'adlist.o' failed
make[1]: *** [adlist.o] Error 1
make[1]: Leaving directory '/root/redis-5.0.14/src'
Makefile:9: recipe for target 'install' failed
make: *** [install] Error 2
[root@Redis-Ubuntu-1804-p21:redis-5.0.14]# make MALLOC=libc PREFIX=/app/redis/ install
5、创建命令软连接
[root@Redis-Ubuntu-1804-p21:redis-5.0.14]# tree /app/redis /app/redis ├── bin │ ├── redis-benchmark │ ├── redis-check-aof │ ├── redis-check-rdb │ ├── redis-cli │ ├── redis-sentinel -> redis-server │ └── redis-server ├── data ├── etc ├── log └── run 5 directories, 6 files [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# ln -s /app/redis/bin/* /usr/bin/ [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# which red red redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server
6、复制并准备Redis配置文件
##方法1:手动修改 [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# cp redis.conf /app/redis/etc/redis_bak.conf [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# cd /app/redis/etc/ [root@Redis-Ubuntu-1804-p21:etc]# ll total 72 drwxr-xr-x 2 redis redis 4096 Apr 13 22:36 ./ drwxr-xr-x 7 redis redis 4096 Apr 13 22:21 ../ -rw-r--r-- 1 root root 63088 Apr 13 22:36 redis_bak.conf [root@Redis-Ubuntu-1804-p21:etc]# vim redis_bak.conf bind 0.0.0.0 port 6379 pidfile /app/redis/run/redis_6379.pid logfile "redis_6379.log" always-show-logo no dbfilename dump_6379.rdb dir /app/redis/data appendfilename "appendonly_6379.aof" [root@Redis-Ubuntu-1804-p21:etc]# cat redis_bak.conf | grep ^[A-z] > redis_6379.confcat redis_bak.conf | grep ^[A-z] > redis_6379.conf [root@Redis-Ubuntu-1804-p21:etc]# sed 's/6379/6380/g' redis_6379.conf > redis_6380.conf [root@Redis-Ubuntu-1804-p21:etc]# sed 's/6379/6381/g' redis_6379.conf > redis_6381.conf [root@Redis-Ubuntu-1804-p21:etc]# chown redis.redis /app/redis/ -R [root@Redis-Ubuntu-1804-p21:etc]# ll total 84 drwxr-xr-x 2 redis redis 4096 Apr 13 22:52 ./ drwxr-xr-x 7 redis redis 4096 Apr 13 22:21 ../ -rw-r--r-- 1 redis redis 1452 Apr 13 22:51 redis_6379.conf -rw-r--r-- 1 redis redis 1452 Apr 13 22:52 redis_6380.conf -rw-r--r-- 1 redis redis 1452 Apr 13 22:52 redis_6381.conf -rw-r--r-- 1 redis redis 63115 Apr 13 22:47 redis_bak.conf [root@Redis-Ubuntu-1804-p21:etc]#
##方法2 sed修改并写入新配置文件 [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# sed -e 's/^bind 127.0.0.1/bind 0.0.0.0/g' -e 's/^pidfile \/var\/run\/redis_6379.pid/pidfile \/app\/redis\/run\/redis_6379.pid/g' -e 's/^logfile ""/logfile "\/app\/redis\/log\/redis_6379.log"/g' -e 's/^always-show-logo yes/always-show-logo no/g' -e 's/^appendfilename "appendonly.aof"/appendfilename "appendonly_6379.aof"/g' -e 's/^dbfilename dump.rdb/dbfilename dump_6379.rdb/g' -e 's/^dir \.\//dir \/app\/redis\/data/g' redis.conf > /app/redis/etc/redis_6379.conf [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# sed 's/6379/6380/g' /app/redis/etc/redis_6379.conf > /app/redis/etc/redis_6380.conf [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# sed 's/6379/6381/g' /app/redis/etc/redis_6379.conf > /app/redis/etc/redis_6381.conf [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# chown redis.redis /app/redis/ -R [root@Redis-Ubuntu-1804-p21:redis-5.0.14]# ll /app/redis/etc total 200 drwxr-xr-x 2 redis redis 4096 Apr 13 23:46 ./ drwxr-xr-x 7 redis redis 4096 Apr 13 22:21 ../ -rw-r--r-- 1 redis redis 63128 Apr 13 23:34 redis_6379.conf -rw-r--r-- 1 redis redis 63128 Apr 13 23:47 redis_6380.conf -rw-r--r-- 1 redis redis 63128 Apr 13 23:47 redis_6381.conf [root@Redis-Ubuntu-1804-p21:redis-5.0.14]#
7、redis service服务配置
[root@Redis-Ubuntu-1804-p21:~]# vim /etc/systemd/system/redis_6379.service [Unit] Description=Redis persistent key-value database After=network.target [Service] ExecStart=/app/redis/bin/redis-server /app/redis/etc/redis_6379.conf --supervised systemd ExecStop=/bin/kill -s QUIT Type=notify User=redis Group=redis RuntimeDirectory=redis RuntimeDirectoryMode=0755 LimitNOFILE=65536 [Install] WantedBy=multi-user.target
[root@Redis-Ubuntu-1804-p21:~]# sed 's/6379/6380/g' /etc/systemd/system/redis_6379.service > /etc/systemd/system/redis_6380.service [root@Redis-Ubuntu-1804-p21:~]# sed 's/6379/6381/g' /etc/systemd/system/redis_6379.service > /etc/systemd/system/redis_6381.service [root@Redis-Ubuntu-1804-p21:~]# systemctl daemon-reload
8、启动服务并设置开机自启动
[root@Redis-Ubuntu-1804-p21:~]# systemctl enable --now redis_6379.service redis_6380.service redis_6381.service Created symlink /etc/systemd/system/multi-user.target.wants/redis_6379.service → /etc/systemd/system/redis_6379.service. Created symlink /etc/systemd/system/multi-user.target.wants/redis_6380.service → /etc/systemd/system/redis_6380.service. Created symlink /etc/systemd/system/multi-user.target.wants/redis_6381.service → /etc/systemd/system/redis_6381.service. [root@Redis-Ubuntu-1804-p21:~]# ps -ef | grep redis-server redis 10491 1 0 00:24 ? 00:00:00 /app/redis/bin/redis-server 0.0.0.0:6381 redis 10492 1 0 00:24 ? 00:00:00 /app/redis/bin/redis-server 0.0.0.0:6380 redis 10493 1 0 00:24 ? 00:00:00 /app/redis/bin/redis-server 0.0.0.0:6379 root 10512 1247 0 00:25 pts/0 00:00:00 grep --color=auto redis-server [root@Redis-Ubuntu-1804-p21:~]# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 127.0.0.1:6010 0.0.0.0:* LISTEN 0 128 127.0.0.1:6011 0.0.0.0:* LISTEN 0 128 0.0.0.0:6379 0.0.0.0:* LISTEN 0 128 0.0.0.0:6380 0.0.0.0:* LISTEN 0 128 0.0.0.0:6381 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 128 [::1]:6010 [::]:* LISTEN 0 128 [::1]:6011 [::]:* [root@Redis-Ubuntu-1804-p21:~]#
[root@Redis-Ubuntu-1804-p21:~]# tree /app/redis
/app/redis
├── bin
│ ├── redis-benchmark
│ ├── redis-check-aof
│ ├── redis-check-rdb
│ ├── redis-cli
│ ├── redis-sentinel -> redis-server
│ └── redis-server
├── data
│ └── dump_6379.rdb
├── etc
│ ├── redis_6379.conf
│ ├── redis_6380.conf
│ └── redis_6381.conf
├── log
│ ├── redis_6379.log
│ ├── redis_6380.log
│ └── redis_6381.log
└── run
├── redis_6379.pid
├── redis_6380.pid
└── redis_6381.pid
5 directories, 16 files
[root@Redis-Ubuntu-1804-p21:~]#
9、观察启动日志,优化系统环境配置
10492:C 14 Apr 2023 00:24:57.118 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 10492:C 14 Apr 2023 00:24:57.118 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=10492, just started 10492:C 14 Apr 2023 00:24:57.118 # Configuration loaded 10492:C 14 Apr 2023 00:24:57.118 * supervised by systemd, will signal readiness 10492:M 14 Apr 2023 00:24:57.127 * Running mode=standalone, port=6380. 10492:M 14 Apr 2023 00:24:57.127 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. 10492:M 14 Apr 2023 00:24:57.127 # Server initialized 10492:M 14 Apr 2023 00:24:57.127 # 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. 10492:M 14 Apr 2023 00:24:57.127 # 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 never > /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. 10492:M 14 Apr 2023 00:24:57.132 * Ready to accept connections
[root@Redis-Ubuntu-1804-p21:~]# cat /proc/sys/net/core/somaxconn 128 [root@Redis-Ubuntu-1804-p21:~]# cat /proc/sys/vm/overcommit_memory 0 ## 补充2个参赛 [root@Redis-Ubuntu-1804-p21:~]# vim /etc/sysctl.conf net.core.somaxconn=1024 vm.overcommit_memory=1 [root@Redis-Ubuntu-1804-p21:~]# tail /etc/sysctl.conf # Protected links # # Protects against creating or following links under certain conditions # Debian kernels have both set to 1 (restricted) # See https://www.kernel.org/doc/Documentation/sysctl/fs.txt #fs.protected_hardlinks=0 #fs.protected_symlinks=0 net.core.somaxconn=1024 vm.overcommit_memory=1 [root@Redis-Ubuntu-1804-p21:~]# sysctl -p net.core.somaxconn = 1024 vm.overcommit_memory = 1 [root@Redis-Ubuntu-1804-p21:~]# cat /proc/sys/net/core/somaxconn 1024 [root@Redis-Ubuntu-1804-p21:~]# cat /proc/sys/vm/overcommit_memory 1
禁用透明大页
#临时修改 [root@Redis-Ubuntu-1804-p21:~]# cat /sys/kernel/mm/transparent_hugepage/enabled always [madvise] never [root@Redis-Ubuntu-1804-p21:~]# echo never > /sys/kernel/mm/transparent_hugepage/enabled [root@Redis-Ubuntu-1804-p21:~]# cat /sys/kernel/mm/transparent_hugepage/enabled always madvise [never] #永久修改生效 在开机启动过程中禁用 [root@Redis-Ubuntu-1804-p21:~]# cat > /etc/init.d/disable_transparent_hugepage << EOF > !/bin/bash > echo never > /sys/kernel/mm/transparent_hugepage/enabled > EOF [root@Redis-Ubuntu-1804-p21:~]# chmod 755 /etc/init.d/disable_transparent_hugepage [root@Redis-Ubuntu-1804-p21:~]# cd /etc/rcS.d/ [root@Redis-Ubuntu-1804-p21:rcS.d]# ln -s ../init.d/disable_transparent_hugepage disable_transparent_hugepage [root@Redis-Ubuntu-1804-p21:rcS.d]# ll /etc/init.d/ | grep disable_trans -rwxr-xr-x 1 root root 68 Apr 14 00:44 disable_transparent_hugepage* [root@Redis-Ubuntu-1804-p21:rcS.d]# ll | grep disable lrwxrwxrwx 1 root root 38 Apr 14 00:45 disable_transparent_hugepage -> ../init.d/disable_transparent_hugepage*
10、重启Redis服务、重启服务器验证
[root@Redis-Ubuntu-1804-p21:~]# systemctl restart redis_6380.service [root@Redis-Ubuntu-1804-p21:~]# tail -f /app/redis/log/redis_6380.log 0492:M 14 Apr 2023 00:24:57.127 # 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 never > /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. 10492:M 14 Apr 2023 00:24:57.132 * Ready to accept connections 10492:signal-handler (1681404602) Received SIGTERM scheduling shutdown... 10492:M 14 Apr 2023 00:50:02.103 # User requested shutdown... 10492:M 14 Apr 2023 00:50:02.103 * Saving the final RDB snapshot before exiting. 10492:M 14 Apr 2023 00:50:02.113 * DB saved on disk 10492:M 14 Apr 2023 00:50:02.113 * Removing the pid file. 10492:M 14 Apr 2023 00:50:02.113 # Redis is now ready to exit, bye bye... 10710:C 14 Apr 2023 00:50:02.131 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 10710:C 14 Apr 2023 00:50:02.131 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=10710, just started 10710:C 14 Apr 2023 00:50:02.132 # Configuration loaded 10710:C 14 Apr 2023 00:50:02.132 * supervised by systemd, will signal readiness 10710:M 14 Apr 2023 00:50:02.137 * Running mode=standalone, port=6380. 10710:M 14 Apr 2023 00:50:02.137 # Server initialized 10710:M 14 Apr 2023 00:50:02.137 * DB loaded from disk: 0.000 seconds 10710:M 14 Apr 2023 00:50:02.138 * Ready to accept connections
[root@Redis-Ubuntu-1804-p21:~]# reboot -------------------- [root@Redis-Ubuntu-1804-p21:~]# ps -ef | grep redis-server redis 858 1 0 00:52 ? 00:00:00 /app/redis/bin/redis-server 0.0.0.0:6380 redis 926 1 0 00:52 ? 00:00:00 /app/redis/bin/redis-server 0.0.0.0:6381 redis 928 1 0 00:52 ? 00:00:00 /app/redis/bin/redis-server 0.0.0.0:6379 root 1419 1403 0 00:53 pts/0 00:00:00 grep --color=auto redis-server [root@Redis-Ubuntu-1804-p21:~]# ss -ntl State Recv-Q Send-Q Local Address:Port Peer Address:Port LISTEN 0 511 0.0.0.0:6379 0.0.0.0:* LISTEN 0 511 0.0.0.0:6380 0.0.0.0:* LISTEN 0 511 0.0.0.0:6381 0.0.0.0:* LISTEN 0 128 127.0.0.53%lo:53 0.0.0.0:* LISTEN 0 128 0.0.0.0:22 0.0.0.0:* LISTEN 0 128 127.0.0.1:6010 0.0.0.0:* LISTEN 0 128 127.0.0.1:6011 0.0.0.0:* LISTEN 0 128 [::]:22 [::]:* LISTEN 0 128 [::1]:6010 [::]:* LISTEN 0 128 [::1]:6011 [::]:* [root@Redis-Ubuntu-1804-p21:~]# tail -f /app/redis/log/redis_6380.log 10710:M 14 Apr 2023 00:52:27.248 # Redis is now ready to exit, bye bye... 858:C 14 Apr 2023 00:52:41.166 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 858:C 14 Apr 2023 00:52:41.166 # Redis version=5.0.14, bits=64, commit=00000000, modified=0, pid=858, just started 858:C 14 Apr 2023 00:52:41.166 # Configuration loaded 858:C 14 Apr 2023 00:52:41.166 * supervised by systemd, will signal readiness 858:M 14 Apr 2023 00:52:41.170 * Running mode=standalone, port=6380. 858:M 14 Apr 2023 00:52:41.170 # Server initialized 858:M 14 Apr 2023 00:52:41.170 # 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 never > /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. 858:M 14 Apr 2023 00:52:41.171 * DB loaded from disk: 0.001 seconds 858:M 14 Apr 2023 00:52:41.171 * Ready to accept connections
11、连接数据库,验证数据读写
[root@Redis-Ubuntu-1804-p21:~]# redis-cli set name janzen OK [root@Redis-Ubuntu-1804-p21:~]# redis-cli get name "janzen" [root@Redis-Ubuntu-1804-p21:~]# redis-cli -p 6380 set name janzen80 OK [root@Redis-Ubuntu-1804-p21:~]# redis-cli -p 6380 get name "janzen80" [root@Redis-Ubuntu-1804-p21:~]# redis-cli -p 6381 set name janzen81 OK [root@Redis-Ubuntu-1804-p21:~]# redis-cli -p 6381 get name "janzen81" [root@Redis-Ubuntu-1804-p21:~]#