前提:
1.阿里云服务器的安全组规则-访问规则配置了8848端口
2. 阿里云服务器的防火墙配置开放了8848端口
[root@taotaoyun bin]# firewall-cmd --state
running
[root@taotaoyun bin]# firewall-cmd --zone=public --list-ports
8848/tcp
[root@taotaoyun bin]#
[root@taotaoyun bin]# netstat -lnpt
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1094/sshd
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1078/master
tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 2033/./redis-server
tcp6 0 0 :::8848 :::* LISTEN 7472/java
tcp6 0 0 ::1:25 :::* LISTEN 1078/master
tcp6 0 0 :::3306 :::* LISTEN 979/mysqld
tcp6 0 0 :::6379 :::* LISTEN 2033/./redis-server
-------------------开始-------------------
在阿里云服务器中nacos的bin目录下没有使用root权限启动命令
./startup.sh -m standalone
[root@taotaoyun bin]# ll
total 32
-rw-r--r-- 1 root root 712 Oct 10 12:06 derby.log
drwxr-xr-x 2 root root 4096 Oct 10 12:00 logs
-rwxr-xr-x 1 502 games 954 Oct 11 2019 shutdown.cmd
-rwxr-xr-x 1 502 games 949 Nov 4 2019 shutdown.sh
-rwxr-xr-x 1 502 games 2854 Nov 4 2019 startup.cmd
-rwxr-xr-x 1 502 games 4801 Nov 6 2019 startup.sh
drwxr-xr-x 3 root root 4096 Oct 8 17:22 work
[root@taotaoyun bin]# ./startup.sh -m standalone
/usr/local/java/jdk1.8.0_301/bin/java -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Djava.ext.dirs=/usr/local/java/jdk1.8.0_301/jre/lib/ext:/usr/local/java/jdk1.8.0_301/lib/ext:/usr/local/nacos/plugins/cmdb:/usr/local/nacos/plugins/mysql -Xloggc:/usr/local/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dnacos.home=/usr/local/nacos -Dloader.path=/usr/local/nacos/plugins/health -jar /usr/local/nacos/target/nacos-server.jar --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/usr/local/nacos/conf/ --logging.config=/usr/local/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
nacos is starting with standalone
nacos is starting,you can check the /usr/local/nacos/logs/start.out
结果在start.out日志中显示cannot execute binary file
/usr/local/java/jdk1.8.0_301/bin/java -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Djava.ext.dirs=/usr/local/java/jdk1.8.0_301/jre/lib/ext:/usr/local/java/jdk1.8.0_301/lib/ext:/usr/local/nacos/plugins/cmdb:/usr/local/nacos/plugins/mysql -Xloggc:/usr/local/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dnacos.home=/usr/local/nacos -Dloader.path=/usr/local/nacos/plugins/health -jar /usr/local/nacos/target/nacos-server.jar --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/usr/local/nacos/conf/ --logging.config=/usr/local/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
/usr/local/java/jdk1.8.0_301/bin/java: /usr/local/java/jdk1.8.0_301/bin/java: cannot execute binary file
而且无法访问nacos网站
-------------------解决-------------------
使用命令sudo ./startup.sh -m standalone
[root@taotaoyun bin]# sudo ./startup.sh -m standalone
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64/bin/java -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Djava.ext.dirs=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64/jre/lib/ext:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64/lib/ext:/usr/local/nacos/plugins/cmdb:/usr/local/nacos/plugins/mysql -Xloggc:/usr/local/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dnacos.home=/usr/local/nacos -Dloader.path=/usr/local/nacos/plugins/health -jar /usr/local/nacos/target/nacos-server.jar --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/usr/local/nacos/conf/ --logging.config=/usr/local/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
nacos is starting with standalone
nacos is starting,you can check the /usr/local/nacos/logs/start.out
这里显示是一样的,但是我们来看看日志
/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64/bin/java -Xms512m -Xmx512m -Xmn256m -Dnacos.standalone=true -Djava.ext.dirs=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64/jre/lib/ext:/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.302.b08-0.el7_9.x86_64/lib/ext:/usr/local/nacos/plugins/cmdb:/usr/local/nacos/plugins/mysql -Xloggc:/usr/local/nacos/logs/nacos_gc.log -verbose:gc -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=10 -XX:GCLogFileSize=100M -Dnacos.home=/usr/local/nacos -Dloader.path=/usr/local/nacos/plugins/health -jar /usr/local/nacos/target/nacos-server.jar --spring.config.location=classpath:/,classpath:/config/,file:./,file:./config/,file:/usr/local/nacos/conf/ --logging.config=/usr/local/nacos/conf/nacos-logback.xml --server.max-http-header-size=524288
,--.
,--.'|
,--,: : | Nacos 1.1.4
,`--.'`| ' : ,---. Running in stand alone mode, All function modules
| : : | | ' ,'\ .--.--. Port: 8848
: | \ | : ,--.--. ,---. / / | / / ' Pid: 7472
| : ' '; | / \ / \. ; ,. :| : /`./ Console: http://172.18.167.239:8848/nacos/index.html
' ' ;. ;.--. .-. | / / '' | |: :| : ;_
| | | \ | \__\/: . .. ' / ' | .; : \ \ `. https://nacos.io
' : | ; .' ," .--.; |' ; :__| : | `----. \
| | '`--' / / ,. |' | '.'|\ \ / / /`--' /
' : | ; : .' \ : : `----' '--'. /
; |.' | , .-./\ \ / `--'---'
'---' `--`---' `----'
2021-10-10 12:18:30,417 INFO Bean 'org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration' of type [org.springframework.security.config.annotation.configuration.ObjectPostProcessorConfiguration$$EnhancerBySpringCGLIB$$113a6bb2] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-10-10 12:18:30,580 INFO Bean 'objectPostProcessor' of type [org.springframework.security.config.annotation.configuration.AutowireBeanFactoryObjectPostProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-10-10 12:18:30,582 INFO Bean 'org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler@73eb439a' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-10-10 12:18:30,585 INFO Bean 'org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration' of type [org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration$$EnhancerBySpringCGLIB$$360f0e64] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-10-10 12:18:30,606 INFO Bean 'methodSecurityMetadataSource' of type [org.springframework.security.access.method.DelegatingMethodSecurityMetadataSource] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2021-10-10 12:18:31,625 INFO Tomcat initialized with port(s): 8848 (http)
2021-10-10 12:18:31,913 INFO Root WebApplicationContext: initialization completed in 6098 ms
2021-10-10 12:18:37,274 INFO Initializing ExecutorService 'applicationTaskExecutor'
2021-10-10 12:18:37,875 INFO Adding welcome page: class path resource [static/index.html]
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/**/*.css'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/**/*.js'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/**/*.html'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/**/*.map'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/**/*.svg'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/**/*.png'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/**/*.ico'], []
2021-10-10 12:18:38,633 INFO Creating filter chain: Ant [pattern='/console-fe/public/**'], []
2021-10-10 12:18:38,634 INFO Creating filter chain: Ant [pattern='/v1/auth/login'], []
2021-10-10 12:18:38,634 INFO Creating filter chain: Ant [pattern='/v1/console/health/**'], []
2021-10-10 12:18:38,634 INFO Creating filter chain: Ant [pattern='/v1/cs/**'], []
2021-10-10 12:18:38,634 INFO Creating filter chain: Ant [pattern='/v1/ns/**'], []
2021-10-10 12:18:38,634 INFO Creating filter chain: Ant [pattern='/v1/cmdb/**'], []
2021-10-10 12:18:38,634 INFO Creating filter chain: Ant [pattern='/actuator/**'], []
2021-10-10 12:18:38,634 INFO Creating filter chain: Ant [pattern='/v1/console/server/**'], []
2021-10-10 12:18:38,681 INFO Creating filter chain: any request, [org.springframework.security.web.context.request.async.WebAsyncManagerIntegrationFilter@22b53226, org.springframework.security.web.context.SecurityContextPersistenceFilter@5af3a0f, org.springframework.security.web.header.HeaderWriterFilter@338494fa, org.springframework.security.web.authentication.logout.LogoutFilter@5f031ebd, com.alibaba.nacos.console.filter.JwtAuthenticationTokenFilter@1fcb4808, org.springframework.security.web.savedrequest.RequestCacheAwareFilter@10993713, org.springframework.security.web.servletapi.SecurityContextHolderAwareRequestFilter@72cf2de5, org.springframework.security.web.authentication.AnonymousAuthenticationFilter@726e5805, org.springframework.security.web.session.SessionManagementFilter@758c83d8, org.springframework.security.web.access.ExceptionTranslationFilter@4c4d27c8, org.springframework.security.web.access.intercept.FilterSecurityInterceptor@60d1a32f]
2021-10-10 12:18:38,915 INFO Exposing 2 endpoint(s) beneath base path '/actuator'
2021-10-10 12:18:38,961 INFO Initializing ExecutorService 'taskScheduler'
2021-10-10 12:18:39,321 INFO Tomcat started on port(s): 8848 (http) with context path '/nacos'
2021-10-10 12:18:39,339 INFO Nacos Log files: /usr/local/nacos/logs/
2021-10-10 12:18:39,339 INFO Nacos Conf files: /usr/local/nacos/conf/
2021-10-10 12:18:39,339 INFO Nacos Data files: /usr/local/nacos/data/
2021-10-10 12:18:39,340 INFO Nacos started successfully in stand alone mode.
2021-10-10 12:18:41,177 INFO Initializing Servlet 'dispatcherServlet'
2021-10-10 12:18:41,206 INFO Completed initialization in 29 ms
已经启动成功了