Openshift 构建 容器化mysql

1: 准备mysql镜像

  • 查看Image streams
    Openshift 提供了image streams管理镜像,"An image stream can be used to automatically perform an action, such as updating a deployment, when a new image, such as a new version of the base image that is used in that deployment, is created." - OpenShift Documentation
    但是请注意,Image Streams并不是镜像仓库,只是镜像的一种映射,具体的镜像实体还需要自己准备。

    查看Image Streams

[root@test3 ~]# oc get is
NAME              DOCKER REPO   TAGS                           UPDATED
hello-openshift                 latest                         10 weeks ago
httpd                           latest,2.4                     6 hours ago
jenkins                         latest,2,1                     6 hours ago
mariadb                         latest,10.1                    6 hours ago
mongodb                         2.6,2.4,latest + 1 more...     6 hours ago                    
mysql                           latest,5.7,5.6 + 1 more...     6 hours ago
nodejs                          4,0.10,latest + 1 more...      6 hours ago
perl                            5.20,5.16,latest + 1 more...   6 hours ago
php                             5.5,latest,7.0 + 1 more...     6 hours ago
postgresql                      latest,9.5,9.4 + 1 more...     6 hours ago
python                          latest,3.5,3.4 + 2 more...     6 hours ago
redis                           latest,3.2                     6 hours ago
ruby                            latest,2.3,2.2 + 1 more...     6 hours ago
wildfly                         10.1,10.0,9.0 + 2 more...      6 hours ago
[root@test3 ~]#

2: 查看image: 发现并没有mysql 的镜像,下面来下载一下:

[root@test3 ~]# oc describe is mysql
Name:            mysql
Namespace:        shp
Created:        6 hours ago
Labels:            <none>
Annotations:        openshift.io/display-name=MySQL
            openshift.io/image.dockerRepositoryCheck=2019-12-24T02:45:15Z
Docker Pull Spec:    <none>
Unique Images:        3
Tags:            4

5.7 (latest)
  tagged from centos/mysql-57-centos7:latest

下载image 到本地: docker pull centos/mysql-57-centos7:latest

3: 从openshift web console界面部署mysql

  1. 新建一个deployment,并加入到project: shp中:

注意:上面创建mysql 的deployment 的时候,图中的"Enviroment Variable" 是要添加user_name,user_password,user_database 的参数的,否则,pod会创建失败的。

4创建好以后,尝试连接:

[root@test3 ~]# oc rsh mysql01-2-nayf1
sh-4.2$ mysql -usheng -psheng
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.7.24 MySQL Community Server (GPL)

Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql>
mysql>

实验成功!

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

shenghuiping2001

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值