标签:
搭建Redmine环境可以选择使用分别安装Ruby+Rails+Redmine+MySQL的方式,
但是过程中需要解决各种扰人的依赖问题。Docker为我们提供的Plan B,方便,快捷。
当然可以选择Ruby+Rails+Redmine+MySQL的安装方式,请参考:
http://www.jyguagua.com/?p=2026
因为是实际生产需要,所以,直接购买阿里云的ECS。
安装和使用方法参考:
https://bbs.aliyun.com/read/267341.html?fpage=0&displayMode=1&toread=0&page=1
Docker官方的说明:
“系统的要求跟 Ubuntu 情况类似,64 位操作系统,内核版本至少为 3.10。
Docker 目前支持 CentOS 6.5 及以后的版本,推荐使用 CentOS 7 系统。”
所以购买ECS后,请选择CentOS 7系统。
更新内核两种方法,编译安装和非编译安装:
编译安装
http://seanlook.com/2014/10/24/upgrade-centos6_kernel-to-3.10.x/
非编译安装
https://www.sjy.im/toss/use-yum-update-centos-kernel-quickly.html
http://www.tuicool.com/articles/rUvERv
我选择的是非编译安装方式,很方便。
升级流程
1,查看内核版本
uname -r
3.8.0-44-generic
2,导入 Public Key
rpm --import https://www.elrepo.org/RPM-GPG-KEY-elrepo.org
3,安装 ELRepo
rpm -Uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm
4,升级 Kernel
yum --enablerepo=elrepo-kernel install kernel-lt -y
5,更改 Grub
vim /etc/grub.conf
根据安装好以后的内核位置,修改 default 的值,一般是修改为0,因为 default 从 0 开始,一般新安装的内核在第一个位置,
所以设置default=0。就是文件最上面的那个default
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You do not have a /boot partition. This means that
# all kernel and initrd paths are relative to /, eg.
# root (hd0,0)
# kernel /boot/vmlinuz-version ro root=/dev/sda1
# initrd /boot/initrd-[generic-]version.img
#boot=/dev/sda
default=0
timeout=5
splashimage=(hd0,0)/boot/grub/splash.xpm.gz
hiddenmenu
title CentOS (3.10.28-1.el6.elrepo.x86_64)
root (hd0,0)
kernel /boot/vmlinuz-3.10.28-1.el6.elrepo.x86_64 ro root=UUID=0a05411f-16f2-4d69-beb0-2db4cefd3613 rd_NO_LUKS KEYBOARDTYPE=pc KEYTABLE=us rd_NO_MD crashkernel=auto LANG=en_US.UTF-8
6,重启CentOS
init 6
7,查看内核版本
uname -r
3.10.0-327.18.2.el7.x86_64
8,内核升级完成
1,添加 yum 软件源
sudo tee /etc/yum.repos.d/docker.repo <<-‘EOF‘
[dockerrepo]
name=Docker Repository
baseurl=https://yum.dockerproject.org/repo/main/centos/$releasever/
enabled=1
gpgcheck=1
gpgkey=https://yum.dockerproject.org/gpg
EOF
2,更新 yum 软件源缓存
yum update
3,安装 docker-engine
yum install -y docker-engine
4,配置让 Docker 服务在系统启动后自动启动。
CentOS 7中支持的新式 systemd 语法,如下:
systemctl start docker.service
systemctl enable docker.service
另附旧语法,如下:
service docker start
chkconfig docker on
5,Docker安装完成
让我们测试一下,Docker是否安装成功:
1,查看Docker版本
# docker version
Client:
Version: 1.9.1
API version: 1.21
Package version: docker-common-1.9.1-40.el7.centos.x86_64
Go version: go1.4.2
Git commit: ab77bde/1.9.1
Built:
OS/Arch: linux/amd64
Server:
Version: 1.9.1
API version: 1.21
Package version: docker-common-1.9.1-40.el7.centos.x86_64
Go version: go1.4.2
Git commit: ab77bde/1.9.1
Built:
OS/Arch: linux/amd64
2,输入Docker然后回车,可以打印Docker的所有命令
# docker
Usage: docker [OPTIONS] COMMAND [arg...]
docker daemon [ --help | ... ]
docker [ --help | -v | --version ]
A self-sufficient runtime for containers.
Options:
--config=~/.docker Location of client config files
-D, --debug=false Enable debug mode
--disable-legacy-registry=false Do not contact legacy registries
-H, --host=[] Daemon socket(s) to connect to
-h, --help=false Print usage
-l, --log-level=info Set the logging level
--tls=false Use TLS; implied by --tlsverify
--tlscacert=~/.docker/ca.pem Trust certs signed only by this CA
--tlscert=~/.docker/cert.pem Path to TLS certificate file
--tlskey=~/.docker/key.pem Path to TLS key file
--tlsverify=false Use TLS and verify the remote
-v, --version=false Print version information and quit
Commands:
attach Attach to a running container
build Build an image from a Dockerfile
commit Create a new image from a container‘s changes
cp Copy files/folders between a container and the local filesystem
create Create a new container
diff Inspect changes on a container‘s filesystem
events Get real time events from the server
exec Run a command in a running container
export Export a container‘s filesystem as a tar archive
history Show the history of an image
images List images
import Import the contents from a tarball to create a filesystem image
info Display system-wide information
inspect Return low-level information on a container or image
kill Kill a running container
load Load an image from a tar archive or STDIN
login Register or log in to a Docker registry
logout Log out from a Docker registry
logs Fetch the logs of a container
network Manage Docker networks
pause Pause all processes within a container
port List port mappings or a specific mapping for the CONTAINER
ps List containers
pull Pull an image or a repository from a registry
push Push an image or a repository to a registry
rename Rename a container
restart Restart a container
rm Remove one or more containers
rmi Remove one or more images
run Run a command in a new container
save Save an image(s) to a tar archive
search Search the Docker Hub for images
start Start one or more stopped containers
stats Display a live stream of container(s) resource usage statistics
stop Stop a running container
tag Tag an image into a repository
top Display the running processes of a container
unpause Unpause all processes within a container
version Show the Docker version information
volume Manage Docker volumes
wait Block until a container stops, then print its exit code
Run ‘docker COMMAND --help‘ for more information on a command.
测试成功。
三个重要概念
1,image镜像
官方解释:
“Docker 镜像(Image)就是一个只读的模板。例如:一个镜像可以包含一个完整的 ubuntu 操作系统环境,
里面仅安装了 Apache 或用户需要的其它应用程序。”
把image理解为一个超级应用程序,与通常应用程序不同的地方是,它包含了应用程序运行的所有环境,如,包括一个操作系统环境。
2,container容器
容器是从镜像创建的运行实例。它可以被启动、开始、停止、删除。每个容器都是相互隔离的、保证安全的平台。
由同一镜像可以启动不同的容器(实例),不同的容器由拥有不同的【container ID】【NAMES】等信息,由Docker维护。
可以使用命令docker ps查看正在运行的container;使用docker ps -a查看已经退出的container。
1,查看正在运行的容器
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43b6756d9a6e sameersbn/redmine "/sbin/entrypoint.sh " 11 hours ago Up 10 hours 443/tcp, 0.0.0.0:10083->80/tcp redmine
8f8f4f81321e sameersbn/postgresql:9.4-21 "/sbin/entrypoint.sh" 11 hours ago Up 10 hours 5432/tcp postgresql-redmine
2,查看所有容器
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43b6756d9a6e sameersbn/redmine "/sbin/entrypoint.sh " 11 hours ago Up 10 hours 443/tcp, 0.0.0.0:10083->80/tcp redmine
8f8f4f81321e sameersbn/postgresql:9.4-21 "/sbin/entrypoint.sh" 11 hours ago Up 10 hours 5432/tcp postgresql-redmine
d3fd852f511c training/webapp "python app.py" 11 hours ago Exited (137) 11 hours ago web
1f0664fda251 training/webapp "python app.py" 11 hours ago Exited (137) 11 hours ago thirsty_heisenberg
e9500a923b5f training/webapp "app.py" 11 hours ago Created clever_mirzakhani
94592c0dad84 training/webapp "app.py" 11 hours ago Created compassionate_meitner
d66bdf427b7e training/webapp "python app.py" 12 hours ago Exited (137) 11 hours ago lonely_mcnulty
5a1a8abdd530 ubuntu:14.04 "/bin/sh -c ‘while tr" 12 hours ago Exited (0) 12 hours ago
。。。
可以利用容器ID的唯一性,实现数据的保存。如,当你运行中的Remine异常停机,或者服务器重启导致Remine停止运行,
如果是重新通过镜像启动实例的话,原来Redmine的数据就丢失了。此时,可以通过,查询所有容器,并通过Docker start [CONTAINER ID]重新启动容器即可,
数据不会丢失。操作方法,后面详细说明。
另一种方法是,使用docker commit命令把被停止的容器制作成镜像,然后创建改镜像的容器,也可以保证数据不丢失。
3,Repository仓库
存放镜像的地方。最大的公开仓库是Docker Hub,存放了数量庞大的镜像供用户下载。
可以通过命令,docker search [image name]查询你想要的镜像。
1,docker search #在仓库中查找镜像
查看docker hub中Ubuntu的镜像。
docker search ubuntu
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/ubuntu Ubuntu is a Debian-based Linux operating s... 3995 [OK]
docker.io docker.io/ubuntu-upstart Upstart is an event-based replacement for ... 63 [OK]
docker.io docker.io/rastasheep/ubuntu-sshd Dockerized SSH service, built on top of of... 27 [OK]
docker.io docker.io/torusware/speedus-ubuntu Always updated official Ubuntu docker imag... 26 [OK]
docker.io docker.io/ubuntu-debootstrap debootstrap --variant=minbase --components... 24 [OK]
docker.io docker.io/nickistre/ubuntu-lamp LAMP server on Ubuntu 7
2,docker pull #下载指定镜像
使用查找结果中的镜像名称,下载指定的Ubuntu镜像,当然选择星星数最多的。
docker pull docker.io/ubuntu
Using default tag: latest
Trying to pull repository docker.io/library/ubuntu ...
3,docker images #列出本地的所有镜像
docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
docker.io/ubuntu 14.04 0e7d4a488bcc 34 hours ago 187.9 MB
docker.io/sameersbn/redmine latest 2d92be2b784a 3 weeks ago 653.4 MB
docker.io/sameersbn/postgresql latest 460997f40d74 3 weeks ago 231.3 MB
docker.io/sameersbn/postgresql 9.4-21 6aa1daa9f8ce 3 weeks ago 231.3 MB
docker.io/training/webapp latest 54bb4e8718e8 12 months ago 348.7 MB
4,docker rmi #删除镜像
5,docker ps #列出当前运行中的容器
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43b6756d9a6e sameersbn/redmine "/sbin/entrypoint.sh " 11 hours ago Up 10 hours 443/tcp, 0.0.0.0:10083->80/tcp redmine
8f8f4f81321e sameersbn/postgresql:9.4-21 "/sbin/entrypoint.sh" 11 hours ago Up 10 hours 5432/tcp postgresql-redmine
6,docker ps -a #列出所有容器,包换已退出的容器
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43b6756d9a6e sameersbn/redmine "/sbin/entrypoint.sh " 11 hours ago Up 10 hours 443/tcp, 0.0.0.0:10083->80/tcp redmine
8f8f4f81321e sameersbn/postgresql:9.4-21 "/sbin/entrypoint.sh" 11 hours ago Up 11 hours 5432/tcp postgresql-redmine
d3fd852f511c training/webapp "python app.py" 12 hours ago Exited (137) 12 hours ago web
1f0664fda251 training/webapp "python app.py" 12 hours ago Exited (137) 12 hours ago thirsty_heisenberg
e9500a923b5f training/webapp "app.py" 12 hours ago Created clever_mirzakhani
94592c0dad84 training/webapp "app.py" 12 hours ago Created compassionate_meitner
d66bdf427b7e training/webapp "python app.py" 12 hours ago Exited (137) 12 hours ago lonely_mcnulty
5a1a8abdd530 ubuntu:14.04 "/bin/sh -c ‘while tr" 12 hours ago Exited (0) 12 hours ago
7,docker rm #删除容器,注意加docker rm -f强制删除容器,可以删除运行中的容器
8,docker run #使用镜像启动容器,其中,-t 选项让Docker分配一个伪终端(pseudo-tty)并绑定到容器的标准输入上, -i 则让容器的标准输入保持打开;-d 选项来实现后天运行;
docker run -t -i ubuntu:14.04 /bin/echo ‘Hello World‘
Hello World
此外,如果run一个本地没有的image,docker会先从仓库中下载(pull)该镜像,再执行run命令。
9, docker stop #终止一个运行中的容器。
当Docker容器中指定的应用终结时,容器也自动终止。 例如对于上一章节中只启动了一个终端的容器,
用户通过 exit 命令或 Ctrl+d 来退出终端时,所创建的容器立刻终止。
10,docker start #重新启动终止状态的容器
docker restart 命令会将一个运行态的容器终止,然后再重新启动它。
redmine需要使用数据库,所以需要先安装MySQL
1,查找mysql
docker search mysql
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/mysql MySQL is a widely used, open-source relati... 2403 [OK]
docker.io docker.io/mysql/mysql-server Optimized MySQL Server Docker images. Crea... 147 [OK]
docker.io docker.io/centurylink/mysql Image containing mysql. Optimized to be li... 45 [OK]
docker.io docker.io/sameersbn/mysql 35
2, 下载指定镜像
docker pull docker.io/sameersbn/mysql
1,查找Redmine
docker search redmine
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/sameersbn/redmine 199 [OK]
docker.io docker.io/redmine Redmine is a flexible project management w... 190 [OK]
docker.io docker.io/bitnami/redmine Bitnami Docker Image for Redmine 7 [OK]
docker.io docker.io/74th/redmine-all-in-one Redmine includes hosting SVN & Git , backl... 5
2,下载Redmine
docker pull docker.io/sameersbn/redmine
1,启动MySQL
docker run --name=postgresql-redmine -d \
--env=‘DB_NAME=redmine_production‘ \
--env=‘DB_USER=redmine‘ --env=‘DB_PASS=password‘ \
--volume=/srv/docker/redmine/postgresql:/var/lib/postgresql \
sameersbn/postgresql:9.4-21
为redmine提供的数据库容器名称为postgresql-redmine, -d选项,指明数据库后天运行
2,启动Redmine
docker run --name=redmine -d \
--link=postgresql-redmine:postgresql --publish=10083:80 \
--env=‘REDMINE_PORT=10083‘ \
--volume=/srv/docker/redmine/redmine:/home/redmine/data \
sameersbn/redmine
redmine容器的名称为redmine,-d选项,指明数据库后天运行;端口号为10083
服务器重启后,redmine和数据库都停止了,需要重新启动,此时,
只要找到上次停止的container名字,重新打开即可。这样可以保障数据不丢失。
查找停止前的container name
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43b6756d9a6e sameersbn/redmine "/sbin/entrypoint.sh " 29 minutes ago Up 3 minutes 443/tcp, 0.0.0.0:10083->80/tcp redmine
8f8f4f81321e sameersbn/postgresql:9.4-21 "/sbin/entrypoint.sh" 33 minutes ago Up 5 minutes 5432/tcp postgresql-redmine
重新打开数据库(使用名称打开)
docker start postgresql-redmine
postgresql-redmine
重新打开redmine
docker start redmine
redmine
3,查看当前容器运行状态
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
43b6756d9a6e sameersbn/redmine "/sbin/entrypoint.sh " 11 hours ago Up 11 hours 443/tcp, 0.0.0.0:10083->80/tcp redmine
8f8f4f81321e sameersbn/postgresql:9.4-21 "/sbin/entrypoint.sh" 11 hours ago Up 11 hours 5432/tcp postgresql-redmine
4,安装完成,登录服务器,查看是否正常运行,注意端口号为10083
首次登录,
用户名:admin
密码:admin
登录后,选择我的账户,修改语言为[简体中文]
安装完成。
Docker 从入门到实践
https://www.gitbook.com/book/yeasy/docker_practice/details
阿里云Ubuntu环境搭建Docker服务
http://blog.csdn.net/minimicall/article/details/40108305
Docker实践
http://blog.csdn.net/lincyang/article/details/43055061
sameersbn/redmine
https://hub.docker.com/r/sameersbn/redmine/
使用Yum快速更新升级CentOS内核
https://www.sjy.im/toss/use-yum-update-centos-kernel-quickly.html
使用yum快速升级CentOS 6.5内核到 3.10.28
http://www.tuicool.com/articles/rUvERv
CentOS 6.5搭建Redmine
http://www.jyguagua.com/?p=2026
ECS云服务器零基础教程linux版
https://bbs.aliyun.com/read/267341.html?fpage=0&displayMode=1&toread=0&page=1
CentOS 6.x 内核升级(2.6.32 -> 3.10.58)过程记录
http://seanlook.com/2014/10/24/upgrade-centos6_kernel-to-3.10.x/
阿里云ECS+CentOS 7.0+Docker+Redmine环境搭建
标签:
原文地址:http://www.cnblogs.com/iluzhiyong/p/redmine.html