CentOS安装Redis
解压安装包
[root@zhang opt]# tar -zxvf redis-6.0.6.tar.gz
进入解压后的文件
[root@zhang opt]# cd redis-6.0.6/
[root@zhang redis-6.0.6]# ls
00-RELEASENOTES COPYING Makefile redis.conf runtest-moduleapi src utils
BUGS deps MANIFESTO runtest runtest-sentinel tests
CONTRIBUTING INSTALL README.md runtest-cluster sentinel.conf TLS.md
安装gcc环境
[root@zhang redis-6.0.6]# yum install gcc-c++
Repository epel is listed more than once in the configuration
Last metadata expiration check: 0:11:41 ago on Tue 11 May 2021 10:06:45 PM CST.
Package gcc-c++-8.3.1-5.1.el8.x86_64 is already installed.
Dependencies resolved.
Nothing to do.
Complete!
#环境配置
[root@zhang redis-6.0.6]# make
redis默认的安装路径/usr/local/bin
进入安装目录创建一个自己的配置文件目录
并把原生的redis.conf复制到自定义配置目录以后使用自己的配置文件,原生的配置文件就不需要更改
[root@zhang bin]# ls
chardetect easy_install-3.6 jsondiff luajit redis-check-aof
cloud-id easy_install-3.8 jsonpatch luajit-2.0.4 redis-check-rdb
cloud-init jemalloc-config jsonpointer mcrypt redis-cli
cloud-init-per jemalloc.sh jsonschema mdecrypt redis-sentinel
easy_install jeprof libmcrypt-config redis-benchmark redis-server
[root@zhang bin]# mkdir myconfig
[root@zhang bin]# cp /opt/redis-6.0.6/redis.conf ./myconfig/
[root@zhang bin]# cd myconfig/
[root@zhang myconfig]# ls
redis.conf
redis默认不是后台启动的,需要修改配置文件
更改配置文件的 daemonize yes
通过指定的配置文件启动redis服务
[root@zhang bin]# redis-server ./myconfig/redis.conf
30526:C 11 May 2021 22:36:55.205 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
30526:C 11 May 2021 22:36:55.205 # Redis version=6.0.6, bits=64, commit=00000000, modified=0, pid=30526, just started
30526:C 11 May 2021 22:36:55.205 # Configuration loaded
连接本机redis服务
[root@zhang bin]# redis-cli -p 6379
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>
查看redis的进程信息
[root@zhang ~]# ps -ef|grep redis
redis 1464 1 0 May10 ? 00:00:00 /usr/lib/systemd/systemd --user
redis 1494 1464 0 May10 ? 00:00:00 (sd-pam)
redis 1652 1 0 May10 ? 00:06:59 /www/server/redis/src/redis-server 127.0.0.1:6379
root 30594 23805 0 22:37 pts/0 00:00:00 redis-cli -p 6379
root 30840 30784 0 22:41 pts/1 00:00:00 grep --color=auto redis
关闭redis服务
127.0.0.1:6379> shutdown
not connected> exit
#查看进程信息
[root@zhang ~]# ps -ef|grep redis
root 30963 30784 0 22:43 pts/1 00:00:00 grep --color=auto redis
学习参考狂神说java