Nacos2.x安装教程(Windows/Linux单机版 + Linux集群版)
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.
2021-06-07 Windows Linux Nacos
本文档整理自教程:
Nacos 致力于帮助您发现、配置和管理微服务。Nacos 提供了一组简单易用的特性集,帮助您快速实现动态服务发现、服务配置、服务元数据及流量管理。
Nacos 帮助您更敏捷和容易地构建、交付和管理微服务平台。 Nacos 是构建以“服务”为中心的现代应用架构 (例如微服务范式、云原生范式) 的服务基础设施。
替代Spring Cloud Netflix Eureka
、Spring Cloud Config
、Spring Cloud Bus
打开GitHub
地址的Releases
页面,选择Latest release
版本,往下翻到Assets
,Windows
下载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+
。参考:
- 连接
MySQL
,创建一个库,例如:nacos
,推荐再单独创建一个用户并单独授权刚刚创建的库 - 使用
mysqldump
或者其他图形工具导入conf
目录下的nacos-mysql.sql
- 编辑
conf
目录下的application.properties
文件,在文件结尾添加如下内容。注意:URL、用户名、密码不要写错
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://127.0.0.1:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&serverTimezone=UTC
db.user=nacos
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
文件,并写入如下内容
192.168.220.101:8848
192.168.220.102:8848
192.168.220.103:8848
每个节点分别执行./bin/startup.sh
Nginx负载均衡
在任意一台服务器上或者再找一台服务器安装Nginx
服务。参考:
安装完成后修改nginx.conf
配置文件,添加如下内容,端口可自定义
upstream cluster{
server 192.168.220.101:8848;
server 192.168.220.102:8848;
server 192.168.220.103:8848;
}
server {
listen 8888;
location / {
proxy_pass http://cluster;
}
}
浏览器打开http://[nginx_ip]:8888/nacos/
打开网页,默认用户名密码均为nacos
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK