创业公司基础设施如何搭建(三) —— Confluence(Do
2020-02-15 本文已影响0人
天行者YANG
知识库
DevOps、敏捷管理,对于整体流程和团队,2个工具是最不能少的,而且使用频率非常高,知识库 + 问题跟踪,我用的是Confluence + Jira,工欲善其事必先利其器,我们先需要把工具选择和准备好,再开始后面的事情,下面介绍下Confluence的安装流程
为什么是Confluence
- 丰富的知识库相关的模板
- 在线协作编辑
- 每个人的知识可以分享给全公司的人
- 评论功能和提醒功能完美结合,随时随地得到最新知识库更新
- 和JIRA结合完美
工具包准备
- atlassian-confluence-6.9.0 官方下载地址
- 我的百度网盘也有6.9.0包 - 密码:79sq
- atlassian-extras-decoder-v2-3.3.0.jar - 密码:pw64
- patch工具 - 密码:p3l2
安装和启动
这里介绍2种安装和启动方式
- 传统安装启动方式
- Docker安装启动方式(推荐)
1.传统安装和启动
需要准备
- CentOS 7.x
- JDK 1.8(配置好JAVA_HOME)
- MYSQL 5.7.X(二进制安装或者Docker镜像)
一顿操作猛如虎。。。
## 解压安装包
cd your-path
tar -xvf atlassian-confluence-6.9.0.tar.gz
## 指定工作目录
vi /your-path/atlassian-confluence-6.9.0/confluence/WEB-INF/classes/confluence-init.properties
# 在文件中加入 confluence.home=/your-home-path/
## 用下载的atlassian-extras-decoder-v2-3.3.0.jar覆盖原有Jar
cp -aR /your-path/atlassian-extras-decoder-v2-3.3.0.jar /your-path/atlassian-confluence-6.9.0/confluence/WEB-INF/lib/
## mysql的驱动Jar去官网下载一个适合5.7的即可
cp mysql-connector-java-5.1.45.jar /your-path/atlassian-confluence-6.9.0/confluence/WEB-INF/lib
## 启动
/your-path/atlassian-confluence-6.9.0/bin/start-confluence.sh
# 默认是8090端口,在浏览器打开http://localhost:8090
2.Docker安装启动方式
需要准备
- Docker
由于官方已经有镜像,我们在官方镜像上面加入自定义的内容即可,官方的6.9.0的Dockerfile的Repo地址,我们需要的是红框的2个文件,如下:
我在本地Mac上面建立了一个Docker Build目录,包含下面几个文件
- Dockerfile(上面的官方repo下载)
- atlassian-confluence-6.9.0.tar.gz(官方二进制包,主要是Dockerfile里面的Curl自动下载的速度实在是慢的可以,我在提前下载好,COPY进去,这块不是非必须用这个包,可以依赖Dockerfile的Curl到官方下载安装包)
- atlassian-extras-decoder-v2-3.3.0.jar(百度网盘工具包)
- docker-entrypoint.sh(上面的官方repo下载)
修改Dockerfile
FROM openjdk:8-alpine
# Setup useful environment variables
ENV CONF_HOME /var/atlassian/confluence
ENV CONF_INSTALL /opt/atlassian/confluence
ENV CONF_VERSION 6.9.0
ENV JAVA_CACERTS $JAVA_HOME/jre/lib/security/cacerts
ENV CERTIFICATE $CONF_HOME/certificate
# [新增] 把build目录的必要文件复制到镜像内
COPY atlassian-confluence-${CONF_VERSION}.tar.gz /tmp/atlassian-confluence-${CONF_VERSION}.tar.gz
COPY atlassian-extras-decoder-v2-3.3.0.jar /tmp/atlassian-extras-decoder-v2-3.3.0.jar
# [新增] 创建Install目录,解压安装包,替换工具Jar包,删除安装包压缩文件
RUN mkdir -p ${CONF_INSTALL}
RUN tar -xzvf /tmp/atlassian-confluence-${CONF_VERSION}.tar.gz -C ${CONF_INSTALL} --strip-components=1 --no-same-owner \
&& mv ${CONF_INSTALL}/confluence/WEB-INF/lib/atlassian-extras-decoder-v2-3.3.0.jar ${CONF_INSTALL}/confluence/WEB-INF/lib/atlassian-extras-decoder-v2-3.3.0.jar.bak \
&& mv /tmp/atlassian-extras-decoder-v2-3.3.0.jar ${CONF_INSTALL}/confluence/WEB-INF/lib \
&& rm -rf /tmp/atlassian-confluence-${CONF_VERSION}.tar.gz
# Install Atlassian Confluence and helper tools and setup initial home
# directory structure.
RUN set -x \
&& apk --no-cache add curl xmlstarlet bash ttf-dejavu libc6-compat gcompat \
&& mkdir -p "${CONF_HOME}" \
&& chmod -R 700 "${CONF_HOME}" \
&& chown daemon:daemon "${CONF_HOME}" \
&& mkdir -p "${CONF_INSTALL}/conf" \
&& curl -Ls "https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.44.tar.gz" | tar -xz --directory "${CONF_INSTALL}/confluence/WEB-INF/lib" --strip-components=1 --no-same-owner "mysql-connector-java-5.1.44/mysql-connector-java-5.1.44-bin.jar" \
&& chmod -R 700 "${CONF_INSTALL}/conf" \
&& chmod -R 700 "${CONF_INSTALL}/temp" \
&& chmod -R 700 "${CONF_INSTALL}/logs" \
&& chmod -R 700 "${CONF_INSTALL}/work" \
&& chown -R daemon:daemon "${CONF_INSTALL}/conf" \
&& chown -R daemon:daemon "${CONF_INSTALL}/temp" \
&& chown -R daemon:daemon "${CONF_INSTALL}/logs" \
&& chown -R daemon:daemon "${CONF_INSTALL}/work" \
&& echo -e "\nconfluence.home=$CONF_HOME" >> "${CONF_INSTALL}/confluence/WEB-INF/classes/confluence-init.properties" \
&& xmlstarlet ed --inplace \
--delete "Server/@debug" \
--delete "Server/Service/Connector/@debug" \
--delete "Server/Service/Connector/@useURIValidationHack" \
--delete "Server/Service/Connector/@minProcessors" \
--delete "Server/Service/Connector/@maxProcessors" \
--delete "Server/Service/Engine/@debug" \
--delete "Server/Service/Engine/Host/@debug" \
--delete "Server/Service/Engine/Host/Context/@debug" \
"${CONF_INSTALL}/conf/server.xml" \
&& touch -d "@0" "${CONF_INSTALL}/conf/server.xml" \
&& chown daemon:daemon "${JAVA_CACERTS}"
# Use the default unprivileged account. This could be considered bad practice
# on systems where multiple processes end up being executed by 'daemon' but
# here we only ever run one process anyway.
USER daemon:daemon
# Expose default HTTP connector port.
EXPOSE 8090 8091
# Set volume mount points for installation and home directory. Changes to the
# home directory needs to be persisted as well as parts of the installation
# directory due to eg. logs.
VOLUME ["/var/atlassian/confluence", "/opt/atlassian/confluence/logs"]
# Set the default working directory as the Confluence home directory.
WORKDIR /var/atlassian/confluence
COPY docker-entrypoint.sh /
ENTRYPOINT ["/docker-entrypoint.sh"]
# Run Atlassian Confluence as a foreground process by default.
CMD ["/opt/atlassian/confluence/bin/start-confluence.sh", "-fg"]
执行build
cd /your-docker-build-path
docker build -t michael/atlassian-confluence:6.9.0 .
启动镜像(配套如果使用MYSQL,建议Docker Compose启动Confluence + MYSQL)
docker run -d --rm --name=wiki -p 8090:8090 -p 8091:8091 \
-v /your-confluence-path/home:/var/atlassian/confluence \
-v /your-confluence-path/logs:/opt/atlassian/confluence/logs \
michael/atlassian-confluence:6.9.0
配置
-
选择产品安装
confluence-setup-1.png -
点击下一步(省略了一步,授权码填写,用keygen,你懂得)
- 选择配置数据库
- 配置数据库并测试(我选择的是MYSQL,这里需要修改MYSQL事务隔离级别,改成transaction-isolation = READ-COMMITTED,读取已提交,Confluence要求的,会检查)
- 选择红框选项(Confluence有多种用户管理方式,为了单纯介绍Confluence,暂时不展开;剩余方式有:Jira数据库、Crowd数据库、LDAP数据库等等)
confluence-setup-8.png