如何快速安装Rancher

Rancher 官方文档都是英文文档,完全看完都头疼。因此将主要步骤记录下来,留待以后安装使用.

  • 配置数据库 创建数据库及用户
CREATE DATABASE IF NOT EXISTS cattle COLLATE = 'utf8_general_ci' CHARACTER SET = 'utf8';

GRANT ALL ON cattle.* TO 'cattle'@'%' IDENTIFIED BY 'cattle';

GRANT ALL ON cattle.* TO 'cattle'@'localhost' IDENTIFIED BY 'cattle';  
  • 创建Rancher Server容器
docker run -d --restart=unless-stopped \  
              -p 8080:8080 rancher/server \
              --db-host myhost.example.com \
              --db-port 3306 \
              --db-user username \
              --db-pass password 
              --db-name cattle
  • 监控日志

官方没有提及这步,但此步骤相当重要! 如果在日志中长时间看到 DB Migration, 检查一下mysql中是否存在db lock。

mysql> use cattle;

# Check that there is a lock in the table
mysql> select * from DATABASECHANGELOGLOCK;

# Update to remove the lock by the container
mysql> update DATABASECHANGELOGLOCK set LOCKED="", LOCKGRANTED=null, LOCKEDBY=null where ID=1;


# Check that the lock has been removed
mysql> select * from DATABASECHANGELOGLOCK;  

清除锁之后,容器要么会顺利执行,要么会报错。 如果报错,就restart。一般第二次都会成功。