Mac 安装Nacos踩坑脱坑教程

1、检查本地是否安装了jdk和mvn

java -version .   #检查java
mvn -v .          #检查本地maven

2、安装java和maven

注:如果要想成功运行Nacos就必须下载x86版本的jdk,arm64的jdk会无法启动
一、java 下载地址:

https://www.azul.com/downloads/?version=java-8-lts&os=macos&architecture=x86-64-bit&package=jdk

下载.dmg安装之后进行安装

二、配置java环境

运行java -version 查看是否安装成功

jokins@JokinsdeMacBook-Pro Contents % java -version
openjdk version "1.8.0_345"
OpenJDK Runtime Environment (Zulu 8.64.0.19-CA-macosx) (build 1.8.0_345-b01)
OpenJDK 64-Bit Server VM (Zulu 8.64.0.19-CA-macosx) (build 25.345-b01, mixed mode)

使用/usr/libexec/java_home -V查看jdk安装目录

jokins@JokinsdeMacBook-Pro Contents % /usr/libexec/java_home -V 
Matching Java Virtual Machines (1):
    1.8.0_345 (x86_64) "Azul Systems, Inc." - "Zulu 8.64.0.19" /Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home
/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home

返回到桌面 command+shift+G 进入到/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/这个地址并打开终端
运行sudo vim /etc/profile命令
按i进行编辑,esc推出编辑并输入命令:wq!回车

JAVA_HOME="/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home"
export JAVA_HOME
CLASS_PATH="$JAVA_HOME/lib"
PATH=".$PATH:$JAVA_HOME/bin"

运行
source /etc/profile 启用配置
echo $JAVA_HOME

jokins@JokinsdeMacBook-Pro Contents % echo $JAVA_HOME
/Library/Java/JavaVirtualMachines/zulu-8.jdk/Contents/Home

运行结果是这个就表明jdk安装成功!

3、安装Nacos

一、下载nacos
地址

https://github.com/alibaba/nacos/releases/tag/2.1.1

下载.zip 并解压
二、配置nacos
1、进入conf/文件下复制nacos-mysql.sql里的内容,并在你的数据库里新建一个nacos数据库并运行。

2、更改文件cluster.conf.example为cluster.conf

3、打开conf/文件下的application.properties文件进行sql编辑
如果本地有mysql服务,只需要运行sql文件并更改用户名和密码就可以了

#*************** 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://你的数据库ip地址:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=UTC
db.user.0=root
db.password.0=密码

三、运行Nacos

进入bin目录下执行sh startup.sh -m standalone命令
进入log文件下,使用tail -f start.out查看是否启动成功

         ,--.
       ,--.'|
   ,--,:  : |                                           Nacos 2.1.1
,`--.'`|  ' :                       ,---.               Running in stand alone mode, All function modules
|   :  :  | |                      '   ,'\   .--.--.    Port: 8848
:   |   \ | :  ,--.--.     ,---.  /   /   | /  /    '   Pid: 11987
|   : '  '; | /       \   /     \.   ; ,. :|  :  /`./   Console: http://192.168.1.1:8848/nacos/index.html
'   ' ;.    ;.--.  .-. | /    / ''   | |: :|  :  ;_
|   | | \   | \__\/: . ..    ' / '   | .; : \  \    `.      https://nacos.io
'   : |  ; .' ," .--.; |'   ; :__|   :    |  `----.   \
|   | '`--'  /  /  ,.  |'   | '.'|\   \  /  /  /`--'  /
'   : |     ;  :   .'   \   :    : `----'  '--'.     /
;   |.'     |  ,     .-./\   \  /            `--'---'
'---'        `--`---'     `----'

2022-09-06 16:39:00,842 INFO Tomcat initialized with port(s): 8848 (http)

2022-09-06 16:39:00,997 INFO Root WebApplicationContext: initialization completed in 6655 ms

2022-09-06 16:39:09,664 INFO Adding welcome page: class path resource [static/index.html]

2022-09-06 16:39:10,635 WARN You are asking Spring Security to ignore Ant [pattern='/**']. This is not recommended -- please use permitAll via HttpSecurity#authorizeHttpRequests instead.

2022-09-06 16:39:10,637 INFO Will not secure Ant [pattern='/**']

2022-09-06 16:39:10,703 INFO Will secure any request with [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@545de5a4, org.springframework.security.web.context.SecurityContextPersistenceFilter@7651218e, org.springframework.security.web.header.HeaderWriterFilter@2ed3b1f5, org.springframework.security.web.csrf.CsrfFilter@132ddbab, org.springframework.security.web.authentication.logout.LogoutFilter@21005f6c, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@6d366c9b, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@24faea88, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@29ef6856, org.springframework.security.web.session.SessionManagementFilter@68d6972f, org.springframework.security.web.access.ExceptionTranslationFilter@675d8c96]

2022-09-06 16:39:10,765 INFO Exposing 1 endpoint(s) beneath base path '/actuator'

2022-09-06 16:39:10,894 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'

2022-09-06 16:39:10,943 INFO Nacos started successfully in stand alone mode. use external storage

2022-09-06 16:39:14,060 INFO Initializing Servlet 'dispatcherServlet'

2022-09-06 16:39:14,065 INFO Completed initialization in 5 ms

运行结果如上,表明运行成功,在web端打开log里的地址就行。
到此结束!!!!!
一定一定不要安装arm版的jdk要不然一定启动不起来!!!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值