ApolloConfing —— shell安装Apollo
简介
- 客户端(安装MySQL客户端)
- 数据(初始化数据库和数据表)
- 三应用(安装Apollo conifg、admin、protal修改配置并启动)
shell
客户端
> echo "[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/7/\$basearch/
enabled=1
gpgcheck=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql" > /etc/yum.repos.d/mysql-community.repo
> more /etc/yum.repos.d/mysql-community.repo
> yum clean all
> yum install -y mysql-community-client
数据
currentTime=`date +%Y-%m-%d-%H-%M-%S`
Shell='[Shell]'
echo_info() {
echo "\033[30;32mINFO:\033[0m $Shell$currentTime $1"
}
apolloConfigDBSQL=https://xxxx/ApolloConfigDB-fat.sql
apolloPortalDB=https://xxxx/ApolloPortalDB-fat.sql
msqlUrl=jdbc:mysql://1234567:3306/ApolloConfigDB?characterEncoding=utf8
mysqlUser=root
mysqlPassword=root
echo_info '开始下载ApolloConfigDB-fat.sql'
wget $apolloConfigDBSQL
echo_info '结束下载ApolloConfigDB-fat.sql'
echo_info '开始安装ApolloConfigDB-fat.sql'
mysql -h$msqlUrl -P3306 -u$mysqlUser -p$mysqlPassword -DApolloConfigDB < ApolloConfigDB-fat.sql
echo_info '结束安装ApolloConfigDB-fat.sql'
echo_info '开始下载ApolloPortalDB-fat.sql'
wget $apolloPortalDB
echo_info '结束下载ApolloPortalDB-fat.sql'
echo_info '开始安装ApolloPortalDB-fat.sql'
mysql -h$msqlUrl -P3306 -u$mysqlUser -p$mysqlPassword < ApolloPortalDB-fat.sql
echo_info '结束安装ApolloPortalDB-fat.sql'
三应用
currentTime=`date +%Y-%m-%d-%H-%M-%S`
Shell='[Shell]'
echo_info() {
echo "\033[30;32mINFO:\033[0m $Shell$currentTime $1"
}
downloadApolloConfigUrl=https://github.com/apolloconfig/apollo/releases/download/v1.4.0/apollo-configservice-1.4.0-github.zip
downloadApolloAdminUrl=https://github.com/apolloconfig/apollo/releases/download/v1.4.0/apollo-adminservice-1.4.0-github.zip
downloadApolloPortalUrl=https://github.com/apolloconfig/apollo/releases/download/v1.4.0/apollo-portal-1.4.0-github.zip
portalMetaLocalPost=http://localhost:8080
portalMetaDevPost=http://localhost:8080
portalMetaFatPost=http://localhost:8080
portalMetaUatPost=http://localhost:8080
portalMetaLptPost=http://localhost:8080
portalMetaProPost=http://localhost:8080
mysqlConfigUrl=jdbc:mysql://1234567:3306/ApolloConfigDB?characterEncoding=utf8
mysqlPortalUrl=jdbc:mysql://1234567:3306/ApolloPortalDB?characterEncoding=utf8
mysqlUser=root
mysqlPassword=root
su worker
dataServerPath="/Users/changyang/data/server/"
if [ ! -d "$dataServerPath" ]; then
mkdir $dataServerPath
else
echo_info '文件夹已存在'
echo_info '进入文件夹'
cd $dataServerPath
fi
echo_info '开始下载ApolloConfig'
wget $downloadApolloConfigUrl
echo_info '结束下载ApolloConfig'
echo_info '开始解压ApolloConfig'
unzip apollo-configservice-1.4.0-github.zip -d apollo-configservice
echo_info '结束解压ApolloConfig'
echo_info '开始修改ApolloConfig config'
apolloConfigConfigPath=$dataServerPath'apollo-configservice/config/application-github.properties'
sed -i -e "s#^spring.datasource.url = .*#spring.datasource.url = ${mysqlConfigUrl}#g" ${apolloConfigConfigPath}
sed -i -e "s#^spring.datasource.username = .*#spring.datasource.username = ${mysqlUser}#g" ${apolloConfigConfigPath}
sed -i -e "s#^spring.datasource.password = .*#spring.datasource.password = ${mysqlPassword}#g" ${apolloConfigConfigPath}
echo_info '结束修改ApolloConfig config'
echo_info '开始启动ApolloConfig'
sh ./apollo-configservice/scripts/startup.sh > config_start.log 2>&1
echo_info '结束启动ApolloConfig'
cd $dataServerPath
echo_info '开始下载ApolloAdmin'
wget $downloadApolloAdminUrl
echo_info '结束下载ApolloAdmin'
echo_info '开始解压ApolloAdmin'
unzip apollo-adminservice-1.4.0-github.zip -d apollo-adminservice
echo_info '结束解压ApolloAdmin'
echo_info '开始修改ApolloAdmin Config'
apolloAdminConfigPath=$dataServerPath'apollo-adminservice/config/application-github.properties'
sed -i -e "s#^spring.datasource.url = .*#spring.datasource.url = ${mysqlConfigUrl}#g" ${apolloAdminConfigPath}
sed -i -e "s#^spring.datasource.username = .*#spring.datasource.username = ${mysqlUser}#g" ${apolloAdminConfigPath}
sed -i -e "s#^spring.datasource.password = .*#spring.datasource.password = ${mysqlPassword}#g" ${apolloAdminConfigPath}
echo_info '结束修改ApolloAdmin Config'
echo_info '开始启动ApolloAdmin'
sh ./apollo-adminservice/scripts/startup.sh > admin_start.log 2>&1
echo_info '结束启动ApolloAdmin'
cd $dataServerPath
echo_info '开始下载ApolloPortal'
wget $downloadApolloPortalUrl
echo_info '结束下载ApolloPortal'
echo_info '开始解压ApolloPortal'
unzip apollo-portal-1.4.0-github.zip -d apollo-portal
echo_info '结束解压ApolloPortal'
echo_info '开始修改ApolloPortal Config'
apolloPortalConfigPath=$dataServerPath'apollo-portal/config/application-github.properties'
sed -i -e "s#^spring.datasource.url = .*#spring.datasource.url = ${mysqlPortalUrl}#g" ${apolloPortalConfigPath}
sed -i -e "s#^spring.datasource.username = .*#spring.datasource.username = ${mysqlUser}#g" ${apolloPortalConfigPath}
sed -i -e "s#^spring.datasource.password = .*#spring.datasource.password = ${mysqlPassword}#g" ${apolloPortalConfigPath}
echo_info '结束修改ApolloPortal Config'
echo_info '开始修改ApolloPortal Meta Service'
apolloPortalMetaPath=$dataServerPath'apollo-portal/config/apollo-env.properties'
sed -i -e "s#^local.meta=.*#local.meta=${portalMetaLocalPost}#g" ${apolloPortalMetaPath}
sed -i -e "s#^dev.meta=.*#dev.meta=${portalMetaDevPost}#g" ${apolloPortalMetaPath}
sed -i -e "s#^fat.meta=.*#fat.meta=${portalMetaFatPost}#g" ${apolloPortalMetaPath}
sed -i -e "s#^uat.meta=.*#uat.meta=${portalMetaUatPost}#g" ${apolloPortalMetaPath}
sed -i -e "s#^lpt.meta=.*#lpt.meta=${portalMetaLocalPost}#g" ${apolloPortalMetaPath}
sed -i -e "s#^pro.meta=.*#pro.meta=${portalMetaProPost}#g" ${apolloPortalMetaPath}
echo_info '结束修改ApolloPortal Meta Service'
echo_info '开始启动ApolloPortal'
sh ./apollo-portal/scripts/startup.sh > portal_start.log 2>&1
echo_info '结束启动ApolloPortal'
|