必要软件安装
如主机地址为`192.168.117.129`
1.安装MySQL
如mysql端口为`3306`账号为`root`密码为`123456`
2.安装Tomcat
3.安装Nginx
4.安装 zookeeeper
如zookeeper集群地址为`192.168.117.130:2181,192.168.117.129:2181,192.168.117.128:2181`
5.安装 Redis
redis需启动双客户端,如双客户端端口分别为`6379`和`6380`
6.安装maven
下载源码
官网地址:https://github.com/knightliao/disconf
如项目放在`/data/disconf`目录下
`mkdir -p /data/disconf`
下载zip文件,然后上传到`linux`的`/data/disconf`目录下
`yum install -y unzip zip`
`cd /data/disconf`
`unzip disconf-master.zip`
配置临时环境变量
`export ONLINE_CONFIG_PATH=/data/disconf/online-resources`
`export WAR_ROOT_PATH=/data/disconf/war`
`mkdir -p /data/disconf/online-resources`
`mkdir -p /data/disconf/war`
准备配置文件
`cp -r /data/disconf/disconf-master/disconf-web/profile/rd/. /data/disconf/online-resources`
`cd /data/disconf/online-resources`
`mv application-demo.properties application.properties`
构建
`注意`需打开新的shell命令行窗口执行以下命令
`cd /data/disconf/disconf-master/disconf-web`
`export ONLINE_CONFIG_PATH=/data/disconf/online-resources`
`export WAR_ROOT_PATH=/data/disconf/war`
`sh deploy/deploy.sh`
修改配置
`cd /data/disconf/war/WEB-INF/classes`
配置文件包括:
`- jdbc-mysql.properties (数据库配置)`
jdbc.db_0.url=jdbc:mysql://192.168.117.129:3306/disconf?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&rewriteBatchedStatements=false
jdbc.db_0.username=root
jdbc.db_0.password=123456
jdbc.maxPoolSize=20
jdbc.minPoolSize=10
jdbc.initialPoolSize=10
jdbc.idleConnectionTestPeriod=1200
jdbc.maxIdleTime=3600
`- redis-config.properties (Redis配置)`
redis.group1.retry.times=2
redis.group1.client1.name=BeidouRedis1
redis.group1.client1.host=127.0.0.1
redis.group1.client1.port=6379
redis.group1.client1.timeout=5000
redis.group1.client1.password=foobared
redis.group1.client2.name=BeidouRedis2
redis.group1.client2.host=127.0.0.1
redis.group1.client2.port=6380
redis.group1.client2.timeout=5000
redis.group1.client2.password=foobared
redis.evictor.delayCheckSeconds=300
`- zoo.properties (Zookeeper配置)`
hosts=192.168.117.130:2181,192.168.117.129:2181,192.168.117.128:2181
# zookeeper\u7684\u524D\u7F00\u8DEF\u5F84\u540D
zookeeper_url_prefix=/disconf
`- application.properties (应用配置)`
# \u670d\u52a1\u5668\u7684domain
#
domain=disconf.com
#
# \u90ae\u7bb1\u8bbe\u7f6e
#
EMAIL_MONITOR_ON = false
EMAIL_HOST = smtp.163.com
EMAIL_HOST_PASSWORD = password
EMAIL_HOST_USER = [email protected]
EMAIL_PORT = 25
DEFAULT_FROM_EMAIL = [email protected]
#
# \u5b9a\u65f6\u6821\u9a8c\u4e2d\u5fc3\u7684\u914d\u7f6e\u4e0e\u6240\u6709\u5ba2\u6237\u7aef\u914d\u7f6e\u7684\u4e00\u81f4\u6027
#
初始化数据库
`mysql -u root -p 123456`
`source /data/disconf/disconf-master/disconf-web/sql/0-init_table.sql`
`source /data/disconf/disconf-master/disconf-web/sql/1-init_data.sql`
`source /data/disconf/disconf-master/disconf-web/sql/201512/20151225.sql`
`source /data/disconf/disconf-master/disconf-web/sql/20160701/20160701.sql`
配置tomcat,部署war包
修改tomcat的server.xml文件,在Host结点下设定Context
`
`并设置端口为 8015`
配置Nginx
在http这个标记对里面加上如下配置
upstream disconf {
server 192.168.117.129:8015;
}
server {
listen 8081;
server_name 192.168.117.129;
access_log /data/disconf/access.log;
error_log /data/disconf/error.log;
location / {
root /data/disconf/war/html;
if ($query_string) {
expires max;
}
}
location ~ ^/(api|export) {
proxy_pass_header Server;
proxy_set_header Host $host:8081;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://disconf;
}
}
启动
启动MySQL
启动redis(多实例启动,端口:6379、6380)
启动zookeeper(单机伪分布集群)
启动nginx
启动tomcat
打开浏览器:http://192.168.117.129:8081/
使用用户名admin和密码admin进入系统
至此disconf的web操作服务搭建完成