Redis二进制编译安装教程
一、Redis编译安装教程
(1)安装包下载与解压
GitHub Redis下载地址:https://github.com/redis/redis/tags Redis安装包下载地址:https://download.redis.io/releases/
[root@redis-v1 ~]# yum -y install make gcc* [root@redis-v1 ~]# wget http://download.redis.io/releases/redis-5.0.3.tar.gz [root@redis-v1 ~]# tar -zxvf redis-5.0.3.tar.gz [root@redis-v1 ~]# ln -s redis-5.0.3 redis [root@redis-v1 ~]# cd redis/src/ [root@redis-v1 src]# make && make install # 编译完成后,查看redis相关工具 [root@redis-v1 ~]# ll /usr/local/bin/ |grep 'redis' -rwxr-xr-x 1 root root 4366536 Mar 24 20:17 redis-benchmark -rwxr-xr-x 1 root root 8090000 Mar 24 20:17 redis-check-aof -rwxr-xr-x 1 root root 8090000 Mar 24 20:17 redis-check-rdb -rwxr-xr-x 1 root root 4801776 Mar 24 20:17 redis-cli lrwxrwxrwx 1 root root 12 Mar 24 20:17 redis-sentinel -> redis-server -rwxr-xr-x 1 root root 8090000 Mar 24 20:17 redis-server
(2)可执行文件说明
可执行文件 说明
redis-server Redis服务器
redis-cli Redis命令行客户端
redis-benchmark Redis性能测试
redis-check-aof AOF文件修复工具
redis-check-dump RDB文件检查工具
redis-sentinel sentinel服务器(2.8以后)
二、Redis三种启动方式
2.1 最简单方式启动Redis
[root@redis-v1 ~]# redis-server 981:C 24 Mar 2022 20:27:35.912 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 981:C 24 Mar 2022 20:27:35.912 # Redis version=5.0.3, bits=64, commit=00000000, modified=0, pid=981, just started 981:C 24 Mar 2022 20:27:35.912 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf 981:M 24 Mar 2022 20:27:35.914 * Increased maximum number of open files to 10032 (it was originally set to 1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis 5.0.3 (00000000/0) 64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 981 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' 981:M 24 Mar 2022 20:27:35.916 # Server initialized 981:M 24 Mar 2022 20:27:35.916 # 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. 981:M 24 Mar 2022 20:27:35.916 # 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. 981:M 24 Mar 2022 20:27:35.916 * Ready to accept connections
注:后台运行可执行nohup redis-server &
# 服务验证 [root@redis-v1 ~]# ps -ef |grep redis root 1055 27629 0 20:28 pts/0 00:00:00 redis-server *:6379 root 1109 27629 0 20:29 pts/0 00:00:00 grep --color=auto redis [root@redis-v1 ~]# netstat -antulp |grep redis tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 1055/redis-server * tcp6 0 0 :::6379 :::* LISTEN 1055/redis-server * [root@redis-v1 ~]# redis-cli -h localhost -p 6379 ping PONG # redis密码设置 localhost:6379> config set requirepass 123456 OK localhost:6379> AUTH 123456 OK # 禁用登录密码校验 localhost:6379> config set requirepass "" OK
2.2 动态参数启动
[root@redis-v1 ~]# nohup redis-server --port 6380 &
2.3 配置文件启动
[root@redis-v1 ~]# mkdir /data/redis7000 [root@redis-v1 ~]# cd redis [root@redis-v1 redis]# vim redis-7000.conf bind 0.0.0.0 protected-mode no # 免密码登录 port 7000 daemonize yes # 以守护进程的方式启动 pidfile "/var/run/redis-7000.pid" logfile "7000.log" dbfilename "dump-7000.rdb" dir "/data/redis7000/" slave-read-only yes appendfilename "appendonly-7000.aof" [root@redis-v1 ~]# redis-server redis-7000.conf [root@redis-v1 redis]# netstat -antulp |grep 7000 tcp 0 0 0.0.0.0:7000 0.0.0.0:* LISTEN 2731/redis-server * tcp6 0 0 :::7000 :::* LISTEN 2731/redis-server *
注:生产环境可以选择配置文件启动,一台物理机可以部署多个redis实例。单机多实例配置文件可以用端口分开。
作者:UStarGao
链接:https://www.starcto.com/redis/281.html
来源:STARCTO
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
UCloud云平台推荐
随便看看
- 2022-04-02Docker可视化管理工具-Portainer
- 2022-08-18MySQL general_log日志抓取业务SQL语句
- 2021-03-05MySQL 用户与权限管理
- 2021-09-13开源为知笔记容器化部署
- 2021-11-02开源网盘系统nextcloud容器化部署