阿里云上实战openshift3-阿里云NAS存储配置

1. 阿里云NAS存储初始化

see:

https://help.aliyun.com/document_detail/27527.html?spm=a2c4g.11186623.4.8.wWNbbz

https://help.aliyun.com/document_detail/63956.html?spm=a2c4g.11186623.6.608.VWixXS

1)阿里云管理控制台上为NAS创建文件系统、添加挂载点

  【注】需在NAS的权限组上增加规则,读写权限:读写,用户权限:限制所有用户(all_squash),否则非root用户访问NAS下的子目录和文件只读不可写、写操作会出现Promission Denied!

2)ECS(每个node节点)上安装nfs

  yum install nfs-utils

3)NAS上创建要mount为PV的目录

  例如:/mariadb,/admindb,/redis,/usericons

  #任选一ECS上,本地创建目录:

 mkdir /mnt/ali-nas -p

 chown nfsnobody:nfsnobody /mnt/ali-nas

 #mount

  mount -t nfs -o vers=4.0 <测试NAS挂载点地址>:/ /mnt/ali-nas

 #NAS盘上创建目录

 mkdir /mnt/ali-nas/mariadb

 mkdir /mnt/ali-nas/admindb

 mkdir /mnt/ali-nas/redis

 mkdir /mnt/ali-nas/usericons

 chown nfsnobody:nfsnobody /mnt/ali-nas -R


4)ECS(node节点)上查看mount

 mount -l


5)取消mount

 umount -lf /mnt/ali-nas 

  【注】阿里NAS的umount需加-lf,否则很可能会出现device is busy!


2.创建PV

1)本地电脑创建pv-mariadb.yaml

         apiVersion:v1

         kind:PersistentVolume

         metadata:

            name: pv-mariadb

         spec:

            capacity:

                    storage: 10Gi

            accessModes:

                    - ReadWriteOnce

            persistentVolumeReclaimPolicy: Retain

            nfs:

                    path: /mariadb

                    server: <阿里nas挂载点地址>

2)本地电脑创建pv-admindb.yaml

         apiVersion:v1

         kind:PersistentVolume

         metadata:

            name: pv-admindb

         spec:

            capacity:

                    storage: 2Gi

            accessModes:

                    - ReadWriteOnce

            persistentVolumeReclaimPolicy: Retain

            nfs:

                    path: /admindb

                    server: <阿里nas挂载点地址>

3)本地电脑创建pv-redis.yaml

         apiVersion:v1

         kind:PersistentVolume

         metadata:

            name: pv-redis

         spec:

            capacity:

                    storage: 2Gi

            accessModes:

                    - ReadWriteOnce

            persistentVolumeReclaimPolicy: Retain

            nfs:

                    path: /redis

                    server: <阿里nas挂载点地址>

4)本地电脑创建pv-usericons.yaml

         apiVersion:v1

         kind:PersistentVolume

         metadata:

            name: pv-usericons

         spec:

            capacity:

                    storage: 10Gi

            accessModes:

                    - ReadWriteMany

            persistentVolumeReclaimPolicy: Retain

            nfs:

                    path: /usericons

                    server: <阿里nas挂载点地址>

5)管理员用户登录OpenShift Web

Console, 导入以上yaml,创建PV

6)远程登录master节点

  #修改pv label

  oc label pv pv-mariadb data=mariadb

  oc label pv pv-admindb data=admindb

  oc label pv pv-redis data=redis

  oc label pv pv-usericons file=usericons

  #查看pv

  oc get pv --show-labels

你可能感兴趣的:(阿里云上实战openshift3-阿里云NAS存储配置)