ubuntu16.04LTS安装rancher
Posted 转圈又是原点
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu16.04LTS安装rancher相关的知识,希望对你有一定的参考价值。
1、更新apt源地址
cp /etc/apt/sources.list /etc/apt/sources.list.bak
vim /etc/apt/sources.list
deb-src http://archive.ubuntu.com/ubuntu xenial main restricted #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates universe
deb http://mirrors.aliyun.com/ubuntu/ xenial multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse #Added by software-properties
deb http://archive.canonical.com/ubuntu xenial partner
deb-src http://archive.canonical.com/ubuntu xenial partner
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted
deb-src http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted multiverse universe #Added by software-properties
deb http://mirrors.aliyun.com/ubuntu/ xenial-security universe
deb http://mirrors.aliyun.com/ubuntu/ xenial-security multiverse
apt-get update
apt-get upgrade -y
2、安装docker-engine
curl https://releases.rancher.com/install-docker/1.13.sh | sh
3、设置registry(在这里设置了私服镜像库)
vim /lib/systemd/system/docker.service
ExecStart=/usr/bin/docker daemon --insecure-registry XXX.XXX.XXX.XXX
systemctl daemon-reload
systemctl restart docker
4、设置加速器(由于国内下载镜像速度受到限制,所以使用加速器是最好选择)
sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-‘EOF‘
{
"registry-mirrors": ["https://XXXXXX.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo tee /etc/docker/daemon.json <<-‘EOF‘
{
"registry-mirrors": ["https://XXXXXX.mirror.aliyuncs.com"]
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker
5 、安装rancher
docker pull rancher/server:stable
一、设置外接数据库:
这里我设置外界数据库为mysql
在Ubuntu中安装完mysql后要设置对外可见
vim /etc/mysql/mysql.conf.d/mysqld.cnf 修改127.0.0.1使外部连接成功
5 、安装rancher
docker pull rancher/server:stable
一、设置外接数据库:
这里我设置外界数据库为mysql
在Ubuntu中安装完mysql后要设置对外可见
vim /etc/mysql/mysql.conf.d/mysqld.cnf 修改127.0.0.1使外部连接成功
sudo /etc/init.d/mysql restart 重启数据库
连接外接数据库:
docker run -d --name rancher-server --restart=unless-stopped -p 8080:8080 rancher/server:stable --db-host XXX.XXX.XXX.XXX --db-port 3306 --db-user cattle --db-pass cattle --db-name cattle
二、设置rancher的内存大小(建议最多设置为宿主机物理内存的70%)
docker run -d --name rancher-server --restart=unless-stopped -p 8080:8080 -e JAVA_OPTS="-Xmx4096m" rancher/server:stable
三、设置HA节点(建议设置HA,以做主备)
docker run -d --name rancher-server-node --restart=unless-stopped -p 8080:8080 -p 9345:9345 rancher/server:stable --db-host xxx.xxx.xxx.xxx --db-port 3306 --db-user cattle --db-pass cattle --db-name cattle --advertise-address XXX.XXX.XXX.XXX
连接外接数据库:
docker run -d --name rancher-server --restart=unless-stopped -p 8080:8080 rancher/server:stable --db-host XXX.XXX.XXX.XXX --db-port 3306 --db-user cattle --db-pass cattle --db-name cattle
二、设置rancher的内存大小(建议最多设置为宿主机物理内存的70%)
docker run -d --name rancher-server --restart=unless-stopped -p 8080:8080 -e JAVA_OPTS="-Xmx4096m" rancher/server:stable
三、设置HA节点(建议设置HA,以做主备)
docker run -d --name rancher-server-node --restart=unless-stopped -p 8080:8080 -p 9345:9345 rancher/server:stable --db-host xxx.xxx.xxx.xxx --db-port 3306 --db-user cattle --db-pass cattle --db-name cattle --advertise-address XXX.XXX.XXX.XXX
以上是关于ubuntu16.04LTS安装rancher的主要内容,如果未能解决你的问题,请参考以下文章
在 Ubuntu Server 16.04 LTS 上安装 LAMP