设为首页 收藏本站
查看: 895|回复: 0

[经验分享] How to Install Rancher Docker on CentOS 7-Arnold

[复制链接]

尚未签到

发表于 2019-2-16 06:32:56 | 显示全部楼层 |阅读模式
  How to Install Rancher Docker Container Manager on CentOS 7
  Rancher is an open source container management platform. It allows you to run and manage Docker and Kubernetes with ease. Rancher provides infrastructure services such as multi-host networking, load balancing, and volume snapshots.
  In this tutorial, I will guide you to step-by-step install and configure Rancher Server and Agent on CentOS 7 server. We will install Docker and Rancher on the CentOS server, enable local authentication Rancher server, add the rancher host, and then try to deploy container application 'Ghost' from Rancher Dashboard.
Prerequisites

  •   CentOS 7

    •   host01 - 192.168.33.10
    •   host02 - 192.168.33.11

  •   Root privileges
What we will do?

  •   Install Docker on CentOS 7
  •   Install Rancher Server
  •   Enable Local Authentication Rancher Server
  •   Add New Host
  •   Deploy New Container
Step 1 - Install Docker on CentOS 7
  Rancher can be installed as a set of Docker Containers, one container as a management server and another as an agent. And we need Docker installed on all our rancher host and agent.
  Install Docker on CentOS 7 using the yum command below.
  yum -y install docker
  After the installation is complete, start the service and add it to the boot time.
  systemctl start docker
  systemctl enable docker
  Docker installed on the rancher host server - check it using commands below.
  systemctl status docker
  docker --version
  And you will get the result as shown below.
DSC0000.png

Step 2 - Install Rancher Server
  To run and install Rancher, we just need to run the Rancher container on our server host. In this step, we will install Rancher Server single container on our 'host01' server.
  Before installing Rancher server on 'host01' server, we will create and define a new directory as a Rancher database volume.
  Run the commands below.
  HOST_VOLUME=$HOME/rancher-data/mysql
  mkdir -p $HOST_VOLUME
  Now install Rancher server using the docker command below.
  sudo docker run -d \
  -v $HOST_VOLUME:/var/lib/mysql \
  --restart=unless-stopped \
  -p 8080:8080 \
  rancher/server
  Wait for the Rancher server installation.
DSC0001.png

  When the installation is complete, Rancher server is accessible from the web browser.
  Open your web browser and type the server IP address with port 8080.
  http://192.168.33.10:8080/
  And you will get the Rancher first page installation as below.
DSC0002.png

  Rancher server has been installed on CentOS 7 server and is now running on default port 8080.
Step 3 - Enable Local Authentication on Rancher Server
  After the Rancher installation, we need to configure the Rancher Access Control. The Access Control allows you to manage users who have the access permissions to your Rancher server.
  Rancher supports many access control providers, including Active Directory, Azure AD, Github, OpenLDAP, SAML, and Local Authentication.
  For this guide, we will enable the local authentication for our Rancher server installation.
  Open your web browser and type the server IP address with port 8080.
  http://192.168.33.10:8080/
  Move your cursor to the 'ADMIN' menu drop-down and click the 'Access Control'.
DSC0003.png

  Now we want to use the 'Local Authentication' method. Click 'LOCAL' on the page, then type your username and password.
DSC0004.png

  Click 'Enable Local Auth' button and you will be redirected to the Rancher admin dashboard.
  Access Control for the Rancher server has been setup with Local Authentication enabled.
Step 4 - Add New Host
  Hosts are the most basic unit of resource within Rancher and represented as any Linux server (a virtual or physical server with Docker installed on it).
  In this step, we will add new host 'host02' with Ubuntu as an operating system and with the 2GB of RAM.
  Connect to the 'host02' server using the ssh.
  ssh root@gost02
  Now install Docker on it using yum command.
  yum -y install docker
  And when the installation is complete, start docker and enable it to launch everytime at system start.
  systemctl start docker
  systemctl enable docker
  Docker has been installed on the 'host02' server.
DSC0005.png

  Next, we will add host02 to the Rancher as a host.
  Open the Rancher Dashboard, move your cursor to the 'INFRASTRUCTURE' menu and click 'Hosts'.
DSC0006.png

  Now click the 'Add Host' button.
DSC0007.png

  For the Host Registration URL, we will use default as shown below.
DSC0008.png

  Click 'Save button'.
  Now select the Host type, Rancher support for many type of hosts including Amazon EC2, Azure, DigitalOcean, Rackspace Hosts.
  Select the 'Custom' host, type the 'hots02' IP address, and copy the docker command on the box.
DSC0009.png

  Now open the host02 terminal shell and paste the following command.
  sudo docker run -e CATTLE_AGENT_IP="192.168.33.11"  --rm --privileged -v /var/run/docker.sock:/var/run/docker.sock -v /var/lib/rancher:/var/lib/rancher rancher/agent:v1.2.10 http://192.168.33.10:8080/v1/scripts/BCF2EFCA73A02954EBDF:1514678400000:OdRDdvnEUbV2hUMAFIS3oQxcTt4
  The command will download and run new container for Rancher Agent.
DSC00010.png

  And when it's complete, you will get the result as shown below.
DSC00011.png

  Now back to the Rancher Dashboard Host Add page and click the 'Close' button.
  And you will see the 'host02' on the page as shown below.
DSC00012.png

  host02 has been added to the Rancher server, and we're now ready to run container managed by Rancher server.
Step 5 - Test Create New Container
  Rancher provides a catalog for applications. The available application templates make deployment easier.
  Rancher provides two types of catalogs. The Library catalog that contains templates from the Rancher certified catalog, and the Community catalog that contains templates from the Rancher Community-catalog.
  In this step, we will try to deploy a simple blog platform 'Ghost' as a container through the Rancher Catalog Community Templates.
  On the Rancher Dashboard, move the cursor to the 'CATALOG' menu and click the Community Catalog.
DSC00013.png

  In the 'Search' box, type the application name that we want to install ('Ghost').
DSC00014.png

  Click the 'View Details' button.
  Give the new Ghost container a name and description.
DSC00015.png

  Then click the 'Launch' button.
  When it's complete, you will get the result as below.
DSC00016.png

  The 'Ghost' container has been created and is now running on Rancher agent server.
  Now move your cursor to the 'INFRASTRUCTURE' menu and click 'Host'. Now make sure you get the 'ghost' container is running on the 'host2' server.
DSC00017.png

  To verify the Ghost container installation, open your web browser and type the 'host02' IP address and you will get the ghost blog default homepage.
  http://192.168.33.11/
DSC00018.png

  Rancher server and Rancher agent installation on Ubuntu 16.04 has been completed successfully.
Reference

  •   http://rancher.com/docs/rancher/latest/en/


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-672796-1-1.html 上篇帖子: RHEL和Centos系统的区别? 下篇帖子: How to Setup Puppet Master and Agent on CentOS 7-Arnold
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表