rancher 1.6 + mysql 5.7 + docker 17.03.2
官方文档: https://rancher.com
安装docker17.03
$: curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
$: sudo apt-key fingerprint 0EBFCD88
$: sudo add-apt-repository \
"deb [arch=amd64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
$: sudo apt-get update
$: sudo apt-get install -y docker-ce docker-ce-cli containerd.io
$: apt-cache madison docker-ce
$: sudo apt-get install docker-ce=17.03.2~ce-0~ubuntu-xenial
$: sudo usermod -aG docker $USER
$: docker version
配置私有证书
$:sudo mv ~/devdockerCA.crt /usr/local/share/ca-certificates/docker-dev-cert/
$:sudo update-ca-certificates
$:sudo systemctl restart docker
$:reboot
安装mysql
$:sudo docker pull mysql:5.7
$:sudo mkdir /mydata/mysql/log
$:sudo mkdir /mydata/mysql/data
$:sudo mkdir /mydata/mysql/conf
sudo vi my.cnf (内容如下)
"""
[client]
default-character-set=utf8
[mysql]
default-character-set=utf8
[mysql]
init_connect='SET collation_connection = utf8_unicode_ci'
init_connect='SET NAMES utf8'
character-set-server=utf8
collation-server=utf8_unicode_ci
skip-character-set-client-handshake
skip-name-resolve
lower_case_table_names = 1
"""
$:sudo docker run -p 3306:3306 --name mysql \
-v /mydata/mysql/log:/var/log/mysql \
-v /mydata/mysql/data:/var/lib/mysql \
-v /mydata/mysql/conf:/etc/mysql/conf \
-e MYSQL_ROOT_PASSWORD=root \
--privileged=true \
--restart=always \
-d mysql:5.7
$:docker ps # 查看是否启动
参数说明:
#docker run -p 3306:3306 将容器的3306端口映射到主机3306端口
#-v /mydata/mysql/log:/var/log/mysql 将配置文件夹挂载到主机
#-v /mydata/mysql/data:/var/lib/mysql 将日志文件挂载到主机
#-v /mydata/mysql/conf:/etc/mysql 将配置文件夹挂载到主机
#-e MYSQL_ROOT_PASSWORD=root 初始化root用户的密码
#--restart=always 设置容器开机自启
#--privileged=true 权限问题
#将mysql容器中的相关配置文件挂载到本机,方便查看,想要修改mysql容器的配置,可以直接通过本机修改。
修改密码:https://blog.csdn.net/skh2015java/article/details/80156278
设置远程调用:https://blog.csdn.net/djklsajdklsajdlk/article/details/127521438
安装rancher
$ sudo docker run -d --restart=unless-stopped -p 8080:8080 rancher/server:v1.6.17 \
--db-host myhost.example.com \
--db-port 3306 --db-user username \
--db-pass password \
--db-name cattle
添加自节点
打开rancher UI
在其他自节点机器上配置好docker后,直接运行该命令即可添加成功