Docker启动安装nacos(踩过坑版)

1、Docker 拉取镜像

docker pull nacos/nacos-server:v2.1.0

2、创建宿主机挂载目录

mkdir -p /mydata/nacos/logs/
mkdir -p /mydata/nacos/conf/

3、启动nacos并复制文件到宿主机,关闭容器
启动容器

docker run -p 8848:8848 --name nacos -d nacos/nacos-server

复制文件

docker cp nacos:/home/nacos/logs/ /mydata/nacos/
docker cp nacos:/home/nacos/conf/ /mydata/nacos/

关闭容器(容器id也可以)

docker rm -f nacos

4、mysql中创建nacos所需的表
mysql中新建一个库,名字可自定义,这里就用nacos,从github中找到创建表的文件,在nacos-config库中执行,创建所需的表https://myblogoss2.oss-cn-beijing.aliyuncs.com/dump-nacos-202403131030.sql
5、再次启动nacos

docker run -d --name nacos -p 8848:8848  -p 9848:9848 -p 9849:9849 --privileged=true -e JVM_XMS=256m -e JVM_XMX=256m -e MODE=standalone -v /mydata/nacos/logs/:/home/nacos/logs -v /mydata/nacos/conf/:/home/nacos/conf/ --restart=always nacos/nacos-server

注意事项
虚拟机需要在防火墙开放相关端口,或者关了防火墙,如果你是云服务器,开放安全组
6、修改配置文件
主要修改的是application.properties文件

vim /mydata/nacos/conf/application.properties

文件修改的地方(修改为你对应的mysql),我的配置文件直接贴上改一下数据库密码和读取的数据库名称就行了。

#
# Copyright 1999-2021 Alibaba Group Holding Ltd.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#      http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

#*************** Spring Boot Related Configurations ***************#
### Default web context path:
server.servlet.contextPath=/nacos
### Default web server port:
server.port=8848

#*************** Network Related Configurations ***************#
### If prefer hostname over ip for Nacos server addresses in cluster.conf:
# nacos.inetutils.prefer-hostname-over-ip=false

### Specify local server's IP:
# nacos.inetutils.ip-address=


#*************** Config Module Related Configurations ***************#
### If use MySQL as datasource:
spring.datasource.platform=mysql

### Count of DB:
db.num=1

### Connect URL of DB:
db.url.0=jdbc:mysql://123.57.1.39:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=
db.password.0=


### Connection pool configuration: hikariCP
db.pool.config.connectionTimeout=30000
db.pool.config.validationTimeout=10000
db.pool.config.maximumPoolSize=20
db.pool.config.minimumIdle=2

#*************** Naming Module Related Configurations ***************#
### Data dispatch task execution period in milliseconds: Will removed on v2.1.X, replace with nacos.core.protocol.distro.data.sync.delayMs
# nacos.naming.distro.taskDispatchPeriod=200

### Data count of batch sync task: Will removed on v2.1.X. Deprecated
# nacos.naming.distro.batchSyncKeyCount=1000

### Retry delay in milliseconds if sync task failed: Will removed on v2.1.X, replace with nacos.core.protocol.distro.data.sync.retryDelayMs
# nacos.naming.distro.syncRetryDelay=5000

### If enable data warmup. If set to false, the server would accept request without local data preparation:
# nacos.naming.data.warmup=true

### If enable the instance auto expiration, kind like of health check of instance:
# nacos.naming.expireInstance=true

### will be removed and replaced by `nacos.naming.clean` properties
nacos.naming.empty-service.auto-clean=true
nacos.naming.empty-service.clean.initial-delay-ms=50000
nacos.naming.empty-service.clean.period-time-ms=30000

### Add in 2.0.0
### The interval to clean empty service, unit: milliseconds.
# nacos.naming.clean.empty-service.interval=60000

### The expired time to clean empty service, unit: milliseconds.
# nacos.naming.clean.empty-service.expired-time=60000

### The interval to clean expired metadata, unit: milliseconds.
# nacos.naming.clean.expired-metadata.interval=5000

### The expired time to clean metadata, unit: milliseconds.
# nacos.naming.clean.expired-metadata.expired-time=60000

### The delay time before push task to execute from service changed, unit: milliseconds.
# nacos.naming.push.pushTaskDelay=500

### The timeout for push task execute, unit: milliseconds.
# nacos.naming.push.pushTaskTimeout=5000

### The delay time for retrying failed push task, unit: milliseconds.
# nacos.naming.push.pushTaskRetryDelay=1000

### Since 2.0.3
### The expired time for inactive client, unit: milliseconds.
# nacos.naming.client.expired.time=180000

