在华为鲲鹏OpenEuler20.03系统上安装Redis, Zookeeper, Nginx

本文涉及的产品
云服务器 ECS,每月免费额度280元 3个月
云数据库 Redis 版,社区版 2GB
推荐场景:
搭建游戏排行榜
云服务器ECS,u1 2核4GB 1个月
简介: 在华为鲲鹏OpenEuler20.03系统上安装Redis, Zookeeper, Nginx

背景


这里实验用的华为云鲲鹏服务器配置如下:


Huawei Kunpeng 920 2.6GHz
4vCPUs | 8GB
openEuler 20.03 64bit with ARM

连接机器后,先查看系统相关信息,注意这里是 aarch64 的,后续软件包也需要是 aarch64 版本的。

# 查看系统内核信息
[root@ecs-kunpeng-0005 ~]# uname -a
Linux ecs-kunpeng-0005 4.19.90-2003.4.0.0036.oe1.aarch64 #1 SMP Mon Mar 23 19:06:43 UTC 2020 aarch64 aarch64 aarch64 GNU/Linux
# 查看系统版本信息
[root@ecs-kunpeng-0005 ~]# cat /etc/os-release
NAME="openEuler"
VERSION="20.03 (LTS)"
ID="openEuler"
VERSION_ID="20.03"
PRETTY_NAME="openEuler 20.03 (LTS)"
ANSI_COLOR="0;31"


安装Redis


  • 下载安装


  1. 下载:https://redis.io/download


  1. 上传:redis-6.2.3.tar.gz到服务器
# 解压
[root@ecs-kunpeng-0006 local]# tar -xvf redis-6.2.3.tar.gz
[root@ecs-kunpeng-0006 local]# mv redis-6.2.3 redis
[root@ecs-kunpeng-0006 local]# cd redis
# 编译
[root@ecs-kunpeng-0006 redis]# make
# 安装
[root@ecs-kunpeng-0006 redis]# make PREFIX=/usr/local/redis install
# 指定配置文件自动,这里配置了端口号为6380
[root@ecs-kunpeng-0006 redis]# bin/redis-server ./redis.conf
612260:C 17 May 2021 14:36:19.264 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
612260:C 17 May 2021 14:36:19.264 # Redis version=6.2.3, bits=64, commit=00000000, modified=0, pid=612260, just started
612260:C 17 May 2021 14:36:19.264 # Configuration loaded
612260:M 17 May 2021 14:36:19.264 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.3 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6380
 |    `-._   `._    /     _.-'    |     PID: 612260
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               
612260:M 17 May 2021 14:36:19.265 # Server initialized
612260:M 17 May 2021 14:36:19.265 # WARNING Your kernel has a bug that could lead to data corruption during background save. Please upgrade to the latest stable kernel.
612260:M 17 May 2021 14:36:19.265 # Redis will now exit to prevent data corruption. Note that it is possible to suppress this warning by setting the following config: ignore-warnings ARM64-COW-BUG

上面 Redis Server 启动后又停止了,并且报了一个警告: Your kernel has a bug that could lead to data corruption during background save. Please upgrade to the latest stable kernel. 并且,给了解决的建议,即在 redis.conf 中取消这最后一条注释: ignore-warnings ARM64-COW-BUG

