Nacos集群

DevOps Nacos评论2,209字数 4216阅读14分3秒阅读模式

预备环境准备

Nacos 依赖 Java 环境来运行。请确保是在以下版本环境中安装使用.

  1. 64 bit OS,支持 Linux/Unix/Mac/Windows,推荐选用 Linux/Unix/Mac。
  2. 64 bit JDK 1.8+;下载 & 配置

安装java

下载二进制包

三个节点同时下载
wget https://github.com/alibaba/nacos/releases/download/2.2.0/nacos-server-2.2.0.tar.gz
三个节点同时解压
tar zxf nacos-server-2.2.0.tar.gz  -C /usr/local/

配置三个节点到nacos

[root@bogon ~]# cd /usr/local/nacos/conf/
[root@bogon conf]# cp cluster.conf.example cluster.conf
[root@bogon conf]# vim cluster.conf
192.168.1.181:8848
192.168.1.182:8848
192.168.1.183:8848

任意一个节点安装mysql

[root@bogon ~]#  vim /etc/yum.repos.d/mysql.repo
[mysql]
name= mysql8.0
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-8.0-community-el7-x86_64/
enable=1
gpgcheck=0
[root@bogon ~]# yum clean all && yum makecache
[root@bogon ~]# yum install mysql-community-server -y
初始化数据库
[root@bogon ~]# systemctl enable --now mysqld
[root@bogon ~]# grep "password" /var/log/mysqld.log 
2022-12-21T08:37:27.900081Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: us_YR:6?Ijqc
[root@bogon ~]# mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 8
Server version: 8.0.31

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'XIAOXIN@root2758';
Query OK, 0 rows affected (0.02 sec)

mysql> CREATE USER 'root'@'%' IDENTIFIED BY 'XIAOXIN@root2758' ;
Query OK, 0 rows affected (0.02 sec)

mysql> grant all privileges on *.* to 'root'@'%';
Query OK, 0 rows affected (0.01 sec)

mysql> create  database nacos_config default character set utf8 collate utf8_bin;
Query OK, 1 row affected, 2 warnings (0.01 sec)

mysql> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| nacos_config       |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.01 sec)


mysql> use nacos_config;
Database changed
mysql> source /usr/local/nacos/conf/mysql-schema.sql;
Query OK, 0 rows affected, 3 warnings (0.13 sec)

Query OK, 0 rows affected, 3 warnings (0.01 sec)

Query OK, 0 rows affected, 3 warnings (0.03 sec)

Query OK, 0 rows affected, 3 warnings (0.02 sec)

Query OK, 0 rows affected, 4 warnings (0.00 sec)

Query OK, 0 rows affected, 9 warnings (0.01 sec)

Query OK, 0 rows affected, 4 warnings (0.01 sec)

Query OK, 0 rows affected, 9 warnings (0.01 sec)

Query OK, 0 rows affected, 5 warnings (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 0 rows affected (0.01 sec)

Query OK, 0 rows affected (0.00 sec)

Query OK, 1 row affected (0.08 sec)

Query OK, 1 row affected (0.01 sec)

mysql>

application.properties 配置

  • 三个节点配置信息一致,其他默认
[root@bogon conf]#  grep -v "^$" application.properties | grep -v "^#"
server.servlet.contextPath=/nacos
server.error.include-message=ALWAYS
server.port=8848
spring.datasource.platform=mysql
db.num=1
db.url.0=jdbc:mysql://192.168.1.182:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=XIAOXIN@root2758
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2
nacos.cmdb.dumpTaskInterval=3600
nacos.cmdb.eventTaskInterval=10
nacos.cmdb.labelTaskInterval=300
nacos.cmdb.loadDataAtStart=false
management.metrics.export.elastic.enabled=false
management.metrics.export.influx.enabled=false
server.tomcat.accesslog.enabled=true
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**
nacos.core.auth.system.type=nacos
nacos.core.auth.enabled=false
nacos.core.auth.caching.enabled=true
nacos.core.auth.enable.userAgentAuthWhite=false
nacos.core.auth.server.identity.key=serverIdentity
nacos.core.auth.server.identity.value=security
nacos.core.auth.plugin.nacos.token.expire.seconds=18000
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789
nacos.istio.mcp.server.enabled=false

启动服务

  • 三个节点pwd都启动
[root@bogon bin]# pwd
/usr/local/nacos/bin
[root@bogon bin]# sh startup.sh

验证

  • http://192.168.1.181:8848/nacos/
  • http://192.168.1.182:8848/nacos/
  • http://192.168.1.183:8848/nacos/
  • 默认账号和密码 nacos
  • 看到集群节点绿了。说明成功了。

Nacos集群

继续阅读
DevOps
  • 本文由 发表于 2022年12月21日 16:20:57
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
  • nacos
单机Nacos Nacos

单机Nacos

Nacos 快速开始 这个快速开始手册是帮忙您快速在您的电脑上,下载、安装并使用 Nacos。 0.版本选择 您可以在Nacos的release notes及博客中找到每个版本支持的功能的介绍,...
单机Nacos Nacos

单机Nacos

Nacos 快速开始 这个快速开始手册是帮忙您快速在您的电脑上,下载、安装并使用 Nacos。 0.版本选择 您可以在Nacos的release notes及博客中找到每个版本支持的功能的介绍,...
NacosSync Nacos

NacosSync

NacosSync 介绍 介绍 NacosSync是一个支持多种注册中心的同步组件,基于Spring boot开发框架,数据层采用Spring Data JPA,遵循了标准的J...
评论  0  访客  0

发表评论