一、下載apollo
1.github下載地址:https://github.com/ctripcorp/apollo/releases
2.網盤下載:(網盤包含apolloconfigdb.sql和 apolloportaldb.sql 文件,非常重要)
鏈接:https://pan.baidu.com/s/1Muhep2ysWgY5OoKokwMXCw
提取碼:6di8
依賴環境:java、mysql 數據庫安裝地址如下:
java:https://blog.csdn.net/QWERTY55555/article/details/105435042
mysql :https://blog.csdn.net/QWERTY55555/article/details/105713013
二、上傳到服務器並解壓
# 新建文件夾tools/soft
mkdir -p /tools/soft
# 上傳
cd /tools/soft
rz -be
# 解壓將安裝包解壓到 /tools 目錄下
unzip /tools/soft/apollo-adminservice-1.3.0-github.zip -d /tools/apollo-adminservice-1.3.0-github
unzip /tools/soft/apollo-configservice-1.3.0-github.zip -d /tools/apollo-configservice-1.3.0-github
unzip /tools/soft/apollo-portal-1.3.0-github.zip -d /tools/apollo-portal-1.3.0-github
三、修改3個服務文件/config/application-github.properties (mysql數據庫配置)
# 修改 adminservice服務application-github.properties文件
vi /tools/apollo-adminservice-1.3.0-github/config/application-github.properties
內容如下:
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456
# 修改configservice服務application-github.properties文件
vi /tools/apollo-configservice-1.3.0-github/config/application-github.properties
內容如下:
# DataSource
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456
# 修改portal服務application-github.properties文件
vi /tools/apollo-portal-1.3.0-github/config/application-github.properties
內容如下:
# DataSource
spring.datasource.url = jdbc:mysql://127.0.0.1:3306/ApolloPortalDB?characterEncoding=utf8
spring.datasource.username = root
spring.datasource.password = 123456
ps: 配置爲數據庫地址、用戶名和密碼
四、mysql導入數據表
[root@miguvideo-6 tools]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 936
Server version: 5.7.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
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.
mysql> source /tools/soft/apolloportaldb.sql;
mysql> source /tools/soft/apolloconfigdb.sql;
mysql> exit
五、修改apollo-portal 服務apollo-env.properties文件
[root@miguvideo-6 config]# vi /tools/apollo-portal-1.3.0-github/config/apollo-env.properties
修改內容如下:
local.meta=http://10.150.200.95:8080
dev.meta=http://10.150.200.95:8080 # 爲configservice服務地址,這裏我的機器ip爲10.150.200.95
fat.meta=http://fill-in-fat-meta-server:8080
uat.meta=http://fill-in-uat-meta-server:8080
lpt.meta=${lpt_meta}
pro.meta=http://fill-in-pro-meta-server:8080
六、修改數據庫
[root@miguvideo-6 config]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 939
Server version: 5.7.19 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
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.
mysql> update ServerConfig set Value="http://10.150.200.95:8080/eureka/" where Id="1";
mysql> FLUSH PRIVILEGES;
七、新建啓動服務和停止服務腳本
# 新建startup.sh
vi /tools/startup.sh
內容如下:
/tools/apollo-configservice-1.3.0-github/scripts/startup.sh
/tools/apollo-adminservice-1.3.0-github/scripts/startup.sh
/tools/apollo-portal-1.3.0-github/scripts/startup.sh
# 新建shutdown.sh
vi /tools/shutdown.sh
#!/bin/bash
/tools/apollo-adminservice-1.3.0-github/scripts/shutdown.sh
/tools/apollo-configservice-1.3.0-github/scripts/shutdown.sh
/tools/apollo-portal-1.3.0-github/scripts/shutdown.sh
八、啓動服務
# 執行腳本
sh /tools/startup.sh
九、驗證是否啓動成功
[root@miguvideo-6 100003172]# curl localhost:8070/signin
<!DOCTYPE html>
<html lang="en" ng-app="login">
<head>
<meta charset="UTF-8">
<title>Apollo配置中心</title>
<link rel="icon" href="./img/config.png">
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<link rel="stylesheet" href="vendor/font-awesome.min.css">
<style type="text/css">
body {
padding-top: 90px;
background: #F7F7F7;
color: #666666;
font-family: 'Roboto', sans-serif;
font-weight: 100;
}
body {
width: 100%;
background: -webkit-linear-gradient(left, #22d686, #24d3d3, #22d686, #24d3d3);
background: linear-gradient(to right, #22d686, #24d3d3, #22d686, #24d3d3);
background-size: 600% 100%;
}
.panel {
border-radius: 5px;
}
label {
font-weight: 300;
}
.panel-login {
border: none;
-webkit-box-shadow: 0px 0px 49px 14px rgba(188, 190, 194, 0.39);
-moz-box-shadow: 0px 0px 49px 14px rgba(188, 190, 194, 0.39);
box-shadow: 0px 0px 49px 14px rgba(188, 190, 194, 0.39);
}
.panel-login .checkbox input[type=checkbox] {
margin-left: 0px;
}
.panel-login .checkbox label {
padding-left: 25px;
font-weight: 300;
display: inline-block;
position: relative;
}
.panel-login .checkbox {
padding-left: 20px;
}
.panel-login .checkbox label::before {
content: "";
display: inline-block;
position: absolute;
width: 17px;
height: 17px;
left: 0;
margin-left: 0px;
border: 1px solid #cccccc;
border-radius: 3px;
background-color: #fff;
-webkit-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
-o-transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
transition: border 0.15s ease-in-out, color 0.15s ease-in-out;
}
.panel-login .checkbox label::after {
display: inline-block;
position: absolute;
width: 16px;
height: 16px;
left: 0;
top: 0;
margin-left: 0px;
padding-left: 3px;
padding-top: 1px;
font-size: 11px;
color: #555555;
}
.panel-login .checkbox input[type="checkbox"] {
opacity: 0;
}
.panel-login .checkbox input[type="checkbox"]:focus + label::before {
outline: thin dotted;
outline: 5px auto -webkit-focus-ring-color;
outline-offset: -2px;
}
.panel-login .checkbox input[type="checkbox"]:checked + label::after {
font-family: 'FontAwesome';
content: "\f00c";
}
.panel-login > .panel-heading .tabs {
padding: 0;
}
.panel-login h2 {
font-size: 20px;
font-weight: 300;
margin: 30px;
}
.panel-login > .panel-heading {
color: #848c9d;
background-color: #e8e9ec;
border-color: #fff;
text-align: center;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
border-top-left-radius: 0px;
border-top-right-radius: 0px;
border-bottom: 0px;
padding: 0px 15px;
}
.panel-login .form-group {
padding: 0 30px;
}
.panel-login > .panel-heading .login {
padding: 20px 30px;
border-bottom-leftt-radius: 5px;
}
.panel-login > .panel-heading .register {
padding: 20px 30px;
background: #2d3b55;
border-bottom-right-radius: 5px;
}
.panel-login > .panel-heading a {
text-decoration: none;
color: #666;
font-weight: 300;
font-size: 16px;
-webkit-transition: all 0.1s linear;
-moz-transition: all 0.1s linear;
transition: all 0.1s linear;
}
.panel-login > .panel-heading a#register-form-link {
color: #fff;
width: 100%;
text-align: right;
}
.panel-login > .panel-heading a#login-form-link {
width: 100%;
text-align: left;
}
.panel-login input[type="text"], .panel-login input[type="email"], .panel-login input[type="password"] {
height: 45px;
border: 0;
font-size: 16px;
-webkit-transition: all 0.1s linear;
-moz-transition: all 0.1s linear;
transition: all 0.1s linear;
-webkit-box-shadow: none;
box-shadow: none;
border-bottom: 1px solid #e7e7e7;
border-radius: 0px;
padding: 6px 0px;
}
.panel-login input:hover,
.panel-login input:focus {
outline: none;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
border-color: #ccc;
}
.btn-login {
background-color: #E8E9EC;
outline: none;
color: #2D3B55;
font-size: 14px;
height: auto;
font-weight: normal;
padding: 14px 0;
text-transform: uppercase;
border: none;
border-radius: 0px;
box-shadow: none;
}
.btn-login:hover,
.btn-login:focus {
color: #fff;
background-color: #2D3B55;
}
.forgot-password {
text-decoration: underline;
color: #888;
}
.forgot-password:hover,
.forgot-password:focus {
text-decoration: underline;
color: #666;
}
.btn-register {
background-color: #E8E9EC;
outline: none;
color: #2D3B55;
font-size: 14px;
height: auto;
font-weight: normal;
padding: 14px 0;
text-transform: uppercase;
border: none;
border-radius: 0px;
box-shadow: none;
}
.btn-register:hover,
.btn-register:focus {
color: #fff;
background-color: #2D3B55;
}
</style>
</head>
<body>
<div class="container" ng-controller="LoginController">
<div class="row">
<div class="col-md-6 col-md-offset-3">
<div class="panel panel-login">
<div class="panel-body">
<div class="row">
<div class="col-lg-12">
<form id="login-form" action="/signin" method="post" role="form" style="display: block;">
<p class="text-center"><img src="img/logo-detail.png" style="width: 500px;"></p>
<div class="form-group">
<input type="text" name="username" tabindex="1" class="form-control"
placeholder="Username" value="">
</div>
<div class="form-group">
<input type="password" name="password" tabindex="2"
class="form-control" placeholder="Password">
</div>
<div class="form-group" style="color: red">
<small ng-bind="info"></small>
</div>
<div class="col-xs-12 form-group pull-right">
<input type="submit" name="login-submit" id="login-submit" tabindex="4"
class="form-control btn btn-login" value="登錄">
</div>
</form>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- jquery.js -->
<script src="vendor/jquery.min.js" type="text/javascript"></script>
<!-- bootstrap.js -->
<script src="vendor/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
<!--angular-->
<script src="vendor/angular/angular.min.js"></script>
<script src="vendor/angular/angular-resource.min.js"></script>
<script src="vendor/angular/angular-toastr-1.4.1.tpls.min.js"></script>
<script src="vendor/angular/loading-bar.min.js"></script>
<script type="application/javascript" src="scripts/app.js"></script>
<script type="application/javascript" src="scripts/AppUtils.js"></script>
<script type="application/javascript" src="scripts/directive/directive.js"></script>
<script type="application/javascript" src="scripts/controller/LoginController.js"></script>
<script type="application/javascript">
$(function () {
$('#login-form-link').click(function (e) {
$("#login-form").delay(100).fadeIn(100);
$("#register-form").fadeOut(100);
$('#register-form-link').removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
$('#register-form-link').click(function (e) {
$("#register-form").delay(100).fadeIn(100);
$("#login-form").fadeOut(100);
$('#login-form-link').removeClass('active');
$(this).addClass('active');
e.preventDefault();
});
});
</script>
</body>
</html>