micro service system configuration(2)-CMP配置中心,micro-cmp
1.配置yum源
vi/etc/yum.repos.d/mariadb.repo
[mariadb] name = MariaDBbaseurl = https://mirrors.ustc.edu.cn/mariadb/yum/10.2/centos7-amd64gpgkey=https://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1
2.yum安装
yum -yinstall MariaDB-server MariaDB-client
3.启动服务
systemctlstart mariadb
4.设置开机启动
systemctlenable mariadb
5.设置密码
mysql_secure_installation
6.配置字符集
客户端:vi/etc/my.cnf.d/mysql-clients.cnf
[mysql]default-character-set=utf8
服务端:vi/etc/my.cnf.d/server.cnf
[mysqld] init_connect='SETcollation_connection = utf8_general_ci' init_connect='SET NAMES utf8'character-set-server=utf8 collation-server=utf8_general_ciskip-character-set-client-handshake #开启慢查询 slow_query_log= ON slow_query_log_file = /usr/local/mysql/data/slow.log long_query_time = 1
7.重启
systemctlrestart mariadb
8.设置root可远程连接
mysql -uroot-y
GRANT ALL PRIVILEGES ON *.* TO'root'@'%'IDENTIFIED BY '1qazxsw2' WITH GRANT OPTION;
flush privileges;
来自 <https://note.youdao.com/share/iframe.html>
先要部署IAM,配置中心依赖于IAM,
各个服务请求配置中心时,配置中心会IAM发起鉴权
环境初始化
jdk1.8
maridb10.20(数据库要配置全局小写,lower_case_table_names=0 )
初始化数据库
不一定是最新的,最好找一份最新的
http://172.16.24.72/tool/apollo/configdb.sql
http://172.16.24.72/tool/apollo/portaldb.sql
下载
mkdir /opt/apollo
cd /opt/apollo
wget http://172.16.24.72/tool/apollo/apollo-configservice-0.8.1-github.zip
wget http://172.16.24.72/tool/apollo/apollo-adminservice-0.8.1-github.zip
wget http://172.16.24.72/tool/apollo/apollo-portal-0.8.1-github.zip
部署Config Service
-- 解压
unzipapollo-configservice-0.8.1-github.zip -d config-service
cd config-service
-- 新建配置文件application-github.properties & 注意替换数据库配置信息
touchapplication-github.properties
echo "spring.datasource.url=jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8">> application-github.properties
echo"spring.datasource.username=root">> application-github.properties
echo'spring.datasource.password=!qazxsw2' >>application-github.properties
-- 如果服务器是浮动ip(也就是外网访问的 IP 并没有在网卡上面),需要在 startup.sh 里面添加下面内容
exportJAVA_OPTS="$JAVA_OPTS -Deureka.instance.ip-address={浮动公网ip}"
-- 启动,不传IAM地址则默认为iam-bate.chinac.com
sh scripts/startup.sh http://127.0.0.1:8081
部署Admin Service
-- 解压
unzipapollo-adminservice-0.8.1-github.zip -d admin-service
cd admin-service
-- 新建配置文件application-github.properties & 注意替换数据库配置信息
touchapplication-github.properties
echo"spring.datasource.url=jdbc:mysql://127.0.0.1:3306/ApolloConfigDB?characterEncoding=utf8">> application-github.properties
echo"spring.datasource.username=root">> application-github.properties
echo 'spring.datasource.password=!qazxsw2'>> application-github.properties
-- 如果服务器是浮动ip(也就是外网访问的 IP 并没有在网卡上面),需要在 startup.sh 里面添加下面内容
exportJAVA_OPTS="$JAVA_OPTS -Deureka.instance.ip-address={浮动公网ip}"
-- 启动,不传IAM地址则默认为iam-bate.chinac.com
sh scripts/startup.sh http://127.0.0.1:8081
部署Portal Service
-- 解压
unzip apollo-portal-0.8.1-github.zip-d portal-service
cd portal-service
-- 新建配置文件application-github.properties & 注意替换数据库配置信息
touchapplication-github.properties
echo"spring.datasource.url=jdbc:mysql://127.0.0.1:3306/ApolloPortalDB?characterEncoding=utf8">> application-github.properties
echo"spring.datasource.username=root">> application-github.properties
echo'spring.datasource.password=!qazxsw2' >>application-github.properties
-- 修改 script/startup.sh 添加如下内容,env 可用值为 uat,dev,fat,pro,分别对应模拟环境,开发环境,QA环境,生产环境
export JAVA_OPTS="$JAVA_OPTS-Ddev_meta=http://172.16.78.229:8080"
追加在该行下面
-- 启动
sh scripts/startup.sh
删除无用集群
1. 用 admin 登陆,拿到 cookies,具体见图
2. 带 cookie 发起请求
delete{portal}/apps/{appId}/envs/{env}/clusters/{clusterName:.+}
delete http://172.16.78.229:9999/apps/ms-user/envs/DEV/clusters/moni-node2
如果是 postman ,需要开启,才能发送带 cookies 的请求
在header中添加
Cookie
JSESSIONID=78D940B4162FD5E05C3CC830D304BD23
来自 <https://note.youdao.com/share/iframe.html>
实际部署的时候这一步也是要做的:
Env(Ddev)可用值为 uat,dev,fat,pro, 从数据库中可以找到对应的值, 如有多个环境,需要加空格累加。