A. The need to increase multi-profile configuration in the startup configuration file (application.yml or application.properties) in
spring:
application:
name: eureka
---#注意这里是三个"减号"
spring:
profiles: eureka1
security:
basic:
enabled: true
user:
name: user
password: password123
server:
port: 8761
eureka:
instance:
hostname: eureka1
client:
service-url:
defaultZone: http://user:password123@eureka2:8762/eureka
---#注意这里是三个"减号"
spring:
profiles: eureka2
security:
basic:
enabled: true
user:
name: user
password: password123
server:
port : 8762
eureka:
instance:
hostname: eureka2
client:
service-url:
defaultZone: http://user:password123@eureka1:8761/eureka
II. Adding parameters to start at boot time
nohup java -jar eureka.jar --spring.profiles.active=eureka1 > eureka1.out &
Description:
1.nohup and final & means to start programs when running in the background, do not play log After execution of this command, ssh and turn off after the current process will not stop.
2.java -jar eureka.jar expressed eureka.jar start with java command in the form of jar package
parameters 3.-spring.profiles.active = eureka1 minus two and the background represents startup loader spring.profiles name for eureka1 the series of parameters, represented in the above example loaded following parameters:
spring:
profiles: eureka1
security:
basic:
enabled: true
user:
name: user
password: password123
server:
port: 8761
eureka:
instance:
hostname: eureka1
client:
service-url:
defaultZone: http://user:password123@eureka2:8762/eureka
4.> eureka1.out shows a log output to eureka1.out
Third, the need to increase the hosts configuration file name mapping
windows system stored in the file: C: \ Windows \ System32 \ the Drivers \ etc \ hosts
Linux system stored in the file: / etc / hosts
my files amended as follows:
# localhost name resolution is handled within DNS itself.
127.0.0.1 localhost eureka1 eureka2
# ::1 localhost
If the windows system is win7 or later, when modifying the hosts file, you need to run notepad as administrator and open the hosts file
Tips: If you start deploying eureka clusters on the same server, you only need to deploy a jar, just need to start twice, and were using the -spring.profiles.active parameters to achieve different load profiles when the two starts the content.