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