#*************** CMDB Module Related Configurations ***************#
### The interval to dump external CMDB in seconds:
# nacos.cmdb.dumpTaskInterval=3600

### The interval of polling data change event in seconds:
# nacos.cmdb.eventTaskInterval=10

### The interval of loading labels in seconds:
# nacos.cmdb.labelTaskInterval=300

### If turn on data loading task:
# nacos.cmdb.loadDataAtStart=false


#*************** Metrics Related Configurations ***************#
### Metrics for prometheus
#management.endpoints.web.exposure.include=*

### Metrics for elastic search
management.metrics.export.elastic.enabled=false
#management.metrics.export.elastic.host=http://localhost:9200

### Metrics for influx
management.metrics.export.influx.enabled=false
#management.metrics.export.influx.db=springboot
#management.metrics.export.influx.uri=http://localhost:8086
#management.metrics.export.influx.auto-create-db=true
#management.metrics.export.influx.consistency=one
#management.metrics.export.influx.compressed=true

#*************** Access Log Related Configurations ***************#
### If turn on the access log:
server.tomcat.accesslog.enabled=true

### The access log pattern:
server.tomcat.accesslog.pattern=%h %l %u %t "%r" %s %b %D %{User-Agent}i %{Request-Source}i

### The directory of access log:
server.tomcat.basedir=

#*************** Access Control Related Configurations ***************#
### If enable spring security, this option is deprecated in 1.2.0:
#spring.security.enabled=false

