标签:持久 enc 响应 网络 情况下 ons 相关 数据库服务 rhs
1 # setsebool -P virt_use_nfs=true 2 # setsebool -P virt_sandbox_use_nfs=true
1 [root@node ~]# showmount -e 2 Export list for master.lab.example.com: 3 /var/export/nfs-demo * 4 [root@services ~]# cat /etc/exports.d/nfs-demo.conf 5 /var/export/nfs-demo 6 ... 7 [root@services ~]# ls -lZ /var/export -d 8 drwx------. 10000000 650000 unconfined_u:object_r:usr_t:s0 /var/export/nfs-demo
1 [student@workstation ~]$ lab deploy-volume setup
1 [root@services ~]# less -FiX /root/DO280/labs/deploy-volume/config-nfs.sh 2 [root@services ~]# /root/DO280/labs/deploy-volume/config-nfs.sh #创建NFS 3 Export directory /var/export/dbvol created. 4 [root@services ~]# showmount -e #确认验证
1 [root@node1 ~]# mount -t nfs services.lab.example.com:/var/export/dbvol /mnt 2 [root@node1 ~]# mount | grep /mnt 3 [root@node1 ~]# ll -a /mnt/ #检查相关权限
1 [root@node1 ~]# umount /mnt/ #卸载
1 [student@workstation ~]$ oc login -u admin -p redhat https://master.lab.example.com 2 [student@workstation ~]$ less -FiX /home/student/DO280/labs/deploy-volume/mysqldb-volume.yml 3 apiVersion: v1 4 kind: PersistentVolume 5 metadata: 6 name: mysqldb-volume 7 spec: 8 capacity: 9 storage: 3Gi 10 accessModes: 11 - ReadWriteMany 12 nfs: 13 path: /var/export/dbvol 14 server: services.lab.example.com 15 persistentVolumeReclaimPolicy: Recycle 16 [student@workstation ~]$ oc create -f /home/student/DO280/labs/deploy-volume/mysqldb-volume.yml 17 [student@workstation ~]$ oc get pv #查看PV 18 NAME CAPACITYACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE 19 mysqldb-volume 3Gi RWX Recycle Available 1m
1 [student@workstation ~]$ oc login -u developer -p redhat https://master.lab.example.com 2 [student@workstation ~]$ oc new-project persistent-storage
1 [student@workstation ~]$ oc new-app --name=mysqldb 2 --docker-image=registry.lab.example.com/rhscl/mysql-57-rhel7 3 -e MYSQL_USER=ose 4 -e MYSQL_PASSWORD=openshift 5 -e MYSQL_DATABASE=quotes 6 [student@workstation ~]$ oc status #确认验证 7 In project persistent-storage on server https://master.lab.example.com:443 8 9 10 svc/mysqldb - 172.30.39.72:3306 11 dc/mysqldb deploys istag/mysqldb:latest 12 deployment #1 deployed 58 seconds ago - 1 pod
1 [student@workstation ~]$ oc describe pod mysqldb | grep -A2 ‘Volumes‘ #查看当前pod的Volume 2 Volumes: 3 mysqldb-volume-1: 4 Type: EmptyDir (a temporary directory that shares a pod‘s lifetime) 5 [student@workstation ~]$ oc set volumes dc mysqldb 6 --add --overwrite --name=mysqldb-volume-1 -t pvc 7 --claim-name=mysqldb-pvclaim 8 --claim-size=3Gi 9 --claim-mode=‘ReadWriteMany‘ #修改dc并创建PVC 10 [student@workstation ~]$ oc describe pod mysqldb | grep -E -A 2 ‘Volumes|ClaimName‘ #查看验证
1 [student@workstation ~]$ oc get pvc #查看PVC 2 NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE 3 mysqldb-pvclaim Bound mysqldb-volume 3Gi RWX 2m
1 [student@workstation ~]$ oc get pod 2 NAME READY STATUS RESTARTS AGE 3 mysqldb-2-r7wz8 1/1 Running 0 4m 4 [student@workstation ~]$ oc port-forward mysqldb-2-r7wz8 3306:3306
1 [student@workstation ~]$ mysql -h127.0.0.1 -uose -popenshift 2 quotes < /home/student/DO280/labs/deploy-volume/quote.sql #填充数据测试 3 [student@workstation ~]$ mysql -h127.0.0.1 -uose -popenshift 4 quotes -e "select count(*) from quote;" #确认填充完成 5 [student@workstation ~]$ ssh root@services ls -la /var/export/dbvol #查看NFS服务端数据 6 …… 7 drwxr-x---. 2 nfsnobody nfsnobody 54 Jul 21 23:43 quotes 8 …… 9 [student@workstation ~]$ ssh root@services ls -la /var/export/dbvol/quotes 10 total 116 11 drwxr-x---. 2 nfsnobody nfsnobody 54 Jul 21 23:43 . 12 drwx------. 6 nfsnobody nfsnobody 4096 Jul 21 23:39 .. 13 -rw-r-----. 1 nfsnobody nfsnobody 65 Jul 21 23:39 db.opt 14 -rw-r-----. 1 nfsnobody nfsnobody 8584 Jul 21 23:43 quote.frm 15 -rw-r-----. 1 nfsnobody nfsnobody 98304 Jul 21 23:44 quote.ibd
1 [student@workstation ~]$ oc delete project persistent-storage #删除项目 2 project "persistent-storage" deleted 3 [student@workstation ~]$ oc delete pv mysqldb-volume #删除PV 4 persistentvolume "mysqldb-volume" deleted
1 [student@workstation ~]$ ssh root@services ls -la /var/export/dbvol 2 …… 3 drwxr-x---. 2 nfsnobody nfsnobody 54 Jul 21 23:43 quotes 4 …… 5 [student@workstation ~]$ ssh root@services rm -rf /var/export/dbvol/* #使用rm才可以彻底删除
1 [OSEv3:vars] 2 openshift_hosted_registry_storage_kind=nfs #定义OCP存储后端 3 openshift_hosted_registry_storage_access_modes=[‘ReadWriteMany‘] #定义访问模式,默认为ReadWriteMany,表示允许多个节点以读写形式挂载 4 openshift_hosted_registry_storage_nfs_directory=/exports #定义NFS服务器上的NFS存储目录 5 openshift_hosted_registry_storage_nfs_options=‘*(rw,root_squash)‘ #定义存储卷的NFS选项。这些选项被添加到/etc/ exports.d/openshift-ansible.exports中。rw选项允许对NFS卷进行读写访问,root_squash选项阻止远程连接的根用户拥有root特权,并为nfsnobody分配用户ID 6 openshift_hosted_registry_storage_volume_name=registry #定义要用于持久仓库的NFS目录的名称 7 openshift_hosted_registry_storage_volume_size=40Gi #定义持久卷大小 8 ... output omitted ... 9 [nfs] 10 services.lab.example.com
1 [student@workstation ~]$ oc describe pv registry-volume 2 Name: registry-volume #定义持久卷名 3 Labels: <none> 4 Annotations: pv.kubernetes.io/bound-by-controller=yes 5 StorageClass: 6 Status: Bound 7 Claim: default/registry-claim #定义使用持久卷的声明 8 Reclaim Policy: Retain #默认持久卷策略,具有Retain策略的卷在从其声明中释放后不会被擦除 9 Access Modes: RWX #定义持久卷的访问模式,由Ansible inventory文件的openshift_hosted_registry_storage_access_modes=[‘ReadWriteMany‘]变量定义 10 Capacity: 40Gi #定义持久卷的大小,由Ansible inventory文件的openshift_hosted_registry_storage_volume_size变量定义 11 Message: 12 Source: #定义存储后端的位置和NFS共享 13 Type: NFS (an NFS mount that lasts the lifetime of a pod) 14 Server: services.lab.example.com 15 Path: /exports/registry 16 ReadOnly: false 17 Events: <none>
1 [user@demo ~] oc describe dc/docker-registry | grep -A4 Volumes 2 Volumes: 3 registry-storage: 4 Type: PersistentVolumeClaim (a reference to a PersistentVolumeClaim in the same namespace) 5 ClaimName: registry-claim 6 ReadOnly: false
1 [user@demo ~] ssh root@master ls -l 2 /var/export/registryvol/docker/registry/v2/repositories/default/
1 [root@services ~]# less -FiX /root/DO280/labs/storage-review/config-review-nfs.sh 2 [root@services ~]# /root/DO280/labs/storage-review/config-review-nfs.sh #创建NFS 3 [root@services ~]# showmount -e #确认验证
1 [student@workstation ~]$ oc login -u admin -p redhat https://master.lab.example.com 2 [student@workstation ~]$ less -FiX /home/student/DO280/labs/storage-review/review-volume-pv.yaml 3 apiVersion: v1 4 kind: PersistentVolume 5 metadata: 6 name: review-pv 7 spec: 8 capacity: 9 storage: 3Gi 10 accessModes: 11 - ReadWriteMany 12 nfs: 13 path: /var/export/review-dbvol 14 server: services.lab.example.com 15 persistentVolumeReclaimPolicy: Recycle 16 [student@workstation ~]$ oc create -f /home/student/DO280/labs/storage-review/review-volume-pv.yaml 17 [student@workstation ~]$ oc get pv #查看PV 18 NAME CAPACITYACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE 19 review-pv 3Gi RWX Recycle Available 13s
1 [student@workstation ~]$ less -FiX /home/student/DO280/labs/storage-review/instructor-template.yaml 2 [student@workstation ~]$ oc create -n openshift -f /home/student/DO280/labs/storage-review/instructor-template.yaml 3 #使用模板创建应用至openshift namespace中
1 [student@workstation ~]$ oc login -u developer -p redhat https://master.lab.example.com 2 [student@workstation ~]$ oc new-project instructor
1 [student@workstation ~]$ oc login -u developer -p redhat https://master.lab.example.com 2 [student@workstation ~]$ oc get pod 3 NAME READY STATUS RESTARTS AGE 4 instructor-1-9fmct 1/1 Running 0 43s 5 instructor-1-build 0/1 Completed 0 2m 6 mysql-1-f7rrq 1/1 Running 0 2m 7 [student@workstation ~]$ oc port-forward mysql-1-f7rrq 3306:3306
1 [student@workstation ~]$ mysql -h127.0.0.1 -u instructor -ppassword 2 instructor < /home/student/DO280/labs/storage-review/instructor.sql 3 [student@workstation ~]$ mysql -h127.0.0.1 -u instructor -ppassword instructor -e "select * from instructors;" #查看 4
1 [student@workstation ~]$ lab storage-review grade #环境脚本判断实验
1 [student@workstation ~]$ oc login -uadmin -predhat 2 [student@workstation ~]$ oc delete project instructor 3 [student@workstation ~]$ oc delete pv review-pv 4 [student@workstation ~]$ ssh root@services 5 [root@services ~]# rm -rf /var/export/review-dbvol 6 [root@services ~]# rm -f /etc/exports.d/review-dbvol.exports
标签:持久 enc 响应 网络 情况下 ons 相关 数据库服务 rhs
原文地址:https://www.cnblogs.com/itzgr/p/13172031.html