Ubuntu下搭建Redis服务器

前端之家收集整理的这篇文章主要介绍了Ubuntu下搭建Redis服务器前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

在Ubuntu中搭建Redis服务器

安装

1 安装

sudo apt-get install redis-server

2 启动

redis-server
5617:C 18 Sep 12:57:10.437 # Warning: no config file specified,using the default config. In order to specify a config file use redis-server /path/to/redis.conf
5617:M 18 Sep 12:57:10.437 * Increased maximum number of open files to 10032 (it was originally set to @H_404_26@1024). _._ _.-``__ ''-._ _.-`` `. `_. ''-._ Redis @H_404_26@3.0@H_404_26@.6 (@H_404_26@00000000/@H_404_26@0) @H_404_26@64 bit .-`` .-```. ```\/ _.,_ ''-._ ( ',.-` | `,) Running in standalone mode |`-._`-...-` __...-.``-._|'` _.-'| Port: 6379 | `-._ `._ / _.-' | PID: 5617 `-._ `-._ `-./ _.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | http://redis.io `-._ `-._`-.__.-'_.-' _.-' |`-._`-._ `-.__.-' _.-'_.-'| | `-._`-._ _.-'_.-' | `-._ `-._`-.__.-'_.-' _.-' `-._ `-.__.-' _.-' `-._ _.-' `-.__.-' @H_404_26@5617:M @H_404_26@18 Sep @H_404_26@12:@H_404_26@57:@H_404_26@10.438 # WARNING: The TCP backlog setting of @H_404_26@511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of @H_404_26@128. @H_404_26@5617:M @H_404_26@18 Sep @H_404_26@12:@H_404_26@57:@H_404_26@10.438 # Server started,Redis version @H_404_26@3.0@H_404_26@.6 @H_404_26@5617:M @H_404_26@18 Sep @H_404_26@12:@H_404_26@57:@H_404_26@10.438 # WARNING overcommit_memory is set to @H_404_26@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. @H_404_26@5617:M @H_404_26@18 Sep @H_404_26@12:@H_404_26@57:@H_404_26@10.438 # 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. @H_404_26@5617:M @H_404_26@18 Sep @H_404_26@12:@H_404_26@57:@H_404_26@10.438 * DB loaded from disk: @H_404_26@0.000 seconds @H_404_26@5617:M @H_404_26@18 Sep @H_404_26@12:@H_404_26@57:@H_404_26@10.438 * The server is now ready to accept connections on port @H_404_26@6379

3 启动客户端

redis-cli
127.0.0.1:6379> ping
PONG

4 检查 Redis 服务器系统进程

ps -aux|grep redis
ubuntu    @H_404_26@5617  @H_404_26@0.0  @H_404_26@0.7  @H_404_26@38856  @H_404_26@7884 pts/@H_404_26@0    Sl+  @H_404_26@12:@H_404_26@57   @H_404_26@0:@H_404_26@01 redis-server *:@H_404_26@6379
ubuntu    @H_404_26@5707  @H_404_26@0.0  @H_404_26@0.0  @H_404_26@12944   @H_404_26@976 pts/@H_404_26@1    S+   @H_404_26@13:@H_404_26@22   @H_404_26@0:@H_404_26@00 grep redis

5 通过端口检查 Redis 服务器状态

netstat -nlt|grep 6379
tcp        @H_404_26@0      @H_404_26@0 @H_404_26@0.@H_404_26@0.@H_404_26@0.@H_404_26@0:@H_404_26@6379            @H_404_26@0.@H_404_26@0.@H_404_26@0.@H_404_26@0:*               LISTEN     
tcp6       @H_404_26@0      @H_404_26@0 :::@H_404_26@6379                 :::*                    LISTEN

6 通过启动命令检查 Redis 服务器状态

sudo /etc/init.d/redis-server status
redis-server is running

配置

1 设置登录密码

# 取消注释requirepass
requirepass your_password
@H_401_403@2 取消登录IP限制
# 注释bind
# bind 127.0.0.1
原文链接:https://www.f2er.com/ubuntu/351245.html

猜你在找的Ubuntu相关文章