小工具知识网

当前位置: 首页 > 行业知识 > 如何使用linux启动Nacos

行业知识

如何使用linux启动Nacos

2026-11-18 07:58:17 来源:互联网转载

使用linux启动Nacos

前���你需要满足一下配置:

()

具体的配置需求参考Nacos的中文网站:

https://nacos.io/zh-cn/

()
  1. 64 bit OS,支持 Linux/Unix/Mac/Windows,推荐选用 Linux/Unix/Mac。
  2. 64 bit JDK 1.8+;下载 & 配置。
  3. Maven 3.2.x+;下载 & 配置。之后才开始配置nacos

在linux中配置nacos

在官网下载你需要的Nacos的版本

然后再再linux环境下

rz  #导入Nacos的压缩包mkdir /usr/local/Nacos #创建Nacos用来储藏nacos的解压文件tar -zxvf 压缩包所在路径  -C  /usr/local/Nacos  #把nacos的配置文件解压到我们指定的目录位置                        #此处C大写#-z: z代表的是gzip, 通过gzip命令处理文件,gzip可以对文件压缩或者解压#-c: c代表create,即创建新的包文件#-x: x代表的是extract,实现从包文件中还原文件,提取,解压文件#-v: v代表的是verbose,显示命令的执行过程#-f: f代表的是file,用于指定包文件的名称cd /usr/local/Nacos/bin #进入Nacos的bin目录置 

第一个关键配置

vim startup.sh #大概是这个位置

#[ ! -e "$JAVA_HOME/bin/java" ] && #JAVA_HOME=$HOME/usr/local/jdk1.8.0_171/bin/java#[ ! -e "$JAVA_HOME/bin/java" ] && #JAVA_HOME=/usr/java#[ ! -e "$JAVA_HOME/bin/java" ] && #JAVA_HOME=/opt/taobao/java#[ ! -e "$JAVA_HOME/bin/java" ] && unset JAVA_HOME

找到这个位置之后按I进入插入模式 insert mode

把第一个带有$HOME的后面改为自己在linux中JDK的安装位

第二个关键配置

进入事先在linux中配置好的数据库

mysql -u root -pEnter password: XXXXX

进入数据库

cteate database Nacos;  #创建一个用来装nacos-mysql.sql的内容use Nacos  #使用这个数据库source /usr/local/nacos/conf/nacos-mysql.sql  #执行这个文件目录下的sql文件

第三个关键配置

cd ..  #返回上一层目录cd conf #进入config目录vim application.properties  #打开这个文件#下面的配置,Nacos自带有,只需要把注解打开然后换上自己数据库的配置即可spring.datasource.platform=mysqlCount of DB:db.num=1Connect URL of DB:#地址用自己虚拟机的ip地址 加刚刚在数据库中创建的这个db.url.0=jdbc:mysql://192.168.26.130:3306/Nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTCdb.user.0=root  #自己数据库的账号db.password.0=root  #自己数据库的密码

Ending

启动Nacos

在/usr/local/nacos/bin下输入 standalone是单机启动

./startup.sh -m standalone 启动Nacos 或者 sh startup.sh -m standalone

会出现

nacos is starting with standalonenacos is starting,you can check the /usr/local/nacos/logs/start.out

我们可以cat -n /usr/local/nacos/logs/start.out

如果出现

   2       3           ,--.     4         ,--.'|     5     ,--,:  : |                                           Nacos 1.4.1     6  ,`--.'`|  ' :                       ,---.               Running in stand alone mode, All function modules     7  |   :  :  | |                      '   ,'\   .--.--.    Port: 8848     8  :   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 21759     9  |   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://192.168.26.130:8848/nacos/index.html    10  '   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_    11  |   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io    12  '   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \    13  |   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /    14  '   : |     ;  :   .'   \   :    : `----'  '--'.     /    15  ;   |.'     |  ,     .-./\   \  /            `--'---'    16  '---'        `--`---'     `----'    17      18  2023-04-04 08:46:06,573 INFO Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@20435c40' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)    19      20  2023-04-04 08:46:06,582 INFO Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)    21      22  2023-04-04 08:46:07,065 INFO Tomcat initialized with port(s): 8848 (http)    23      24  2023-04-04 08:46:07,467 INFO Root WebApplicationContext: initialization completed in 4090 ms    25      26  2023-04-04 08:46:09,942 INFO Initializing ExecutorService 'applicationTaskExecutor'    27      28  2023-04-04 08:46:10,083 INFO Adding welcome page: class path resource [static/index.html]    29      30  2023-04-04 08:46:10,498 INFO Creating filter chain: Ant [pattern='/**'], []    31      32  2023-04-04 08:46:10,533 INFO Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@35293c05, org.springframework.security.web.context.SecurityContextPersistenceFilter@7fe083b1, org.springframework.security.web.header.HeaderWriterFilter@2a492f2a, org.springframework.security.web.csrf.CsrfFilter@1b58ff9e, org.springframework.security.web.authentication.logout.LogoutFilter@5a62b2a4, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@486be205, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@4b4dd216, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@620aa4ea, org.springframework.security.web.session.SessionManagementFilter@16afbd92, org.springframework.security.web.access.ExceptionTranslationFilter@56b78e55]    33      34  2023-04-04 08:46:10,620 INFO Initializing ExecutorService 'taskScheduler'    35      36  2023-04-04 08:46:10,642 INFO Exposing 2 endpoint(s) beneath base path '/actuator'    37      38  2023-04-04 08:46:10,774 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'    39      40  2023-04-04 08:46:10,777 INFO Nacos started successfully in stand alone mode. use external storage    41  

表示成功

最后的最后

配置防火墙

firewall-cmd --zone=public --add-port=8848/tcp --permanentfirewall-cmd --reload

一切准备就绪http://192.168.26.130:8848/nacos启动它

用户名:nacos

密码:nacos

默认值

上一篇:如何下载CDSN?详细步骤教程

下一篇:南京企业网站建设方案应该怎么做