Centos7上面部署redis
编写这个部署redis,只是为了另一个文章入侵redis做准备,网上还有好多类似的文章,这个单纯的就是部署安装,并简单的测试使用以下
关联其他文章
[1]VMware上面安装部署centos7镜像系统【详细含镜像】
[2]血的教训—入侵redis并远程控制你的机器场景复现
redis版本 3.0.4
系统版本 | IP地址 | 详解 |
---|---|---|
Centos7 | 192.168.144.128 | 部署redis-server端 |
废话不多,直接开干
部署redis
用的是redis-3.0.4的呦
#下载源码包
[root@localhost ~]# wget https://download.redis.io/releases/redis-3.0.4.tar.gz
--2022-10-26 15:09:31-- https://download.redis.io/releases/redis-3.0.4.tar.gz
正在解析主机 download.redis.io (download.redis.io)... 45.60.125.1
正在连接 download.redis.io (download.redis.io)|45.60.125.1|:443... 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:1364993 (1.3M) [application/octet-stream]
正在保存至: “redis-3.0.4.tar.gz”100%[====================================================================================================================================================================>] 1,364,993 1.59MB/s 用时 0.8s2022-10-26 15:09:33 (1.59 MB/s) - 已保存 “redis-3.0.4.tar.gz” [1364993/1364993])[root@localhost ~]# ls
anaconda-ks.cfg mysql-5.6.39.tar.gz php-5.6.40.tar.gz zabbix-4.0.3.tar.gz zabbix_dd.py zabbix_wx.py
msyh.ttf nginx-1.16.1.tar.gz redis-3.0.4.tar.gz zabbix_agent-4.0.0-windows-amd64.zip zabbix_sendmail.py
## 开始解压源码包
[root@localhost ~]# tar xvf redis-3.0.4.tar.gz
redis-3.0.4/
redis-3.0.4/.gitignore
redis-3.0.4/00-RELEASENOTES
redis-3.0.4/BUGS
redis-3.0.4/CONTRIBUTING
redis-3.0.4/COPYING
**********省略好多*********************************
[root@localhost ~]# ls
anaconda-ks.cfg mysql-5.6.39.tar.gz php-5.6.40.tar.gz redis-3.0.4.tar.gz zabbix_agent-4.0.0-windows-amd64.zip zabbix_sendmail.py
msyh.ttf nginx-1.16.1.tar.gz redis-3.0.4 zabbix-4.0.3.tar.gz zabbix_dd.py zabbix_wx.py
[root@localhost ~]# cd redis-3.0.4
[root@localhost redis-3.0.4]# ls
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
##开始编译
[root@localhost redis-3.0.4]# make && make install
make[1]: 进入目录“/root/redis-3.0.4/src”
rm -rf redis-server redis-sentinel redis-cli redis-benchmark redis-check-dump redis-check-aof *.o *.gcda *.gcno *.gcov redis.info lcov-html
(cd ../deps && make distclean)
make[2]: 进入目录“/root/redis-3.0.4/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-*)
******************省略好多********************LINK redis-serverINSTALL redis-sentinelCC redis-cli.oLINK redis-cliCC redis-benchmark.oLINK redis-benchmarkCC redis-check-dump.oLINK redis-check-dumpCC redis-check-aof.oLINK redis-check-aofHint: It's a good idea to run 'make test' ;)make[1]: 离开目录“/root/redis-3.0.4/src”
[root@localhost redis-3.0.4]# ls
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
[root@localhost redis-3.0.4]# ls
00-RELEASENOTES BUGS CONTRIBUTING COPYING deps INSTALL Makefile MANIFESTO README redis.conf runtest runtest-cluster runtest-sentinel sentinel.conf src tests utils
[root@localhost redis-3.0.4]# cd src/
[root@localhost src]# ls
adlist.c anet.o cluster.h debug.c intset.c Makefile object.o redisassert.h redis-cli.c rio.c sha1.c syncio.c t_zset.o zmalloc.c
adlist.h aof.c cluster.o debug.o intset.h Makefile.dep pqsort.c redis-benchmark redis-cli.o rio.h sha1.h syncio.o util.c zmalloc.h
adlist.o aof.o config.c dict.c intset.o memtest.c pqsort.h redis-benchmark.c redis.h rio.o sha1.o testhelp.h util.h zmalloc.o
ae.c asciilogo.h config.h dict.h latency.c memtest.o pqsort.o redis-benchmark.o redis.o scripting.c slowlog.c t_hash.c util.o
ae_epoll.c bio.c config.o dict.o latency.h mkreleasehdr.sh pubsub.c redis.c redis-sentinel scripting.o slowlog.h t_hash.o valgrind.sup
ae_evport.c bio.h crc16.c endianconv.c latency.o multi.c pubsub.o redis-check-aof redis-server sds.c slowlog.o t_list.c version.h
ae.h bio.o crc16.o endianconv.h lzf_c.c multi.o rand.c redis-check-aof.c redis-trib.rb sds.h solarisfixes.h t_list.o ziplist.c
ae_kqueue.c bitops.c crc64.c endianconv.o lzf_c.o networking.c rand.h redis-check-aof.o release.c sds.o sort.c t_set.c ziplist.h
ae.o bitops.o crc64.h fmacros.h lzf_d.c networking.o rand.o redis-check-dump release.h sentinel.c sort.o t_set.o ziplist.o
ae_select.c blocked.c crc64.o help.h lzf_d.o notify.c rdb.c redis-check-dump.c release.o sentinel.o sparkline.c t_string.c zipmap.c
anet.c blocked.o db.c hyperloglog.c lzf.h notify.o rdb.h redis-check-dump.o replication.c setproctitle.c sparkline.h t_string.o zipmap.h
anet.h cluster.c db.o hyperloglog.o lzfP.h object.c rdb.o redis-cli replication.o setproctitle.o sparkline.o t_zset.c zipmap.o##启动redis-server
[root@localhost src]# ./redis-server
4203:C 26 Oct 15:11:20.884 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf
4203:M 26 Oct 15:11:20.885 * Increased maximum number of open files to 10032 (it was originally set to 1024)._.__.-``__ ''-.__.-`` `. `_. ''-._ Redis 3.0.4 (00000000/0) 64 bit.-`` .-```. ```\/ _.,_ ''-._( ' , .-` | `, ) Running in standalone mode|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379| `-._ `._ / _.-' | PID: 4203`-._ `-._ `-./ _.-' _.-'|`-._`-._ `-.__.-' _.-'_.-'|| `-._`-._ _.-'_.-' | http://redis.io`-._ `-._`-.__.-'_.-' _.-'|`-._`-._ `-.__.-' _.-'_.-'|| `-._`-._ _.-'_.-' |`-._ `-._`-.__.-'_.-' _.-'`-._ `-.__.-' _.-'`-._ _.-'`-.__.-'4203:M 26 Oct 15:11:20.885 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
4203:M 26 Oct 15:11:20.885 # Server started, Redis version 3.0.4
4203:M 26 Oct 15:11:20.885 # 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.
4203:M 26 Oct 15:11:20.885 # 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.
4203:M 26 Oct 15:11:20.885 * The server is now ready to accept connections on port 6379
^C4203:signal-handler (1666768287) Received SIGINT scheduling shutdown...
4203:M 26 Oct 15:11:27.404 # User requested shutdown...
4203:M 26 Oct 15:11:27.404 * Saving the final RDB snapshot before exiting.
4203:M 26 Oct 15:11:27.405 * DB saved on disk
4203:M 26 Oct 15:11:27.405 # Redis is now ready to exit, bye bye...ctrl + c停止掉redis[root@localhost redis-3.0.4]# vim ../redis.conf ##添加密码
# 设置需要密码才能访问,123456为示例,请改为强密码
requirepass 123456[root@localhost src]# ./redis-server ../redis.conf ##带配置文件启动
[root@localhost src]#
[root@localhost src]#
[root@localhost src]#
[root@localhost src]#
[root@localhost src]#
[root@localhost src]# ps -ef | grep redis ##过滤下redis进程
root 4245 4219 0 15:13 pts/1 00:00:00 ./redis-cli
root 4250 1 0 15:16 ? 00:00:00 ./redis-server *:6379
root 4254 1310 0 15:16 pts/0 00:00:00 grep --color=auto redis
## 到这我们的redis-server就已经布置好了
## 大家可以看下其他的几个文章,来了解下我们要干什么吧,嘻嘻
常见遇见问题
缺少gcc gcc-c++
依赖包,报错如下
直接yum安装就可以解决yum -y install gcc gcc-c++
如果你的服务器yum不能够直接安装,建议你可以看看yum的离线安装方式
yum不安装只下载rpm包(含centos6,centos7)
注意安装完gcc后,需要删掉之前解压的redis包,并重新解压一下,才能正常编译,否则还是报错如下:
结束语
这篇文章只是简单的一个部署测试,是为了跟同一专栏里面的其他的文章打基础的
[1]VMware上面安装部署centos7镜像系统【详细含镜像】
[2]血的教训—入侵redis并远程控制你的机器场景复现