服务器规划:
本次搭建一个使用了3台机器
主机 | ip地址 | 内存 |
centoshadoop2 | 192.168.227.141 | 8G |
centoshadoop3 | 192.168.227.142 | 8G |
centoshadoop4 | 192.168.227.143 | 8G |
(一)官网下载源码包
https://github.com/alibaba/nacos/releases
https://github.com/alibaba/nacos/releases/download/1.2.1/nacos-server-1.2.1.tar.gz
创建目录dubbo-nacos目录,我们将nacos安装在该目录
[hadoop@centoshadoop4 tools]$ mkdir -p ~/dubbo-nacos
解压nacos-server-1.2.1.tar.gz 到dubbo-nacos目录
[hadoop@centoshadoop4 tools]$ tar -zxvf nacos-server-1.2.1.tar.gz -C ~/dubbo-nacos
nacos/LICENSE
nacos/NOTICE
nacos/target/nacos-server.jar
nacos/conf/
nacos/conf/schema.sql
nacos/conf/nacos-mysql.sql # MySQL数据库脚本文件,Nacos支持Derby和MySQL两种持久化机制,默认采用Derby数据库,如果采用MySQL,需要运行该脚本创建数据库和表
nacos/conf/application.properties.example
nacos/conf/nacos-logback.xml # Nacos日志配置文件
nacos/conf/cluster.conf.example # 集群配置样例配置文件
nacos/conf/application.properties # SpringBoot 项目默认的配置文件
nacos/bin/startup.sh
nacos/bin/startup.cmd
nacos/bin/shutdown.sh
nacos/bin/shutdown.cmd
进入安装目录
[hadoop@centoshadoop4 tools]$ cd ~/dubbo-nacos
[hadoop@centoshadoop4 dubbo-nacos]$ ll
总用量 0
drwxrwxr-x. 5 hadoop hadoop 67 5月 6 22:17 nacos
[hadoop@centoshadoop4 dubbo-nacos]$ pwd
/home/hadoop/dubbo-nacos
(二)修改配置文件:
(1)配置nacos集群 cluster.conf
[hadoop@centoshadoop4 conf]$ cp cluster.conf.example cluster.conf
vi cluster.conf
centoshadoop4:8848
centoshadoop3:8848
centoshadoop2:8848
(2)配置mysql数据库:application.properties,增加mysql的配置
### If user MySQL as datasource:
spring.datasource.platform=mysql
### Count of DB:
db.num=1
### Connect URL of DB:
db.url.0=jdbc:mysql://192.168.227.136:3306/nacos?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true
db.user=root
db.password=123456
(3)执行nacos-mysql.sql初始化
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hdfs_hive |
| hive_db |
| log_analysis |
| mysql |
| performance_schema |
| spark_db |
| sys |
+--------------------+
8 rows in set (0.06 sec)
创建数据库 nacos_config
mysql> create database nacos;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| hdfs_hive |
| hive_db |
| log_analysis |
| mysql |
| nacos |
| performance_schema |
| spark_db |
| sys |
+--------------------+
9 rows in set (0.00 sec)
远程拷贝nacos-mysql.sql文件到mysql安装机器
[hadoop@centosnode01 ~]$ scp -r -P 22 hadoop@centoshadoop4:/home/hadoop/dubbo-nacos/nacos/conf/nacos-mysql.sql ~/tools/
执行数据库脚本文件:
mysql> use nacos;
Database changed
mysql> source ~/tools/nacos-mysql.sql ;
Query OK, 0 rows affected (0.04 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 1 row affected (0.08 sec)
Query OK, 1 row affected (0.00 sec)
(三)分发nacos安装文件到其他节点:
[hadoop@centoshadoop4 ~]$ cd ~
[hadoop@centoshadoop4 ~]$ scp -r dubbo-nacos/ hadoop@centoshadoop3:~/
[hadoop@centoshadoop4 ~]$ scp -r dubbo-nacos/ hadoop@centoshadoop2:~/
==============制作启动脚本,设置开机启动==============
vi /usr/lib/systemd/system/nacos.service
[Unit]
Description=NacosServer
After=network.target
[Service]
Type=forking
Environment=JAVA_HOME=/usr/local/java/jdk1.8.0_192
ExecStart=/home/hadoop/dubbo-nacos/nacos/bin/startup.sh -m standalone
ExecReload=/home/hadoop/dubbo-nacos/nacos/bin/shutdown.sh
ExecStop=/home/hadoop/dubbo-nacos/nacos/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新加载信息
systemctl daemon-reload
设置开机启动
systemctl enable nacos.service
systemctl start | stop | status nacos
===========制作启动脚本,设置开机启动================
(四)分别进入三台机器的bin目录,执行sh startup.sh 命令启动服务
[hadoop@centoshadoop4 ~]$ cd dubbo-nacos/nacos/bin
[hadoop@centoshadoop4 bin]$ ll
总用量 20
-rwxr-xr-x. 1 hadoop hadoop 954 4月 8 2019 shutdown.cmd
-rwxr-xr-x. 1 hadoop hadoop 949 4月 28 14:10 shutdown.sh
-rwxr-xr-x. 1 hadoop hadoop 2836 4月 30 16:00 startup.cmd
-rwxr-xr-x. 1 hadoop hadoop 4730 4月 30 16:00 startup.sh
[hadoop@centoshadoop4 bin]$ sh startup.sh
/usr/local/java/jdk1.8.0_192/bin/java -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/hadoop/dubbo-nacos/nacos/logs/java_heapdump.hprof -XX:-UseLargePages -Djava.ext.dirs=/usr/local/java/jdk1.8.0_192/jre/lib/ext:/usr/local/java/jdk1.8.0_192/lib/ext -Xloggc:/home/hadoop/dubbo-nacos/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/hadoop/dubbo-nacos/nacos/plugins/health,/home/hadoop/dubbo-nacos/nacos/plugins/cmdb,/home/hadoop/dubbo-nacos/nacos/plugins/mysql -Dnacos.home=/home/hadoop/dubbo-nacos/nacos -jar /home/hadoop/dubbo-nacos/nacos/target/nacos-server.jar --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/home/hadoop/dubbo-nacos/nacos/conf/ --logging.config=/home/hadoop/dubbo-nacos/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
nacos is starting with cluster
nacos is starting,you can check the /home/hadoop/dubbo-nacos/nacos/logs/start.out
[hadoop@centoshadoop4 bin]$ ssh centoshadoop3
Last login: Tue May 5 21:21:27 2020
[hadoop@centoshadoop3 ~]$ cd dubbo-nacos/nacos/bin
[hadoop@centoshadoop3 bin]$ sh startup.sh
/home/hadoop/java/jdk1.8.0_192/bin/java -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/hadoop/dubbo-nacos/nacos/logs/java_heapdump.hprof -XX:-UseLargePages -Djava.ext.dirs=/home/hadoop/java/jdk1.8.0_192/jre/lib/ext:/home/hadoop/java/jdk1.8.0_192/lib/ext -Xloggc:/home/hadoop/dubbo-nacos/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/hadoop/dubbo-nacos/nacos/plugins/health,/home/hadoop/dubbo-nacos/nacos/plugins/cmdb,/home/hadoop/dubbo-nacos/nacos/plugins/mysql -Dnacos.home=/home/hadoop/dubbo-nacos/nacos -jar /home/hadoop/dubbo-nacos/nacos/target/nacos-server.jar --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/home/hadoop/dubbo-nacos/nacos/conf/ --logging.config=/home/hadoop/dubbo-nacos/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
nacos is starting with cluster
nacos is starting,you can check the /home/hadoop/dubbo-nacos/nacos/logs/start.out
[hadoop@centoshadoop3 bin]$ ssh centoshadoop2
Last login: Thu Apr 23 22:37:37 2020
[hadoop@centoshadoop2 ~]$ cd dubbo-nacos/nacos/bin
[hadoop@centoshadoop2 bin]$ sh startup.sh
/home/hadoop/java/jdk1.8.0_192/bin/java -server -Xms2g -Xmx2g -Xmn1g -XX:MetaspaceSize=128m -XX:MaxMetaspaceSize=320m -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/home/hadoop/dubbo-nacos/nacos/logs/java_heapdump.hprof -XX:-UseLargePages -Djava.ext.dirs=/home/hadoop/java/jdk1.8.0_192/jre/lib/ext:/home/hadoop/java/jdk1.8.0_192/lib/ext -Xloggc:/home/hadoop/dubbo-nacos/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dloader.path=/home/hadoop/dubbo-nacos/nacos/plugins/health,/home/hadoop/dubbo-nacos/nacos/plugins/cmdb,/home/hadoop/dubbo-nacos/nacos/plugins/mysql -Dnacos.home=/home/hadoop/dubbo-nacos/nacos -jar /home/hadoop/dubbo-nacos/nacos/target/nacos-server.jar --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/home/hadoop/dubbo-nacos/nacos/conf/ --logging.config=/home/hadoop/dubbo-nacos/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
nacos is starting with cluster
nacos is starting,you can check the /home/hadoop/dubbo-nacos/nacos/logs/start.out
查看日志:
[hadoop@centoshadoop3 bin]$ tail -f /home/hadoop/dubbo-nacos/nacos/logs/start.out
2020-05-06 23:38:59,293 INFO Nacos is starting...
2020-05-06 23:38:59,744 INFO Nacos logs files: /home/hadoop/dubbo-nacos/nacos/logs/
2020-05-06 23:38:59,744 INFO Nacos conf files: /home/hadoop/dubbo-nacos/nacos/conf/
2020-05-06 23:38:59,744 INFO Nacos data files: /home/hadoop/dubbo-nacos/nacos/data/
2020-05-06 23:38:59,744 INFO Nacos started successfully in cluster mode.
访问http://centoshadoop4:8848/nacos/ 地址
输入nacos/nacos登录
无显示节点信息,排查及解决方案
https://blog.csdn.net/ooyhao/article/details/102745641
https://www.cnblogs.com/larscheng/p/11427733.html
centoshadoop4:8848 集群界面的列表节点信息不能显示,必须配置为本机的IP