Linux安装Nacos(单机模式)

小柒博客 评论923字数 682阅读2分16秒阅读模式

一、Nacos简介

Nacos /nɑ:kəʊs/是Dynamic Naming and Configuration Service的首字母简称,一个更易于构建云原生应用的动态服务发现、配置管理和服务管理平台。

Nacos主要提供三种功能:服务注册与发现、动态配置服务、动态DNS服务。

二、安装JDK

JDK下载地址:https://www.oracle.com/cn/java/technologies/javase/jdk11-archive-downloads.html

1、安装JDK-11.0.17

[root@localhost ~]# yum -y install jdk-11.0.17_linux-x64_bin.rpm

2、查看是否安装成功

[root@localhost ~]# java -version

java version "11.0.17" 2022-10-18 LTS

Java(TM) SE Runtime Environment 18.9 (build 11.0.17+10-LTS-269)

Java HotSpot(TM) 64-Bit Server VM 18.9 (build 11.0.17+10-LTS-269, mixed mode)

三、安装MySQL

1、配置清华大学Yum源

[root@localhost ~]# vim /etc/yum.repos.d/mysql-community.repo

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-connectors-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-tools-community-el7-$basearch/
enabled=1
gpgcheck=1
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql

[mysql-5.7-community]
name=MySQL 5.7 Community Server
baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-$basearch/
enabled=1
gpgcheck=0
gpgkey=https://repo.mysql.com/RPM-GPG-KEY-mysql

2、安装MySQL-5.7

[root@localhost ~]# yum -y install mysql-community-server

3、启动MySQL

[root@localhost ~]# systemctl start mysqld

4、登录MySQL

1)查看初始化后生成的密码

[root@localhost ~]# grep 'password' /var/log/mysqld.log

2023-03-25T12:54:39.593636Z 1 [Note] A temporary password is generated for root@localhost: hiPZY4U6yZ_6

2)登录MySQL

[root@localhost ~]# mysql -uroot -p'hiPZY4U6yZ_6'

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connection id is 3

Server version: 5.7.42-log MySQL Community Server (GPL)

 

Copyright (c) 2000, 2023, 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.

# 初始化后需重置密码才能执行sql

mysql> set password=password('Aa123456@!');

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

 

mysql> select version();

+---------------+

| version()    |

+---------------+

| 5.7.42-log |

+---------------+

1 row in set (0.00 sec)

四、安装Nacos

1、下载Nacos软件包

[root@localhost ~]# wget https://github.com/alibaba/nacos/releases/download/1.4.3/nacos-server-1.4.3.zip

2、解压

[root@localhost ~]# unzip nacos-server-1.4.3.zip -d /usr/local

3、修改startup.sh启动脚本

[root@localhost ~]# vim /usr/local/nacos/bin/startup.sh

# 添加JAVA_HOME

JAVA_HOME="/usr/java/jdk-11.0.17"

Linux安装Nacos(单机模式)-图片1

4、导入Nacos自带SQL文件

1)创建数据库及授权

[root@localhost ~]# mysql -uroot -p

Enter password:

mysql> create database nacos;

Query OK, 1 row affected (0.00 sec)

 

mysql> grant all on nacos.* to nacos@'localhost' identified by 'nacos';

Query OK, 0 rows affected, 1 warning (0.00 sec)

 

mysql> flush privileges;

Query OK, 0 rows affected (0.00 sec)

2)导入SQL文件

[root@localhost ~]# mysql -unacos -pnacos nacos < /usr/local/nacos/conf/nacos-mysql.sql

5、修改Nacos配置文件

[root@localhost ~]# vim /usr/local/nacos/conf/application.properties

Linux安装Nacos(单机模式)-图片2

6、配置系统服务

[root@localhost ~]# vim /usr/lib/systemd/system/nacos.service

[Unit]
Description=nacos
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nacos/bin/startup.sh -m standalone
ExecReload=/usr/local/nacos/bin/shutdown.sh
ExecStop=/usr/local/nacos/bin/shutdown.sh
PrivateTmp=true

[Install]
WantedBy=multi-user.target

7、启动Nacos(单机模式)

[root@localhost ~]# systemctl daemon-reload

[root@localhost ~]# systemctl start nacos

[root@localhost ~]# systemctl enable nacos

8、访问Nacos

1)浏览器输入http://192.168.0.198:8848/nacos,如下图所示

2)登录Nacos(默认账号nacos,密码nacos)

若文章图片、下载链接等信息出错,请在评论区留言反馈,博主将第一时间更新!如本文“对您有用”,欢迎随意打赏,谢谢!

继续阅读
Wechat
微信扫一扫,加我!
weinxin
微信号已复制
微信公众号
微信扫一扫,关注我!
weinxin
公众号已复制
Nacos最后更新:2023-9-30
小柒博客
  • 本文由 小柒博客 发表于 2023年5月17日 15:37:11
  • 声明:本站所有文章,如无特殊说明或标注,本站文章均为原创。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。转载请务必保留本文链接:https://www.yangxingzhen.com/9152.html
匿名

发表评论

匿名网友
:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

拖动滑块以完成验证