10

Nacos2.x安装教程(Windows/Linux单机版 + Linux集群版)

 3 years ago
source link: https://maxqiu.com/article/detail/103
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client
Nacos2.x安装教程(Windows/Linux单机版 + Linux集群版)
Nacos2.x安装教程(Windows/Linux单机版 + Linux集群版)

2021-06-07  Windows  Linux  Nacos

本文档整理自教程:

Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。

Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。 Nacos 是构建以“服务”为中心的现代应用架构 (例如微服务范式、云原生范式) 的服务基础设施。

替代Spring Cloud Netflix EurekaSpring Cloud ConfigSpring Cloud Bus

打开GitHub地址的Releases页面,选择Latest release版本,往下翻到AssetsWindows下载xxx.zip版,Linux下载xxx.tar.gz版。例如:

一般用于测试和单机试用。

系统必须安装jdk并设置环境变量,最低jdk8,参考:

将下载的安装包进行解压,

  • Windows:使用压缩工具解压
  • Linux:执行tar -zxf xxx.tar.gz进行解压

解压后移动到自定义的位置。例如:

  • Windows:安装在C盘根目录下
  • Linux:安装在/usr/local/下,执行mv nacos /usr/local/即可

使用MySQL数据源

测试环境非必要,搭建集群环境则必须要改。MySQL最低要求5.6.5+。参考:

  1. 连接MySQL,创建一个库,例如:nacos,推荐再单独创建一个用户并单独授权刚刚创建的库
  2. 使用mysqldump或者其他图形工具导入conf目录下的nacos-mysql.sql
  3. 编辑conf目录下的application.properties文件,在文件结尾添加如下内容。注意:URL、用户名、密码不要写错
  1. spring.datasource.platform=mysql
  2. db.num=1
  3. db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&serverTimezone=UTC
  4. db.user=nacos
  5. db.password=123456
  • Windows:打开cmd,进入nacos目录,执行.\bin\startup.cmd -m standalone
  • Linux:执行cd /usr/local/nacos/进入nacos目录,执行./bin/startup.sh -m standalone启动

浏览器打开http://[ip]:8848/nacos/打开网页,默认用户名密码均为nacos

一般用于生产环境,确保高可用。推荐使用Linux系统

官网架构图:

而安装尚硅谷阳哥的讲解,架构图应该是这样的:

本文着重介绍Nacos的集群配置,Nginx的集群暂不做介绍,仅做一个Nginx单机版

准备三台服务器

  • 192.168.220.101
  • 192.168.220.102
  • 192.168.220.103

按照单机版环境安装使用MySQL数据源的步骤准备好。注意:所有节点的MySQL连接同一个数据库

在每个节点conf目录下新建cluster.conf文件,并写入如下内容

  1. 192.168.220.101:8848
  2. 192.168.220.102:8848
  3. 192.168.220.103:8848

每个节点分别执行./bin/startup.sh

Nginx负载均衡

在任意一台服务器上或者再找一台服务器安装Nginx服务。参考:

安装完成后修改nginx.conf配置文件,添加如下内容,端口可自定义

  1. upstream cluster{
  2. server 192.168.220.101:8848;
  3. server 192.168.220.102:8848;
  4. server 192.168.220.103:8848;
  5. }
  6. server {
  7. listen 8888;
  8. location / {
  9. proxy_pass http://cluster;
  10. }
  11. }

浏览器打开http://[nginx_ip]:8888/nacos/打开网页,默认用户名密码均为nacos


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK