Docker 安装Confluence


一. 安装docker
# curl -fsSL https://get.docker.com/ | sh
# systemctl stop firewalld
# systemctl disable firewalld
# systemctl restart docker

安装compose(可不安装)
# curl -L "https://github.com/docker/compose/releases/download/1.23.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose

二. 下载myslq5.7镜像
# docker pull mysql/mysql-server:5.7

启动一个mysql容器拷贝文件到本地所需映射目录
# docker run --name=mysql5.7 -p 3306:3306 -p 33060:33060 -d mysql/mysql-server:5.7
#查看mysql默认密码
# docker logs mysql5.7 | grep "ROOT PASSWORD"
[Entrypoint] GENERATED ROOT PASSWORD: QUhALEPVYnUbekekIs@JbyLPeHaw

修改mysql默认密码,最好搞个复杂的密码
# docker exec -it mysql5.7 mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '!QAZ2wsx';
mysql> flush privileges;

# docker exec -it mysql5.7 mysql -uroot -p
更改“mysql”数据库里的“user”表里的“host”项,从”localhost”改为'%'。
mysql> use mysql;
mysql> update user set host='%' where user='root';
mysql> select host from user where user='root';
mysql> select host,user from user where user='root';
创建confluenc 数据库
mysql> create database confluence character set utf8 collate utf8_bin;


创建mysql本地映射目录
# mkdir -p /logs/mysql && mkdir -p /data/mysql
拷贝容器中mysql配置文件
# docker cp mysql5.7:/etc/my.cnf /etc/my.cnf
修改my.cnf 如下:

# cat /etc/my.cnf
# For advice on how to change settings please see
# # http://dev.mysql.com/doc/refman/5.7/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
skip-host-cache
skip-name-resolve
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
secure-file-priv=/var/lib/mysql-files
user=mysql
bind-address=0.0.0.0
tmp-table-size = 256M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0

tmp-table-size = 256M
max-heap-table-size = 32M
query-cache-type = 0
query-cache-size = 0
max-connections = 5000
thread-cache-size = 100
open-files-limit = 65535
table-definition-cache = 4096
table-open-cache = 1024
innodb-flush-method = O_DIRECT
innodb-log-files-in-group = 2
innodb-log-file-size = 512M
innodb-flush-log-at-trx-commit = 1
innodb-file-per-table = 1
#innodb-buffer-pool-size = 4G
innodb-buffer-pool-size = 2G
innodb_thread_concurrency = 48
innodb_log_buffer_size = 32M
innodb_flush_log_at_trx_commit = 2
innodb_lock_wait_timeout = 50
myisam_max_sort_file_size = 1G
key-buffer-size = 1G
myisam_sort_buffer_size = 64M
key_buffer_size = 2048M
read_buffer_size = 8M
read_rnd_buffer_size = 16M
sort_buffer_size = 8M
max_allowed_packet = 50M
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

查看mysql默认数据存储路径
# docker inspect mysql5.7 | grep data
"Source": "/var/lib/docker/volumes/16f33b7b861ae59470b5d3dac1f7dfa6c1812b4e1ff718de7e419ac040fed8a7/_data",
拷贝容器存储数据到本地目录
# cp -rf /var/lib/docker/volumes/16f33b7b861ae59470b5d3dac1f7dfa6c1812b4e1ff718de7e419ac040fed8a7/_data/* /data/mysql/
本地创建mysql用户,用于授权目录
# useradd -s /sbin/nologin mysql
目录授权
# touch /logs/mysql/mysqld.log
# chown mysql.mysql /logs/mysql/ -R ;chmod 777 /logs/mysql/ -R
# chown mysql.mysql /data/mysql/ -R

停止mysql5.7容器
# docker stop mysql5.7
# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9d0029c8263d mysql/mysql-server:5.7 "/entrypoint.sh mysq…" 4 minutes ago Exited (0) 9 seconds ago mysql5.7
删除原来启动的mysql容器
# docker rm 9d0029c8263d

启动新的mysql5.7容器
# docker run --name=mysql5.7 -p 3306:3306 -p 33060:33060 -v /etc/my.cnf:/etc/my.cnf -v /logs/mysql/:/var/log/ -v /data/mysql/:/var/lib/mysql/ -d mysql/mysql-server:5.7
查看启动状态
# docker logs --tail 10 -f mysql5.7
[Entrypoint] MySQL Docker Image 5.7.25-1.1.10
[Entrypoint] Starting MySQL 5.7.25-1.1.10

修改mysql数据库隔离级别,防止连接数据库出错
Confluence设置MySQL数据库报错:必须使用'READ-COMMITTED'作为默认隔离级别。
解决方案:注意重启数据库后需要再次执行以下命令。
mysql> SET GLOBAL tx_isolation='READ-COMMITTED';
mysql> flush privileges;

三. 下载confluenc 镜像文件
# docker pull cptactionhank/atlassian-confluence
启动confluence并连接到mysql5.7
# docker run -d --name confluence -p 8090:8090 -p 8091:8091 --link mysql5.7:db --user root:root cptactionhank/atlassian-confluence:latest
查看Confluence 启动状态
# docker ps
# docker inspect confluence
获取授权码(需要用到google邮箱)
然后继续访问http://ip:8090,接着注册confluence的key 参考连接:https://my.oschina.net/u/2289161/blog/1648587

输入连接字符串: jdbc:mysql://db:3306/confluence?useUnicode=true&characterEncoding=UTF8&useSSL=false

四. 破解Confluence到期时间
用下载的文件替换
atlassian-extras-decoder-v2-3.x.jar
atlassian-universal-plugin-manager-plugin-2.22.x.jar文件
注意(该文件下载到/opt下,替换前必须做之前的文件备份,方便回退)
进入confluence容器命令:
# docker exec -it confluence /bin/sh
#mv /opt/atlassian/confluence/confluence/WEB-INF/lib/atlassian-extras-decoder-v2-3.4.1.jar /mnt/
#mv /opt/atlassian/confluence/confluence/WEB-INF/atlassian-bundled-plugins/atlassian-universal-plugin-manager-plugin-3.0.jar /mnt/
备份好文件后,退出confluence容器。拷贝下载的文件到confluence容器中。
#将下载的破解文件替换对应的jar
#docker cp atlassian-extras-decoder-v2-3.2.jar confluence:/opt/atlassian/confluence/confluence/WEB-INF/lib/
#docker cp atlassian-universal-plugin-manager-plugin-2.22.jar confluence:/opt/atlassian/confluence/confluence/WEB-INF/atlassian-bundled-plugins/
重新启动confluence容器
# docker restart confluenc

参考连接:https://my.oschina.net/u/2289161/blog/1648587

上一篇:『互联网架构』软件架构-软件环境的持续发布管理(上)


下一篇:sql server已忽略重复的主键的错误分析