Linux系统centos6安装Redis
Linux系统centos6不小心删除了/etc/yum.repos.d/CentOS-Base.repo文件
[root@CentOS111 yum.repos.d]# yum install gcc
结果报错了
Loaded plugins: refresh-packagekit, security
Setting up Install Process
No package gcc available.
Error: Nothing to do
最后百度了很久发现我的/etc/yum.repos.d/CentOS-Base.repo文件乜有导致使用yum安装时报错。
阿里云官方镜像站:
https://developer.aliyun.com/mirror/
使用阿里云的镜像,找到了CentOS6d的yum镜像配置:
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
发现又有新的报错:
[root@CentOS111 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
--2022-11-03 06:37:33-- https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
正在解析主机 mirrors.aliyun.com... 124.193.244.230, 124.193.244.229, 124.193.244.224, ...
正在连接 mirrors.aliyun.com|124.193.244.230|:443... 已连接。
错误: 证书通用名 “*.alicdn.com” 与所要求的主机名 “mirrors.aliyun.com” 不符。
要以不安全的方式连接至 mirrors.aliyun.com,使用‘--no-check-certificate’。
我按照提提示调整了代码
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo --no-check-certificate
然后关于证书的报错解决了
[root@CentOS111 yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo --no-check-certificate
--2022-11-03 06:43:45-- https://mirrors.aliyun.com/repo/Centos-vault-6.10.repo
正在解析主机 mirrors.aliyun.com... 124.193.244.228, 124.193.244.229, 124.193.244.224, ...
正在连接 mirrors.aliyun.com|124.193.244.228|:443... 已连接。
警告: 证书通用名 “*.alicdn.com” 与所要求的主机名 “mirrors.aliyun.com” 不符。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:2533 (2.5K) [application/octet-stream]
正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”
100%[=======================================================================================================================================================================>] 2,533 --.-K/s in 0s
2022-11-03 06:43:45 (1.08 GB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2533/2533])
这个时候再去下载gc编译环境测试一下 :
[root@CentOS111 yum.repos.d]# yum install gcc
Loaded plugins: refresh-packagekit, security
base | 3.7 kB 00:00
base/primary_db | 4.7 MB 00:00
extras | 3.4 kB 00:00
extras/primary_db | 29 kB 00:00
updates | 3.4 kB 00:00
updates/primary_db | 12 MB 00:01
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package gcc.x86_64 0:4.4.7-23.el6 will be installed
--> Processing Dependency: libgomp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: cpp = 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: libgcc >= 4.4.7-23.el6 for package: gcc-4.4.7-23.el6.x86_64
--> Processing Dependency: cloog-ppl >= 0.15 for package: gcc-4.4.7-23.el6.x86_64
--> Running transaction check
---> Package cloog-ppl.x86_64 0:0.15.7-1.2.el6 will be installed
--> Processing Dependency: libppl_c.so.2()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
--> Processing Dependency: libppl.so.7()(64bit) for package: cloog-ppl-0.15.7-1.2.el6.x86_64
---> Package cpp.x86_64 0:4.4.7-23.el6 will be installed
--> Processing Dependency: libmpfr.so.1()(64bit) for package: cpp-4.4.7-23.el6.x86_64
---> Package libgcc.i686 0:4.4.7-4.el6 will be updated
---> Package libgcc.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgcc.i686 0:4.4.7-23.el6 will be an update
---> Package libgcc.x86_64 0:4.4.7-23.el6 will be an update
---> Package libgomp.x86_64 0:4.4.7-4.el6 will be updated
---> Package libgomp.x86_64 0:4.4.7-23.el6 will be an update
--> Running transaction check
---> Package mpfr.x86_64 0:2.4.1-6.el6 will be installed
---> Package ppl.x86_64 0:0.10.2-11.el6 will be installed
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================================================================================
Installing:
gcc x86_64 4.4.7-23.el6 base 10 M
Installing for dependencies:
cloog-ppl x86_64 0.15.7-1.2.el6 base 93 k
cpp x86_64 4.4.7-23.el6 base 3.7 M
mpfr x86_64 2.4.1-6.el6 base 157 k
ppl x86_64 0.10.2-11.el6 base 1.3 M
Updating for dependencies:
libgcc i686 4.4.7-23.el6 base 115 k
libgcc x86_64 4.4.7-23.el6 base 104 k
libgomp x86_64 4.4.7-23.el6 base 135 k
Transaction Summary
=================================================================================================================================================================================================================
Install 5 Package(s)
Upgrade 3 Package(s)
Total download size: 16 M
Is this ok [y/N]: y
Downloading Packages:
(1/8): cloog-ppl-0.15.7-1.2.el6.x86_64.rpm | 93 kB 00:00
(2/8): cpp-4.4.7-23.el6.x86_64.rpm | 3.7 MB 00:00
(3/8): gcc-4.4.7-23.el6.x86_64.rpm | 10 MB 00:01
(4/8): libgcc-4.4.7-23.el6.i686.rpm | 115 kB 00:00
(5/8): libgcc-4.4.7-23.el6.x86_64.rpm | 104 kB 00:00
(6/8): libgomp-4.4.7-23.el6.x86_64.rpm | 135 kB 00:00
(7/8): mpfr-2.4.1-6.el6.x86_64.rpm | 157 kB 00:00
(8/8): ppl-0.10.2-11.el6.x86_64.rpm | 1.3 MB 00:00
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 4.1 MB/s | 16 MB 00:03
warning: rpmts_HdrFromFdno: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
Retrieving key from http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
Importing GPG key 0xC105B9DE:
Userid: "CentOS-6 Key (CentOS 6 Official Signing Key) <centos-6-key@centos.org>"
From : http://mirrors.aliyun.com/centos-vault/RPM-GPG-KEY-CentOS-6
Is this ok [y/N]: y
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Updating : libgcc-4.4.7-23.el6.x86_64 1/11
Installing : ppl-0.10.2-11.el6.x86_64 2/11
Installing : cloog-ppl-0.15.7-1.2.el6.x86_64 3/11
Installing : mpfr-2.4.1-6.el6.x86_64 4/11
Installing : cpp-4.4.7-23.el6.x86_64 5/11
Updating : libgomp-4.4.7-23.el6.x86_64 6/11
Installing : gcc-4.4.7-23.el6.x86_64 7/11
Updating : libgcc-4.4.7-23.el6.i686 8/11
Cleanup : libgcc-4.4.7-4.el6 9/11
Cleanup : libgcc-4.4.7-4.el6 10/11
Cleanup : libgomp-4.4.7-4.el6.x86_64 11/11
Verifying : libgomp-4.4.7-23.el6.x86_64 1/11
Verifying : libgcc-4.4.7-23.el6.i686 2/11
Verifying : gcc-4.4.7-23.el6.x86_64 3/11
Verifying : mpfr-2.4.1-6.el6.x86_64 4/11
Verifying : cloog-ppl-0.15.7-1.2.el6.x86_64 5/11
Verifying : cpp-4.4.7-23.el6.x86_64 6/11
Verifying : ppl-0.10.2-11.el6.x86_64 7/11
Verifying : libgcc-4.4.7-23.el6.x86_64 8/11
Verifying : libgomp-4.4.7-4.el6.x86_64 9/11
Verifying : libgcc-4.4.7-4.el6.i686 10/11
Verifying : libgcc-4.4.7-4.el6.x86_64 11/11
Installed:
gcc.x86_64 0:4.4.7-23.el6
Dependency Installed:
cloog-ppl.x86_64 0:0.15.7-1.2.el6 cpp.x86_64 0:4.4.7-23.el6 mpfr.x86_64 0:2.4.1-6.el6 ppl.x86_64 0:0.10.2-11.el6
Dependency Updated:
libgcc.i686 0:4.4.7-23.el6 libgcc.x86_64 0:4.4.7-23.el6 libgomp.x86_64 0:4.4.7-23.el6
Complete!
[root@CentOS111 yum.repos.d]#
发现成功了!!!!真的容易啊,这个报错解决了好几个小时,哭了~
编译环境安装好之后,我们把redis的安装包放在/opt文件夹下:
root@CentOS111 opt]# ll
总用量 57552
-rw-r--r--. 1 root root 2487287 11月 2 05:53 redis-6.2.7.tar.gz
drwxr-xr-x. 2 root root 4096 11月 22 2013 rh
-rw-r--r--. 1 root root 56431201 6月 13 2019 VMwareTools-10.3.10-13959562.tar.gz
drwxr-xr-x. 9 root root 4096 6月 13 2019 vmware-tools-distrib
将安装包进行解压:
[root@CentOS111 opt]# tar -zxvf redis-6.2.7.tar.gz
redis-6.2.7/
redis-6.2.7/.github/
redis-6.2.7/.github/ISSUE_TEMPLATE/
redis-6.2.7/.github/ISSUE_TEMPLATE/bug_report.md
redis-6.2.7/.github/ISSUE_TEMPLATE/crash_report.md
redis-6.2.7/.github/ISSUE_TEMPLATE/feature_request.md
redis-6.2.7/.github/ISSUE_TEMPLATE/other_stuff.md
redis-6.2.7/.github/ISSUE_TEMPLATE/question.md
redis-6.2.7/.github/workflows/
redis-6.2.7/.github/workflows/ci.yml
redis-6.2.7/.github/workflows/daily.yml
redis-6.2.7/.gitignore
redis-6.2.7/00-RELEASENOTES
redis-6.2.7/BUGS
redis-6.2.7/CONDUCT
redis-6.2.7/CONTRIBUTING
redis-6.2.7/COPYING
redis-6.2.7/INSTALL
redis-6.2.7/MANIFESTO
redis-6.2.7/Makefile
redis-6.2.7/README.md
........
redis-6.2.7/utils/systemd-redis_server.service
redis-6.2.7/utils/tracking_collisions.c
redis-6.2.7/utils/whatisdoing.sh
[root@CentOS111 opt]#
然后再进入redis的安装文件夹下
[root@CentOS111 opt]# ll
总用量 57556
drwxrwxr-x. 7 root root 4096 4月 27 2022 redis-6.2.7
-rw-r--r--. 1 root root 2487287 11月 2 05:53 redis-6.2.7.tar.gz
drwxr-xr-x. 2 root root 4096 11月 22 2013 rh
-rw-r--r--. 1 root root 56431201 6月 13 2019 VMwareTools-10.3.10-13959562.tar.gz
drwxr-xr-x. 9 root root 4096 6月 13 2019 vmware-tools-distrib
[root@CentOS111 opt]# cd redis-6.2.7
[root@CentOS111 redis-6.2.7]#
执行make命令进行编译
root@CentOS111 redis-6.2.7]# make
cd src && make all
make[1]: Entering directory `/opt/redis-6.2.7/src'
CC Makefile.dep
make[1]: Leaving directory `/opt/redis-6.2.7/src'
make[1]: Entering directory `/opt/redis-6.2.7/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
rm -f adlist.d quicklist.d ae.d anet.d dict.d server.d sds.d zmalloc.d lzf_c.d lzf_d.d pqsort.d zipmap.d sha1.d ziplist.d release.d networking.d util.d object.d db.d replication.d rdb.d t_string.d t_list.d t_set.d t_zset.d t_hash.d config.d aof.d pubsub.d multi.d debug.d sort.d intset.d syncio.d cluster.d crc16.d endianconv.d slowlog.d scripting.d bio.d rio.d rand.d memtest.d crcspeed.d crc64.d bitops.d sentinel.d notify.d setproctitle.d blocked.d hyperloglog.d latency.d sparkline.d redis-check-rdb.d redis-check-aof.d geo.d lazyfree.d module.d evict.d expire.d geohash.d geohash_helper.d childinfo.d defrag.d siphash.d rax.d t_stream.d listpack.d localtime.d lolwut.d lolwut5.d lolwut6.d acl.d gopher.d tracking.d connection.d tls.d sha256.d timeout.d setcpuaffinity.d monotonic.d mt19937-64.d anet.d adlist.d dict.d redis-cli.d zmalloc.d release.d ae.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d ae.d anet.d redis-benchmark.d adlist.d dict.d zmalloc.d release.d crcspeed.d crc64.d siphash.d crc16.d monotonic.d cli_common.d mt19937-64.d
(cd ../deps && make distclean)
make[2]: Entering directory `/opt/redis-6.2.7/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
(cd hdr_histogram && make clean) > /dev/null || true
(rm -f .make-*)
make[2]: Leaving directory `/opt/redis-6.2.7/deps'
(cd modules && make clean)
make[2]: Entering directory `/opt/redis-6.2.7/src/modules'
rm -rf *.xo *.so
make[2]: Leaving directory `/opt/redis-6.2.7/src/modules'
(cd ../tests/modules && make clean)
make[2]: Entering directory `/opt/redis-6.2.7/tests/modules'
rm -f commandfilter.so basics.so testrdb.so fork.so infotest.so propagate.so misc.so hooks.so blockonkeys.so blockonbackground.so scan.so datatype.so auth.so keyspace_events.so blockedclient.so getkeys.so test_lazyfree.so timer.so defragtest.so hash.so zset.so stream.so commandfilter.xo basics.xo testrdb.xo fork.xo infotest.xo propagate.xo misc.xo hooks.xo blockonkeys.xo blockonbackground.xo scan.xo datatype.xo auth.xo keyspace_events.xo blockedclient.xo getkeys.xo test_lazyfree.xo timer.xo defragtest.xo hash.xo zset.xo stream.xo
make[2]: Leaving directory `/opt/redis-6.2.7/tests/modules'
(rm -f .make-*)
echo STD=-pedantic -DREDIS_STATIC='' -std=c99 >> .make-settings
echo WARN=-Wall -W -Wno-missing-field-initializers >> .make-settings
echo OPT=-O2 >> .make-settings
echo MALLOC=jemalloc >> .make-settings
............(省编译过程)
CC lolwut6.o
CC acl.o
CC gopher.o
CC tracking.o
CC connection.o
CC tls.o
CC sha256.o
CC timeout.o
CC setcpuaffinity.o
CC monotonic.o
CC mt19937-64.o
LINK redis-server
INSTALL redis-sentinel
CC redis-cli.o
CC cli_common.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' ;)
make[1]: Leaving directory `/opt/redis-6.2.7/src'
[root@CentOS111 redis-6.2.7]#
到这里说明我们已经编译完成了
然后我们将redis安装到指定目录下
执行make install
[root@CentOS111 redis-6.2.7]# make install
cd src && make install
make[1]: Entering directory `/opt/redis-6.2.7/src'
CC Makefile.dep
make[1]: Leaving directory `/opt/redis-6.2.7/src'
make[1]: Entering directory `/opt/redis-6.2.7/src'
Hint: It's a good idea to run 'make test' ;)
INSTALL redis-server
INSTALL redis-benchmark
INSTALL redis-cli
make[1]: Leaving directory `/opt/redis-6.2.7/src'
[root@CentOS111 redis-6.2.7]#
默认的安装路径是:
/usr/local/bin
然后打开这路径:
[root@CentOS111 usr]# ll
总用量 156
dr-xr-xr-x. 2 root root 40960 11月 3 06:47 bin
drwxr-xr-x. 2 root root 4096 9月 23 2011 etc
drwxr-xr-x. 2 root root 4096 9月 23 2011 games
drwxr-xr-x. 36 root root 4096 11月 1 07:06 include
dr-xr-xr-x. 20 root root 4096 11月 3 06:47 lib
dr-xr-xr-x. 109 root root 57344 11月 3 06:47 lib64
drwxr-xr-x. 25 root root 12288 11月 3 06:47 libexec
drwxr-xr-x. 12 root root 4096 11月 1 07:04 local
dr-xr-xr-x. 2 root root 12288 11月 3 05:26 sbin
drwxr-xr-x. 198 root root 4096 11月 1 07:10 share
drwxr-xr-x. 4 root root 4096 11月 1 07:04 src
lrwxrwxrwx. 1 root root 10 11月 1 07:04 tmp -> ../var/tmp
[root@CentOS111 usr]# cd local
[root@CentOS111 local]# ll
总用量 40
drwxr-xr-x. 2 root root 4096 11月 3 07:02 bin
drwxr-xr-x. 2 root root 4096 9月 23 2011 etc
drwxr-xr-x. 2 root root 4096 9月 23 2011 games
drwxr-xr-x. 2 root root 4096 9月 23 2011 include
drwxr-xr-x. 2 root root 4096 9月 23 2011 lib
drwxr-xr-x. 2 root root 4096 9月 23 2011 lib64
drwxr-xr-x. 2 root root 4096 9月 23 2011 libexec
drwxr-xr-x. 2 root root 4096 9月 23 2011 sbin
drwxr-xr-x. 5 root root 4096 11月 1 07:04 share
drwxr-xr-x. 2 root root 4096 9月 23 2011 src
[root@CentOS111 local]# cd bin
[root@CentOS111 bin]# ll
总用量 32144
-rwxr-xr-x. 1 root root 9654834 11月 3 07:02 redis-benchmark
lrwxrwxrwx. 1 root root 12 11月 3 07:02 redis-check-aof -> redis-server
lrwxrwxrwx. 1 root root 12 11月 3 07:02 redis-check-rdb -> redis-server
-rwxr-xr-x. 1 root root 9766420 11月 3 07:02 redis-cli
lrwxrwxrwx. 1 root root 12 11月 3 07:02 redis-sentinel -> redis-server
-rwxr-xr-x. 1 root root 13484090 11月 3 07:02 redis-server
[root@CentOS111 bin]#
看到redis相关文件说明已经安装完成了
然后执行redis-server进行redis客户端启动(前台启动)测试是否安装成功:
[root@CentOS111 bin]# redis-server
33441:C 03 Nov 2022 07:07:31.445 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
33441:C 03 Nov 2022 07:07:31.445 # Redis version=6.2.7, bits=64, commit=00000000, modified=0, pid=33441, just started
33441:C 03 Nov 2022 07:07:31.445 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
33441:M 03 Nov 2022 07:07:31.445 * Increased maximum number of open files to 10032 (it was originally set to 1024).
33441:M 03 Nov 2022 07:07:31.445 * monotonic clock: POSIX clock_gettime
33441:M 03 Nov 2022 07:07:31.457 # A key '__redis__compare_helper' was added to Lua globals which is not on the globals allow list nor listed on the deny list.
_._
_.-``__ ''-._
_.-`` `. `_. ''-._ Redis 6.2.7 (00000000/0) 64 bit
.-`` .-```. ```\/ _.,_ ''-._
( ' , .-` | `, ) Running in standalone mode
|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379
| `-._ `._ / _.-' | PID: 33441
`-._ `-._ `-./ _.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' | https://redis.io
`-._ `-._`-.__.-'_.-' _.-'
|`-._`-._ `-.__.-' _.-'_.-'|
| `-._`-._ _.-'_.-' |
`-._ `-._`-.__.-'_.-' _.-'
`-._ `-.__.-' _.-'
`-._ _.-'
`-.__.-'
33441:M 03 Nov 2022 07:07:31.458 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
33441:M 03 Nov 2022 07:07:31.458 # Server initialized
33441:M 03 Nov 2022 07:07:31.458 # 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.
33441:M 03 Nov 2022 07:07:31.458 # 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').
33441:M 03 Nov 2022 07:07:31.458 * Ready to accept connections
看到这个界面说明安装成功了!!!!
后台启动
将redis解压文件中的redis.config拷贝到redis的安装目录中
后台启用redis服务
[root@CentOS111 opt]# redis-server /usr/local/bin/redis.conf
[root@CentOS111 opt]#
用ps命令查看redis进程
[root@CentOS111 opt]# ps -ef | grep redis
root 2918 1 0 04:33 ? 00:00:00 redis-server 127.0.0.1:6379
root 2928 2855 0 04:34 pts/0 00:00:00 grep redis
[root@CentOS111 opt]#
启用redis客户端
[root@CentOS111 opt]# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
redis关闭,两种方式:
1、redis-cli shutdown
[root@CentOS111 opt]# redis-cli shutdown
[root@CentOS111 opt]#
2、kill根据进程号杀进程
127.0.0.1:6379> ps -ef|grep redis