介绍
在Linux centos 服务器搭建单机nacos。内容来自nacos官网。
Nacos 致力于帮助您发现、配置和管理微服务。就时间 2022年5月13日 10:00:11
Nacos 的关键特性
- 服务发现和服务健康监测
- 动态配置服务
- 动态 DNS 服务
- 服务及其元数据管理
操作
参考
nacos官网
Linux上安装nacos(完整版)
linux下nacos安装
如何在 Linux 安装 Nacos 服务
centos7 开机延迟几分钟后自启动
centos环境变量设置
Linux开机启动程序rc.local
下载、上传nacos
下载的是编译好的可执行代码
下载地址:https://github.com/alibaba/nacos/releases
服务器创建临时目录
mkdir temp-file
上传到服务器
命令记录
tar -zxvf nacos-server-2.1.0.tar.gz # 解压tar包
mv nacos /usr/local/ # 移动到usr系统目录
cd /usr/local/nacos/bin/ # 跳转
java -version # java版本
sh startup.sh -m standalone # 单机模式启动
vim password # 开发环境 记录一下 账号密码 默认 nacos nacos
ps -ef|grep nacos # 查看运行状态
curl http://127.0.0.1:8848/nacos/index.html # 测试登录页面
vim nacos_self_start.sh # 创建延迟启动脚本
chmod +x nacos_self_start.sh # 授权
cat /etc/profile # 获取java 的环境设置
vim /etc/rc.d/rc.local # 追加开机启动命令
chmod +x /etc/rc.d/rc.local #授权
systemctl enable rc-local # 启用
systemctl start rc-local # 启动
systemctl status rc-local #获取状态
延迟启动sh脚本
#!/bin/bash
echo "nacos delayed 60s start"
sleep 60
sh startup.sh -m standalone
echo "nacos start end"
开机脚本追加,先设置java环境变量,在启动nacos
export JAVA_HOME=/opt/java
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export PATH=$PATH:$JAVA_HOME/bin
# start nacos
nohup /usr/local/nacos/bin/nacos_self_start.sh &
<!--
~ Copyright 1999-2018 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.
-->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title>Nacos</title>
<link rel="shortcut icon" href="console-ui/public/img/nacos-logo.png" type="image/x-icon">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/console1412.css">
<!-- 第三方css开始 -->
<link rel="stylesheet" type="text/css" href="console-ui/public/css/codemirror.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/merge.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/icon.css">
<link rel="stylesheet" type="text/css" href="console-ui/public/css/font-awesome.css">
<!-- 第三方css结束 -->
<link href="./css/main.css?fd60064fb047286c26f3" rel="stylesheet"></head>
<body>
<div id="root" style="overflow:hidden"></div>
<div id="app"></div>
<div id="other"></div>
<!-- 第三方js开始 -->
<script src="console-ui/public/js/jquery.js"></script>
<script src="console-ui/public/js/codemirror.js"></script>
<script src="console-ui/public/js/javascript.js"></script>
<script src="console-ui/public/js/xml.js"></script>
<script src="console-ui/public/js/codemirror.addone.fullscreen.js"></script>
<script src="console-ui/public/js/codemirror.addone.lint.js"></script>
<script src="console-ui/public/js/codemirror.lib.json-lint.js"></script>
<script src="console-ui/public/js/codemirror.addone.json-lint.js"></script>
<script src="console-ui/public/js/codemirror.lib.clike-lint.js"></script>
<script src="console-ui/public/js/diff_match_patch.js"></script>
<script src="console-ui/public/js/merge.js"></script>
<script src="console-ui/public/js/loader.js"></script>
<!-- 第三方js结束 -->
<script type="text/javascript" src="./js/main.js?fd60064fb047286c26f3"></script></body>
</html>
登录nacos
http://IP:8848/nacos/#/login
报错记录
参考:Nacos启动报错解决:which: no javac in (/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
linux下nacos安装
Linux使用JDK替换OpenJDK流程
参考1和2,没有解决问题。参考3解决问题。
下载jdk
上传到服务器
部署jdk
tar -zxvf jdk-8u201-linux-x64.tar.gz #解压
mv jdk1.8.0_201 /usr/local/java8 #移动
vim /etc/profile #编辑环境变量,追加
export JAVA_HOME=/usr/local/java8
export JRE_HOME=/usr/local/java8/jre
export CLASS_PATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH
source /etc/profile #激活
update-alternatives --config java # 获取当前环境有效java
update-alternatives --config javac# 获取当前环境有效javac
update-alternatives --install /usr/bin/javac javac /usr/local/java8/bin/javac 2000000 #安装javac,并指定优先级
update-alternatives --install /usr/bin/java java /usr/local/java8/jre/bin/java 2000000 #安装java,并指定优先级
update-alternatives --install /usr/bin/javac javac /javac 1000000 #原来javac降级
java -version
#开放端口
firewall-cmd --permanent --add-port=8848/tcp
firewall-cmd --reload