Redis安装部署

1.关闭防火墙及selinux
[root@lwq-service ~]# systemctl stop firewalld
[root@lwq-service ~]# systemctl disable firewalld
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@lwq-service ~]# vim /etc/selinux/config
[root@lwq-service ~]# setenforce 0

2.安装编译工具
[root@lwq-service ~]# yum -y install gcc gcc-c++

3.下载redis的安装包并解压至/usr/local
[root@lwq-service ~]# cd /usr/src/
[root@lwq-service src]# wget http://download.redis.io/releases/redis-4.0.14.tar.gz
–2019-09-28 09:22:39-- http://download.redis.io/releases/redis-4.0.14.tar.gz
正在解析主机 download.redis.io (download.redis.io)… 109.74.203.151
正在连接 download.redis.io (download.redis.io)|109.74.203.151|:80… 已连接。
已发出 HTTP 请求,正在等待回应… 302 Found
位置:http://64.123.28.151/files/3061000000F2538E/download.redis.io/releases/redis-4.0.14.tar.gz [跟随至新的 URL]
–2019-09-28 09:22:39-- http://64.123.28.151/files/3061000000F2538E/download.redis.io/releases/redis-4.0.14.tar.gz
正在连接 64.123.28.151:80… 已连接。
已发出 HTTP 请求,正在等待回应… 200 OK
长度:1740967 (1.7M) [application/octet-stream]
正在保存至: “redis-4.0.14.tar.gz”

100%[======================================================>] 1,740,967 10.5MB/s 用时 0.2s

2019-09-28 09:22:39 (10.5 MB/s) - 已保存 “redis-4.0.14.tar.gz” [1740967/1740967])

[root@lwq-service src]# ls
debug kernels redis-4.0.14.tar.gz
[root@lwq-service src]# tar xf redis-4.0.14.tar.gz -C /usr/local/

4.编译redis
[root@lwq-service src]# cd /usr/local/redis-4.0.14/
[root@lwq-service redis-4.0.14]# make
[root@lwq-service redis-4.0.14]# cd src/
[root@lwq-service src]# make install
CC Makefile.dep

Hint: It’s a good idea to run ‘make test’ ; )

INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install

[root@lwq-service src]# cd
[root@lwq-service ~]# ls /usr/local/bin/
redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-sentinel redis-server

5.把参数文件拷贝到/usr/local/etc/redis目录下,这个目录需要自己手工创建
[root@lwq-service ~]# mkdir /usr/local/etc/redis
[root@lwq-service ~]# cp /usr/local/redis-4.0.14/redis.conf /usr/local/etc/redis/
[root@lwq-service ~]# ls /usr/local/etc/redis/
redis.conf

6.可以which命令,看是否找到,能找到,可以执行
[root@lwq-service ~]# which redis-server
/usr/local/bin/redis-server

7.直接启动界面如下
[root@lwq-service ~]# redis-server
41342:C 28 Sep 09:27:54.414 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
41342:C 28 Sep 09:27:54.414 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=41342, just started
41342:C 28 Sep 09:27:54.414 # Warning: no config file specified, using the default config. In order to specify a config file use redis-server /path/to/redis.conf
41342:M 28 Sep 09:27:54.415 * Increased maximum number of open files to 10032 (it was originally set to 1024).
.
.-__ ''-._ _.- .. ‘’-._ Redis 4.0.14 (00000000/0) 64 bit
.-.-```. ```\/ _.,_ ''-._ ( ' , .-` | `, ) Running in standalone mode |`-._`-...-` __...-.-.|’_.-'| Port: 6379 |-. ._ / _.-' | PID: 41342-._ -._-./ .-’ .-’
|-._-.
-.__.-' _.-'_.-'| |-.
-._ _.-'_.-' | http://redis.io-._ -._-..-’.-’ .-’
|-._-.
-.__.-' _.-'_.-'| |-.
-._ _.-'_.-' |-._ -._-.
.-’_.-’ _.-’
-._-..-’ _.-’
-._ _.-'-.
.-’

41342:M 28 Sep 09:27:54.439 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
41342:M 28 Sep 09:27:54.439 # Server initialized
41342:M 28 Sep 09:27:54.439 # 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.
41342:M 28 Sep 09:27:54.440 # 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.
41342:M 28 Sep 09:27:54.440 * Ready to accept connections
^C41342:signal-handler (1569634105) Received SIGINT scheduling shutdown…
41342:M 28 Sep 09:28:25.772 # User requested shutdown…
41342:M 28 Sep 09:28:25.773 * Saving the final RDB snapshot before exiting.
41342:M 28 Sep 09:28:25.874 * DB saved on disk
41342:M 28 Sep 09:28:25.874 # Redis is now ready to exit, bye bye…
#注意:这里直接执行Redis-server 启动的Redis服务,是在前台直接运行的(效果如上图),也就是说,执行完该命令后,如果Lunix关闭当前会话,则Redis服务也随即关闭。正常情况下,启动Redis服务需要从后台启动,并且指定启动配置文件。

8.后台启动redis
编辑配置文件,将daemonize属性改为yes(表明需要在后台运行)
[root@lwq-service ~]# sed -ri ‘s/(daemonize) no/\1 yes/g’ /usr/local/etc/redis/redis.conf
[root@lwq-service ~]# vim /usr/local/etc/redis/redis.conf

9.再次启动redis服务,并指定启动服务配置文件
[root@lwq-service ~]# redis-server /usr/local/etc/redis/redis.conf
41454:C 28 Sep 09:34:02.864 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
41454:C 28 Sep 09:34:02.864 # Redis version=4.0.14, bits=64, commit=00000000, modified=0, pid=41454, just started
41454:C 28 Sep 09:34:02.864 # Configuration loaded

10.服务启动成功后,执行redis-cli启动redis客户端,查看端口号
[root@lwq-service ~]# redis-cli
127.0.0.1:6379> exit
[root@lwq-service ~]# ss -antl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 127.0.0.1:6379 :
LISTEN 0 128 :111 :
LISTEN 0 5 192.168.122.1:53 :
LISTEN 0 128 :22 :
LISTEN 0 128 127.0.0.1:631 :
LISTEN 0 100 127.0.0.1:25 :
LISTEN 0 128 127.0.0.1:6010 :
LISTEN 0 128 :::111 :::

LISTEN 0 128 :::22 :::

LISTEN 0 128 ::1: 631 ::: *
LISTEN 0 100 ::1:25 ::: *
LISTEN 0 128 ::1:6010 ::: *
[root@lwq-service ~]# redis-cli
127.0.0.1:6379> set lwq money
OK
127.0.0.1:6379> get lwq
“money”
127.0.0.1:6379> exit
#到这里redis部署完成

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值