在我安装的虚拟机中,我把所有自己安装的软件都放在了/ph/install 目录下,具体以自己实际情况为准。
[root@localhost ~]$ cd /ph/install #进入到自己创建的安装目录下 #下载压缩包 [root@localhost ~]$ wget http://download.redis.io/releases/redis-5.0.0.tar.gz #解压缩 [root@localhost ~]$ tar -zxvf redis-5.0.0.tar.gz -C /ph/install/ #安装gcc基础环境, 可以先查看是否安装过: gcc --version [root@localhost ~]$ yum -y install gcc [root@localhost ~]$ yum -y install gcc-c++ #编译redis [root@localhost ~]$ cd /ph/install/redis-5.0.0 [root@localhost redis-5.0.0]$ make MALLOC=libc #安装 [root@localhost redis-5.0.0]$ cd src [root@localhost src]$ make install #查看是否安装成功, 输入命令: "ll |grep redis-" 如果显示信息如下所示, 就是安装成功 [root@localhost src]$ ll |grep redis- -rwxr-xr-x. 1 root root 353848 6月 26 18:30 redis-benchmark -rw-rw-r--. 1 root root 29605 10月 17 2018 redis-benchmark.c -rw-r--r--. 1 root root 109104 6月 26 18:30 redis-benchmark.o -rwxr-xr-x. 1 root root 4016272 6月 26 18:30 redis-check-aof -rw-rw-r--. 1 root root 7143 10月 17 2018 redis-check-aof.c -rw-r--r--. 1 root root 28744 6月 26 18:30 redis-check-aof.o -rwxr-xr-x. 1 root root 4016272 6月 26 18:30 redis-check-rdb -rw-rw-r--. 1 root root 13541 10月 17 2018 redis-check-rdb.c -rw-r--r--. 1 root root 65872 6月 26 18:30 redis-check-rdb.o -rwxr-xr-x. 1 root root 771056 6月 26 18:30 redis-cli -rw-rw-r--. 1 root root 249486 10月 17 2018 redis-cli.c -rw-r--r--. 1 root root 871040 6月 26 18:30 redis-cli.o -rwxr-xr-x. 1 root root 4016272 6月 26 18:30 redis-sentinel -rwxr-xr-x. 1 root root 4016272 6月 26 18:30 redis-server -rwxrwxr-x. 1 root root 3600 10月 17 2018 redis-trib.rb
#进入到 /ph/install/redis-5.0.0/ 目录下 [root@localhost /]$ cd /ph/install/redis-5.0.0/ #创建配置文件的文件夹 和 数据的文件夹 [root@localhost redis-5.0.0]$ mkdir conf [root@localhost redis-5.0.0]$ mkdir data #将默认配置文件复制一份到conf文件夹下, 同时备份一份 [root@localhost redis-5.0.0]$ cp redis.conf conf/ [root@localhost redis-5.0.0]$ cp redis.conf conf/redis.conf.back
#进入到 redis-5.0.0/src 目录下, 启动redis服务, &符号表示后台运行, 能够看到如下图所示,启动成功 [root@localhost redis-5.0.0]$ cd src [root@localhost src]$ ./redis-server ../redis.conf & 9818:M 26 Jun 2020 19:02:20.243 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ‘‘-._ _.-`` `. `_. ‘‘-._ Redis 5.0.0 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ‘‘-._ ( ‘ , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|‘` _.-‘| Port: 6379 | `-._ `._ / _.-‘ | PID: 9818 `-._ `-._ `-./ _.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | http://redis.io `-._ `-._`-.__.-‘_.-‘ _.-‘ |`-._`-._ `-.__.-‘ _.-‘_.-‘| | `-._`-._ _.-‘_.-‘ | `-._ `-._`-.__.-‘_.-‘ _.-‘ `-._ `-.__.-‘ _.-‘ `-._ _.-‘ `-.__.-‘ 9818:M 26 Jun 2020 19:02:20.244 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128. #ctrl + c 回退到命令行出, 查看进程, 如下所示就证明 [root@localhost src]$ ps -ef|grep redis root 9818 7878 0 19:02 pts/0 00:00:00 ./redis-server 0.0.0.0:6379 root 9832 7878 0 19:02 pts/0 00:00:00 grep --color=auto redis
#本地连接, 如下表示连接成功 [root@localhost conf]$ redis-cli 127.0.0.1:6379> 127.0.0.1:6379> 127.0.0.1:6379> #连接远程redis [root@localhost conf]$ redis-cli –h 61.129.65.248 –p 6384
#将redis-6379.conf中的注释等都处理掉 [root@localhost redis-5.0.0]$ cd conf [root@localhost conf]$ cat redis.conf|grep -Ev ‘^$|#‘ > redis-6379.conf #进入到conf文件夹对redis-6379.conf文件进行修改 [root@localhost conf]$ vim redis-6379.conf #bind 127.0.0.1 允许外网访问 #bind 0.0.0.0 bind 192.168.23.129 #后台启动 daemonize yes #日志文件 logfile "redis-6379.log" #数据文件夹设置 dir /ph/install/redis-5.0.0/data #:wq 保存退出 #关闭redis 服务 [root@localhost conf]$ ps -ef|grep redis root 9818 7878 0 19:02 pts/0 00:00:02 ./redis-server 0.0.0.0:6379 root 10675 7878 0 19:45 pts/0 00:00:00 grep --color=auto redis [root@localhost conf]$ [root@localhost conf]$ kill -9 9818 #再次启动并加载修改后的配置 redis-6379.conf [root@localhost conf]$ redis-server redis-6379.conf #查看进程是否存在, 如下启动成功 [root@localhost conf]$ ps -ef|grep redis root 10734 1 0 19:47 ? 00:00:00 redis-server 0.0.0.0:6379 root 10739 7878 0 19:47 pts/0 00:00:00 grep --color=auto redis [root@localhost conf]$
原文:https://www.cnblogs.com/qsbnj/p/13474971.html