# 编辑vi redis.conf ,取消最后一行相关注释
[root@ecs-kunpeng-0006 redis]# vi redis.conf 
ignore-warnings ARM64-COW-BUG
# 尝试启动
[root@ecs-kunpeng-0006 redis]# bin/redis-server ./redis.conf
615117:C 17 May 2021 14:36:47.889 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
615117:C 17 May 2021 14:36:47.889 # Redis version=6.2.3, bits=64, commit=00000000, modified=0, pid=615117, just started
615117:C 17 May 2021 14:36:47.889 # Configuration loaded
615117:M 17 May 2021 14:36:47.890 * monotonic clock: POSIX clock_gettime
                _._                                                  
           _.-``__ ''-._                                             
      _.-``    `.  `_.  ''-._           Redis 6.2.3 (00000000/0) 64 bit
  .-`` .-```.  ```\/    _.,_ ''-._                                  
 (    '      ,       .-`  | `,    )     Running in standalone mode
 |`-._`-...-` __...-.``-._|'` _.-'|     Port: 6380
 |    `-._   `._    /     _.-'    |     PID: 615117
  `-._    `-._  `-./  _.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |           https://redis.io       
  `-._    `-._`-.__.-'_.-'    _.-'                                   
 |`-._`-._    `-.__.-'    _.-'_.-'|                                  
 |    `-._`-._        _.-'_.-'    |                                  
  `-._    `-._`-.__.-'_.-'    _.-'                                   
      `-._    `-.__.-'    _.-'                                       
          `-._        _.-'                                           
              `-.__.-'                                               
615117:M 17 May 2021 14:36:47.890 # Server initialized
615117:M 17 May 2021 14:36:47.891 # WARNING Your kernel has a bug that could lead to data corruption during background save. Please upgrade to the latest stable kernel.
615117:M 17 May 2021 14:36:47.891 * Ready to accept connections

启动成功๑乛◡乛๑

  • 远程访问
# 注释第75行的bind,同时将94行的protected-mode由yes改为no
[root@ecs-kunpeng-0006 redis]# vi redis.conf
75 #bind 127.0.0.1 -::1
94 protected-mode no
  • 后台启动
# 将257行的daemonize由no改为yes
[root@ecs-kunpeng-0006 redis]# vi redis.conf
257 daemonize yes
  • 开启认证
# 将901行的requirepass开启,改为自己的密码
[root@ecs-kunpeng-0006 redis]# vi redis.conf
901 requirepass your-guess
  • 停止服务
# 无密码停止服务
[root@ecs-kunpeng-0006 redis]# bin/redis-cli -h 127.0.0.1 -p 6380 shutdown
# 带密码停止服务
[root@ecs-kunpeng-0006 redis]# bin/redis-cli -a 密码 -h 127.0.0.1 -p 6380 shutdown
  • 配置日志

以后台方式启动后,发现 Redis 的日志完全没了。。所以需要配置下日志路径。

[root@ecs-kunpeng-0006 redis]# vi redis.conf
# Specify the log file name. Also the empty string can be used to force
# Redis to log on the standard output. Note that if you use standard
# output for logging but daemonize, logs will be sent to /dev/null
logfile ""
改为:
logfile "/usr/local/redis/log/redis.log"
# 需要手动创建目录,redis.log文件在下次启动时则会自动创建
[root@ecs-kunpeng-0006 redis]# mkdir log
# 启动即可
[root@ecs-kunpeng-0006 redis]# bin/redis-server ./redis.conf

Note: Redis 默认端口为 6379 ,我这里改了端口为 6380


安装Zookeeper


# 下载
[root@ecs-kunpeng-0001 local]# wget https://mirrors.bfsu.edu.cn/apache/zookeeper/zookeeper-3.6.3/apache-zookeeper-3.6.3-bin.tar.gz
# 解压
[root@ecs-kunpeng-0001 local]# tar -xvf apache-zookeeper-3.6.3-bin.tar.gz
[root@ecs-kunpeng-0001 local]# mv apache-zookeeper-3.6.3-bin zookeeper
[root@ecs-kunpeng-0001 zookeeper]# cp conf/zoo_sample.cfg conf/zoo.cfg
# 配置数据与日志目录,zk在第一次启动时会自动创建
[root@ecs-kunpeng-0001 zookeeper]# vi conf/zoo.cfg 
dataDir=/usr/local/zookeeper/data
dataLogDir=/usr/local/zookeeper/log
# 尝试启动
[root@ecs-kunpeng-0001 zookeeper]# bin/zkServer.sh start
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Starting zookeeper ... STARTED
# 查看状态
[root@ecs-kunpeng-0001 zookeeper]# bin/zkServer.sh status
/usr/bin/java
ZooKeeper JMX enabled by default
Using config: /usr/local/zookeeper/bin/../conf/zoo.cfg
Client port found: 2181. Client address: localhost. Client SSL: false.
Mode: standalone


安装Nginx


配置好源后,这里使用 yum 或者 dnf 来安装 Nginx

# yum安装nginx
[root@ecs-kunpeng-0001 ~]# yum install nginx
[root@ecs-kunpeng-0001 ~]# nginx -v
nginx version: nginx/1.16.1
# 配置服务
[root@ecs-kunpeng-0001 ~]# vi /etc/nginx/nginx.conf
# 加载配置
[root@ecs-kunpeng-0001 ~]# nginx -s reload
nginx: [warn] could not build optimal types_hash, you should increase either types_hash_max_size: 2048 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size

在重新加载配置时有个警告:

nginx: [warn] could not build optimal types_hash, you should increase either types_hash_max_size: 2048 or types_hash_bucket_size: 64; ignoring types_hash_bucket_size
# 编辑vi /etc/nginx/nginx.conf,在http下增加配置:types_hash_bucket_size 1024;
[root@ecs-kunpeng-0001 ~]# vi /etc/nginx/nginx.conf
types_hash_bucket_size 1024
# 测试配置
[root@ecs-kunpeng-0001 ~]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
# 查看Nginx状态,active
[root@ecs-kunpeng-0001 ~]# service nginx status

image.png


相关实践学习
一小时快速掌握 SQL 语法
本实验带您学习SQL的基础语法,快速入门SQL。
7天玩转云服务器
云服务器ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,可降低 IT 成本,提升运维效率。本课程手把手带你了解ECS、掌握基本操作、动手实操快照管理、镜像管理等。了解产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
10天前
|
NoSQL Linux Redis
linux 下和win下安装redis 并添加开机自启 图文详解
linux 下和win下安装redis 并添加开机自启 图文详解
15 0
|
1月前
|
NoSQL Linux Redis
Linux系统中安装redis+redis后台启动+常见相关配置
Linux系统中安装redis+redis后台启动+常见相关配置
|
18天前
|
NoSQL Linux Redis
Linux安装Redis
Linux安装Redis
26 0
|
30天前
|
NoSQL 关系型数据库 MySQL
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
Docker安装详细步骤及相关环境安装配置(mysql、jdk、redis、自己的私有仓库Gitlab 、C和C++环境以及Nginx服务代理)
193 0
|
1月前
|
NoSQL Java 应用服务中间件
使用innoSetup将mysql+nginx+redis+jar包打包成windows安装包
使用innoSetup将mysql+nginx+redis+jar包打包成windows安装包
使用innoSetup将mysql+nginx+redis+jar包打包成windows安装包
|
8天前
|
NoSQL Linux Redis
06- 你们使用Redis是单点还是集群 ? 哪种集群 ?
**Redis配置:** 使用哨兵集群,结构为1主2从,加上3个哨兵节点,总计分布在3台Linux服务器上,提供高可用性。
17 0
|
17天前
|
负载均衡 监控 NoSQL
Redis的集群方案有哪些?
Redis集群包括主从复制(基础,手动故障恢复)、哨兵模式(自动高可用)和Redis Cluster(官方分布式解决方案,自动分片和容错)。此外,还有如Codis、Redisson和Twemproxy等第三方工具用于代理和负载均衡。选择方案需考虑应用场景、数据规模和并发需求。
17 2
|
22天前
|
NoSQL Redis
Redis集群(六):集群常用命令及说明
Redis集群(六):集群常用命令及说明
15 0
|
2月前
|
运维 NoSQL 算法
Redis-Cluster 与 Redis 集群的技术大比拼
Redis-Cluster 与 Redis 集群的技术大比拼
46 0
|
17天前
|
NoSQL Java 测试技术
面试官:如何搭建Redis集群?
**Redis Cluster** 是从 Redis 3.0 开始引入的集群解决方案,它分散数据以减少对单个主节点的依赖,提升读写性能。16384 个槽位分配给节点,客户端通过槽位信息直接路由请求。集群是无代理、去中心化的,多数命令直接由节点处理,保持高性能。通过 `create-cluster` 工具快速搭建集群,但适用于测试环境。在生产环境,需手动配置文件,启动节点,然后使用 `redis-cli --cluster create` 分配槽位和从节点。集群动态添加删除节点、数据重新分片及故障转移涉及复杂操作,包括主从切换和槽位迁移。
29 0
面试官:如何搭建Redis集群?