### The ignore urls of auth, is deprecated in 1.2.0:
nacos.security.ignore.urls=/,/error,/**/*.css,/**/*.js,/**/*.html,/**/*.map,/**/*.svg,/**/*.png,/**/*.ico,/console-ui/public/**,/v1/auth/**,/v1/console/health/**,/actuator/**,/v1/console/server/**

### The auth system to use, currently only 'nacos' and 'ldap' is supported:
nacos.core.auth.system.type=nacos

### If turn on auth system:
nacos.core.auth.enabled=false

### Turn on/off caching of auth information. By turning on this switch, the update of auth information would have a 15 seconds delay.
nacos.core.auth.caching.enabled=true

### Since 1.4.1, Turn on/off white auth for user-agent: nacos-server, only for upgrade from old version.
nacos.core.auth.enable.userAgentAuthWhite=false

### Since 1.4.1, worked when nacos.core.auth.enabled=true and nacos.core.auth.enable.userAgentAuthWhite=false.
### The two properties is the white list for auth and used by identity the request from other server.
nacos.core.auth.server.identity.key=serverIdentity
nacos.core.auth.server.identity.value=security

### worked when nacos.core.auth.system.type=nacos
### The token expiration in seconds:
nacos.core.auth.plugin.nacos.token.expire.seconds=18000
### The default token:
nacos.core.auth.plugin.nacos.token.secret.key=SecretKey012345678901234567890123456789012345678901234567890123456789

### worked when nacos.core.auth.system.type=ldap,{0} is Placeholder,replace login username
#nacos.core.auth.ldap.url=ldap://localhost:389
#nacos.core.auth.ldap.basedc=dc=example,dc=org
#nacos.core.auth.ldap.userDn=cn=admin,${nacos.core.auth.ldap.basedc}
#nacos.core.auth.ldap.password=admin
#nacos.core.auth.ldap.userdn=cn={0},dc=example,dc=org


#*************** Istio Related Configurations ***************#
### If turn on the MCP server:
nacos.istio.mcp.server.enabled=false

#*************** Core Related Configurations ***************#

### set the WorkerID manually
# nacos.core.snowflake.worker-id=

### Member-MetaData
# nacos.core.member.meta.site=
# nacos.core.member.meta.adweight=
# nacos.core.member.meta.weight=

### MemberLookup
### Addressing pattern category, If set, the priority is highest
# nacos.core.member.lookup.type=[file,address-server]
## Set the cluster list with a configuration file or command-line argument
# nacos.member.list=192.168.16.101:8847?raft_port=8807,192.168.16.101?raft_port=8808,192.168.16.101:8849?raft_port=8809
## for AddressServerMemberLookup
# Maximum number of retries to query the address server upon initialization
# nacos.core.address-server.retry=5
## Server domain name address of [address-server] mode
# address.server.domain=jmenv.tbsite.net
## Server port of [address-server] mode
# address.server.port=8080
## Request address of [address-server] mode
# address.server.url=/nacos/serverlist

#*************** JRaft Related Configurations ***************#

### Sets the Raft cluster election timeout, default value is 5 second
# nacos.core.protocol.raft.data.election_timeout_ms=5000
### Sets the amount of time the Raft snapshot will execute periodically, default is 30 minute
# nacos.core.protocol.raft.data.snapshot_interval_secs=30
### raft internal worker threads
# nacos.core.protocol.raft.data.core_thread_num=8
### Number of threads required for raft business request processing
# nacos.core.protocol.raft.data.cli_service_thread_num=4
### raft linear read strategy. Safe linear reads are used by default, that is, the Leader tenure is confirmed by heartbeat
# nacos.core.protocol.raft.data.read_index_type=ReadOnlySafe
### rpc request timeout, default 5 seconds
# nacos.core.protocol.raft.data.rpc_request_timeout_ms=5000

#*************** Distro Related Configurations ***************#

### Distro data sync delay time, when sync task delayed, task will be merged for same data key. Default 1 second.
# nacos.core.protocol.distro.data.sync.delayMs=1000

### Distro data sync timeout for one sync data, default 3 seconds.
# nacos.core.protocol.distro.data.sync.timeoutMs=3000

### Distro data sync retry delay time when sync data failed or timeout, same behavior with delayMs, default 3 seconds.
# nacos.core.protocol.distro.data.sync.retryDelayMs=3000

### Distro data verify interval time, verify synced data whether expired for a interval. Default 5 seconds.
# nacos.core.protocol.distro.data.verify.intervalMs=5000

### Distro data verify timeout for one verify, default 3 seconds.
# nacos.core.protocol.distro.data.verify.timeoutMs=3000

### Distro data load retry delay when load snapshot data failed, default 30 seconds.
# nacos.core.protocol.distro.data.load.retryDelayMs=30000

改过后需要重启容器,出问题可以使用docker logs 看一下日志

7、访问页面
http://ip:8848/nacos,默认账号密码nacos,nacos

有问题,直接私信或者留言,看见就会回的 。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/455622.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

通过Maven创建Web工程

通过Maven创建Web工程 方式一方式二 方式一 1.先创建一个Maven工程 2.把该Maven模块的pom文件里添加一个war 3.选中该Maven模块 点击项目架构 4.手动添加一个Web架构 方式二 1.也是new一个模块 但是直接配置好Web 2.这里就是我IDEA对Maven的设置 3.第一次创建 可能…

【C++】STL--String

这一节主要总结string类的常见接口,以及完成了string类的模拟实现。 目录 标准库的String类 string类常见接口 string类对象的常见构造 string析构函数:~string string类对象的容量操作 string类对象的访问及遍历操作 string类对象的修改操作 s…

jvm题库详解

1、JVM内存模型 注意:这个是基于jdk1.8之前的虚拟机,在jdk1.8后 已经没有方法区,一并合并到堆中的元空间了 JVM内存区域总共分为两种类型 线程私有区域:程序计数器、本地方法栈和虚拟机栈 线程共享区域:堆&#xff08…

让若依生成的service、mapper继承mybatisPlus的基类

前言:若依继承mybatisPlus后,生成代码都要手动去service、serviceImpl、mapper文件去继承mybatisplus的基类,繁琐死了。这里通过修改若依生成模版从而达到生成文件后直接使用mybatisPlus的方法。 一、首先找到若依生成模版文件位置&#xff…

顶顶通呼叫中心中间件-群集模式配置

文章目录 群集模式介绍联系我们配置流程群集模式下呼叫线路配置 群集模式介绍 在大规模的外呼或者呼入系统,比如整个系统需要1万并发,单机最高也就3000-5000并发,这时候就需要多机群集了。顶顶通呼叫中心中间件使用的是 redis 数据库&#x…

你选的Six Sigma咨询公司靠谱吗?保姆级避坑指南

近年来,企业为了追求更高的运营效率和产品质量,纷纷寻求Six Sigma这样的先进管理方法。然而,市场上的咨询公司琳琅满目,如何选择一家真正靠谱、能带来实际效益的咨询公司呢? 一、了解公司背景和实力 在选择Six Sigma咨…

msdn我告诉你itellyou做一个安静的工具站,各种windows镜像下载,iso体积都是很小的那种

官网地址:MSDN, 我告诉你 - 做一个安静的工具站 可以看到里面集成了各种操作系统,可以下载使用。 或者在他的新站点:登录 里面有最新的windows11系统可以下载,但是需要登陆之后才可以,随便第三方账号登陆即可&…

【Devin AI】全球首位AI程序员登场,程序员该如何保住饭碗?编程新纪元的革命已到来!

程序员们,警惕!我们的饭碗要被砸了! 一觉醒来,全球首位AI程序员 Devin 上线了!直接引爆整个科技圈。 Devin被介绍为世界首个完全自主的AI软件工程师。只需一句指令,它可端到端地构建和部署整个开发项目。 …

Ajax学习笔记(一):原生AJAX、HTTP协议、AJAX案例准备工作、发送AJAX请求、AJAX 请求状态

目录 一、原生AJAX 1.1AJAX 简介 1.2 XML 简介 1.3 AJAX的特点 二、HTTP协议 三、AJAX案例准备工作 四、发送AJAX请求 1.发送GET请求 2.发送POST请求 3.JSON响应 IE缓存问题: 五、AJAX 请求状态 一、原生AJAX 1.1AJAX 简介 AJAX 全称为 Asynchronous …

使用Nginx进行负载均衡

什么是负载均衡 Nginx是一个高性能的开源反向代理服务器,也可以用作负载均衡器。通过Nginx的负载均衡功能,可以将流量分发到多台后端服务器上,实现负载均衡,提高系统的性能、可用性和稳定性。 如下图所示: Nginx负…

shell控制多线程并发处理

一、前言 我们在用shell编程时,当用到循环语句时,如果循环的对象数量比较多,则代码一条一条处理,时间消耗会特别慢。如果此时机器资源充足,不妨学会多线程并发处理这招,帮助你提前打卡完成工作。 二、控制…

MySQL数据库自动备份(Linux操作系统)

方式一 参考:https://blog.csdn.net/qq_48157004/article/details/126683610?spm1001.2014.3001.5506 1.MySQL备份脚本 在/home/backups/下建立.sh文件,文件名称 mysql_backup.sh ,内容如下 #!/bin/bash #备份路径 BACKUP/home/backups/mysqlBackup…

酷开系统走在前列,品牌重启增长,酷开科技成为品牌商合作目标

区别于火热的移动端,手机屏作为私密屏,往往面向的是用户个体,而电视作为家庭连接的重要枢纽,不仅仅定位于公共屏,同时也面向客厅场景发挥着其大屏传播的作用,这里不仅牵扯到大屏营销,也关联着大…

奥赛满分金牌得主出品,硅谷诞生超级AI码农

又是让程序员们兴奋而焦绿🍌的一刻,昨天业界又发布了一款 AI 编程产品 Devin。号称是业界第一个 AI 软件工程师。 作者 Scott Wu 曾是国际信息奥赛 (IOI) 连续三届的金牌得主,其中还有一届是满分。 Devin 背后的公司名字叫 Cognition。中文翻…

Matlab有限元结果后处理 | 不规则云图绘制(二维/三维)|【Matlab源码+视频教程】

专栏导读 作者简介:工学博士,高级工程师,专注于工业软件算法研究本文已收录于专栏:《有限元编程从入门到精通》本专栏旨在提供 1.以案例的形式讲解各类有限元问题的程序实现,并提供所有案例完整源码;2.单元…

SSA-LSTM多输入回归预测 | 樽海鞘优化算法-长短期神经网络 | Matlab

目录 一、程序及算法内容介绍: 基本内容: 亮点与优势: 二、实际运行效果: 三、算法介绍: 四、完整程序下载: 一、程序及算法内容介绍: 基本内容: 本代码基于Matlab平台编译&am…

换掉ES!Redis官方搜索引擎来了,性能炸裂!

RediSearch 一、介绍二、实现特性1. 对比 Elasticsearch2. 索引构建测试3. 查询性能测试 三、安装1. 源码安装2. docker安装3. 判断是否安装成功 四、命令行操作1. 创建1.1 创建索引1.2 创建文档 2. 查询2.1 基本查询2.1.1 全量查询2.1.2 匹配查询 2.2 模糊匹配2.2.1 后置匹配2…

java数据结构与算法刷题-----LeetCode491. 非递减子序列

java数据结构与算法刷题目录(剑指Offer、LeetCode、ACM)-----主目录-----持续更新(进不去说明我没写完):https://blog.csdn.net/grd_java/article/details/123063846 文章目录 解题思路:时间复杂度O( n 2 ∗ n n^2*n n2∗n),空间复…

从零开始利用MATLAB进行FPGA设计(一):建立脉冲检测模型的Simulink模型2

目录 1.模块的总体结构 1.1从工作空间导入输入信号 1.2FIR滤波器 2.Subsystem 3.MATLAB Function 文章灵感来源于MATLAB官方免费教程:HDL Coder Self-Guided Tutorial 考虑到MATLAB官网的英文看着慢,再加上视频讲解老印浓浓的咖喱味,我…

【数据结构与算法】排序

目 录 一.排序的概念及引用1.1 排序的概念1.2 常见的排序算法 二.常见排序算法的实现2.1 插入排序直接插入排序希尔排序( 缩小增量排序 ) 2.2 选择排序直接选择排序堆排序 2.3 交换排序冒泡排序快速排序快速排序优化:非递归实现快速排序 2.4归并排序2.4.3 海量数据的…
最新文章