搭建springCloud开发环境

摘要: centos7.3搭建springcloud开发环境

搭建开发环境

1.ssh

1
2
3
4
5
[root@paascloud-test-001 ~]# yum -y install openssh*
[root@paascloud-test-001 ~]# systemctl stop firewalld.service
[root@paascloud-test-001 ~]# systemctl disable firewalld.service
[root@paascloud-test-001 ~]# systemctl start sshd.service
[root@paascloud-test-001 ~]# systemctl restart network.service

2.设置hostsname

1
2
3
4
5
6
7
8
9
[root@paascloud-test-001 ~]# hostnamectl set-hostname paascloud-test-001
[root@paascloud-test-001 ~]# hostnamectl set-hostname paascloud-test-002
[root@paascloud-test-001 ~]# hostnamectl set-hostname paascloud-test-003
[root@paascloud-test-001 tool]# vi /etc/hosts
192.168.241.151 paascloud-test-001
192.168.241.152 paascloud-test-002
192.168.241.153 paascloud-test-003

设置静态IP

1
2
3
4
5
6
7
8
9
10
11
[root@paascloud-test-001 ~]# vi /etc/sysconfig/network
# Created by anaconda
NETWORKING=yes
GATEWAY=192.168.241.2
[root@paascloud-test-001 ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33
ONBOOT="yes"
BOOTPROTO=static
IPADDR=192.168.140.151
NETMASK=255.255.255.0
DNS1=192.168.240.2(即为你的网关IP 也可以设置8.8.8.8或者你电脑的DNS既距离你最近的DNS服务器)
[root@paascloud-test-001 ~]# systemctl restart network.service

3.准备开发工具包

1
2
3
4
5
6
7
8
9
10
11
12
[root@paascloud-test-001 src]# pwd
/usr/local/src
-rw-r--r--. 1 root root 8534562 8月 15 12:49 apache-maven-3.5.0-bin.tar.gz
-rw-r--r--. 1 root root 1790 8月 15 08:26 initial-setup-ks.cfg
-rw-r--r--. 1 root root 169983496 8月 15 12:49 jdk-8u131-linux-x64.rpm
-rw-r--r--. 1 root root 73187012 8月 15 12:49 nexus-2.14.5-02-bundle.tar.gz
-rw-r--r--. 1 root root 1550261 8月 15 12:49 redis-3.2.10.tar.gz
-rw-r--r--. 1 root root 22724574 8月 15 12:49 zookeeper-3.4.9.tar.gz
[root@paascloud-test-001 src]# scp -r tool/ root@paascloud-test-002:/usr/local/src/
[root@paascloud-test-001 src]# scp -r tool/ root@paascloud-test-003:/usr/local/src/

4.安装开发环境

这里只展示第一台虚拟机的安装过程, 其他虚拟机类似

4.1 安装JDK

  • 安装
1
2
3
4
5
6
7
8
9
10
11
12
13
[root@paascloud-test-001 tool]# rpm -ivh jdk-8u131-linux-x64.rpm
准备中... ################################# [100%]
正在升级/安装...
1:jdk1.8.0_131-2000:1.8.0_131-fcs ################################# [100%]
Unpacking JAR files...
tools.jar...
plugin.jar...
javaws.jar...
deploy.jar...
rt.jar...
jsse.jar...
charsets.jar...
localedata.jar...
  • 查看 jdk安装目录
1
2
[root@paascloud-test-001 tool]# ls /usr/java/
default/ jdk1.8.0_131/ latest/
  • 配置环境变量

    1
    2
    3
    4
    5
    6
    7
    8
    9
    [root@paascloud-test-001 tool]# alias vi="vim"
    [root@paascloud-test-001 tool]# vi /etc/profile
    JAVA_HOME=/usr/java/jdk1.8.0_131
    JRE_HOME=/usr/java/jdk1.8.0_131/jre
    PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin
    CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$JRE_HOME/lib
    export JAVA_HOME JRE_HOME PATH CLASSPATH
    [root@paascloud-test-001 tool]# source /etc/profile
    [root@paascloud-test-001 tool]# echo $PATH
  • 查看jdk版本

1
2
3
4
[root@paascloud-test-001 tool]# java -version
openjdk version "1.8.0_141"
OpenJDK Runtime Environment (build 1.8.0_141-b16)
OpenJDK 64-Bit Server VM (build 25.141-b16, mixed mode)

4.2 安装MAVEN

  • 安装

    1
    2
    [root@paascloud-test-001 tool]# tar -zxvf /usr/local/src/tool/apache-maven-3.5.0-bin.tar.gz -C /usr/local/
    [root@paascloud-test-001 tool]# mv /usr/local/apache-maven-3.5.0/ /usr/local/maven
  • 配置环境变量

    1
    2
    3
    4
    [root@paascloud-test-001 tool]# vi /etc/profile
    #set maven environment
    export M2_HOME=/usr/local/maven
    export PATH=$M2_HOME/bin:$PATH
  • 查看版本号

    1
    2
    3
    4
    5
    6
    7
    8
    [root@paascloud-test-001 tool]# source /etc/profile
    [root@paascloud-test-001 tool]# mvn -version
    Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
    Maven home: /usr/local/maven
    Java version: 1.8.0_131, vendor: Oracle Corporation
    Java home: /usr/java/jdk1.8.0_131/jre
    Default locale: zh_CN, platform encoding: UTF-8
    OS name: "linux", version: "3.10.0-514.el7.x86_64", arch: "amd64", family: "unix"

4.3 安装MAVEN私服

由于版本3.x 第三方私服库必须使用命令, 而我本人较懒我这里使用的版本是nexus-2.14.5-02-bundle

  • 安装
    1
    2
    3
    [root@paascloud-test-001 tool]# mkdir /usr/local/nexus
    [root@paascloud-test-001 tool]# tar -zxvf /usr/local/src/tool/nexus-2.14.5-02-bundle.tar.gz -C /usr/local/
    [root@paascloud-test-001 tool]# mv /usr/local/nexus-2.14.5-02/ /usr/local/nexus

由于使用root用户 这里需要配置环境变量 否则会出现如下警告

1
2
3
4
5
[root@paascloud-test-001 tool]# /usr/local/nexus/nexus-2.14.5-02/bin/nexus start
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.
  • 配置环境变量

    1
    2
    3
    [root@paascloud-test-001 tool]# vi /etc/profile
    #set nexus environment
    export RUN_AS_USER=root
  • 启动

1
2
3
4
5
[root@paascloud-test-001 tool]# /usr/local/nexus/nexus-2.14.5-02/bin/nexus start
[root@paascloud-test-001 tool]# /usr/local/nexus/nexus-2.14.5-02/bin/nexus status
****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************

http://192.168.241.151:8081/nexus 默认用户名密码 amdin admin123

  • 配置

这里写图片描述

settings.xml

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<!--配置权限,使用默认用户-->
<servers>
<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>
<profiles>
<profile>
<id>paascloud</id>
<activation>
<activeByDefault>true</activeByDefault>
<jdk>1.8</jdk>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
<repositories>
<!-- 私有库地址-->
<repository>
<id>nexus</id>
<url>http://192.168.241.151:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
<repository>
<id>sonatype-nexus-staging</id>
<name>Sonatype Nexus Staging</name>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<!--插件库地址-->
<pluginRepository>
<id>nexus</id>
<url>http://192.168.241.151:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
</profiles>
<!--激活profile-->
<activeProfiles>
<activeProfile>paascloud</activeProfile>
</activeProfiles>

4.4 安装docker

4.5 docker下安装mysql

1
2
3
4
[root@paascloud-test-001 tool]# docker pull index.tenxcloud.com/tenxcloud/mysql
docker run -d -p 3306:3306 -e MYSQL_PASS="123456" --restart=always --name mysql3306 index.tenxcloud.com/tenxcloud/mysql
ip 192.168.241.151 user: admin pwd: 123456

4.6 docker下安装redis

1
2
[root@paascloud-test-001 paascloud-master]# docker pull index.tenxcloud.com/tenxcloud/redis
[root@paascloud-test-001 paascloud-master]# docker run -d -p 6379:6379 -e REDIS_PASS="123456" --restart=always --name redis6379 index.tenxcloud.com/tenxcloud/redis

4.7 docker下安装rabbitmq

1
2
3
[root@paascloud-test-001 paascloud-master]# docker pull index.tenxcloud.com/tenxcloud/rabbitmq
[root@paascloud-test-001 paascloud-master]# docker run -d -p 5672:5672 -p 15672:15672 --restart=always -e RABBITMQ_PASS="123456" --name rabbitmq15672 index.tenxcloud.com/tenxcloud/rabbitmq
控制台地址: http://192.168.241.151:15672/ user: admin pwd:123456

4.8 安装nodeJs 8.3

1
2
# yum install -y gcc-c++ make
https://nodejs.org/en/download/package-manager/
评论