当前位置:网站首页>搭建【Redis in CentOS7.x】
搭建【Redis in CentOS7.x】
2022-07-06 17:46:00 【臧馆长】
准备
这里使用 redis-6.2.6 版本
安装
下载并解压到安装目录
[[email protected] local]# wget https://download.redis.io/releases/redis-6.2.6.tar.gz
[[email protected] local]# tar -zxf redis-6.2.6.tar.gz
[[email protected] local]# mv redis-6.2.6 redis
[[email protected] local]# ll
总用量 2424
drwxrwxr-x. 7 root root 4096 10月 4 2021 redis
-rw-r--r--. 1 root root 2476542 10月 4 2021 redis-6.2.6.tar.gz
[[email protected] local]# cd redis
检查编译环境无则安装
[[email protected] redis]# rpm -q gcc gcc-c++
未安装软件包 gcc
未安装软件包 gcc-c++
[[email protected] redis]# yum -y install gcc gcc-c++
源码编译
# 注意执行编译的工作目录必须为redis
# make install默认会把bin放到/usr/local/bin/下面,需要加上PREFIX=/usr/local/redis/指定目录
[[email protected] redis]# make && make install PREFIX=/usr/local/redis/
cd src && make install
make[1]: 进入目录“/usr/local/redis/src”
修改配置
# 日志路径
[[email protected] redis]# mkdir log
# 修改配置
[[email protected] redis]# cp redis.conf redis.my.conf
[[email protected] redis]# vi redis.my.conf
bind 0.0.0.0
protected-mode no
daemonize yes
ogfile "/usr/local/redis/log/redis.log"
# 创建服务
[[email protected] redis]# vi /usr/lib/systemd/system/redisd.service
[Unit]
Description=redis
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/redis/bin/redis-server /usr/local/redis/redis.my.conf
ExecReload=/usr/local/redis/bin/redis-server -s reload
ExecStop=/usr/local/redis/bin/redis-server -s stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
启动服务
# 查看当前服务状态如下
[[email protected] redis]# systemctl status redisd
● redisd.service - redis
Loaded: loaded (/usr/lib/systemd/system/redisd.service; disabled; vendor preset: disabled)
Active: inactive (dead)
# 加入开机启动项
[[email protected] redis]# systemctl enable redisd
# 启动服务
[[email protected] redis]# systemctl start redisd
# 再次查看当前服务状态
[[email protected] redis]# systemctl status redisd
● redisd.service - redis
Loaded: loaded (/usr/lib/systemd/system/redisd.service; enabled; vendor preset: disabled)
Active: active (running) since 五 2022-05-13 13:05:55 CST; 27s ago
Main PID: 25766 (redis-server)
CGroup: /system.slice/redisd.service
└─25766 /usr/local/redis/bin/redis-server 0.0.0.0:6379
- 常用命令:
- systemctl start redisd(启动redis服务)
- systemctl restart redisd(重启redis服务)
- systemctl stop redisd(停止redis服务)
- systemctl enable redisd(添加开机自启)
- systemctl disable redisd(禁止开机自启)
- systemctl status redisd(查看状态)
开启防火墙端口
[[email protected] redis]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since 五 2022-05-13 10:59:02 CST; 2h 42min ago
Docs: man:firewalld(1)
Main PID: 670 (firewalld)
CGroup: /system.slice/firewalld.service
└─670 /usr/bin/python2 -Es /usr/sbin/firewalld --nofork --nopid
[[email protected] redis]# firewall-cmd --zone=public --add-port=6379/tcp --permanent
success
[[email protected] redis]# firewall-cmd --reload
success
[[email protected] redis]# firewall-cmd --list-ports
6379/tcp
测试
[[email protected] redis]# ./bin/redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379> set name zangh
OK
127.0.0.1:6379> get name
"zangh"
边栏推荐
- 界面控件DevExpress WinForms皮肤编辑器的这个补丁,你了解了吗?
- 「笔记」折半搜索(Meet in the Middle)
- Gazebo的安装&与ROS的连接
- C # method of calculating lunar calendar date 2022
- 【芯片方案设计】脉搏血氧仪
- Docker method to install MySQL
- The cost of returning tables in MySQL
- [Niuke] [noip2015] jumping stone
- 剑指 Offer II 035. 最小时间差-快速排序加数据转换
- Analysis of mutex principle in golang
猜你喜欢

Make Jar, Not War

身体质量指数程序,入门写死的小程序项目

Go zero micro service practical series (IX. ultimate optimization of seckill performance)

Gazebo的安装&与ROS的连接

Lldp compatible CDP function configuration

JTAG principle of arm bare board debugging
![[signal and system]](/img/aa/a65d6da1d1d9410254ca7b775e24a6.png)
[signal and system]
![[hfctf2020]babyupload session parsing engine](/img/db/6003129bc16f943ad9868561a2d5dc.png)
[hfctf2020]babyupload session parsing engine

boot - prometheus-push gateway 使用

HMM notes
随机推荐
C# 计算农历日期方法 2022
Receive user input, height BMI, BMI detection small business entry case
数据手册中的词汇
C语言实例_5
docker 方法安装mysql
c语言—数组
前置机是什么意思?主要作用是什么?与堡垒机有什么区别?
pytorch之数据类型tensor
Send template message via wechat official account
NEON优化:性能优化常见问题QA
2022 Google CTF SEGFAULT LABYRINTH wp
Informatics Orsay Ibn YBT 1172: find the factorial of n within 10000 | 1.6 14: find the factorial of n within 10000
JTAG debugging experience of arm bare board debugging
移植DAC芯片MCP4725驱动到NUC980
The MySQL database in Alibaba cloud was attacked, and finally the data was found
Asset security issues or constraints on the development of the encryption industry, risk control + compliance has become the key to breaking the platform
golang中的WaitGroup实现原理
Informatics Olympiad YBT 1171: factors of large integers | 1.6 13: factors of large integers
云呐|工单管理软件,工单管理软件APP
ESP Arduino (IV) PWM waveform control output