|
| 1 | + |
| 2 | +# Postgresql cluster addons |
| 3 | +## Plans |
| 4 | + |
| 5 | +View and choose the service resource specifications you need. |
| 6 | +``` |
| 7 | + # drycc resources:plans postgresql-cluster |
| 8 | +``` |
| 9 | +### Resource specification list |
| 10 | +| Resource Specification | Cores | MEMORY | Storage SIZE | |
| 11 | +| :---: | :---: | :---: | :---: | |
| 12 | +| standard-10 | 1C | 2G | 10G | |
| 13 | +| standard-20 | 2C | 4G | 20G | |
| 14 | +| standard-50 | 2C | 8G | 50G | |
| 15 | +| standard-100 | 4C | 16G | 100G | |
| 16 | +| standard-200 | 8C | 32G | 200G | |
| 17 | +| standard-400 | 16C | 64G | 400G | |
| 18 | +| standard-800 | 32C | 128G | 800G | |
| 19 | + |
| 20 | +In order to obtain a better experience, it is recommended not to exceed 80% usage of resource utilization for a long period of time. If there is a need for larger resource scale, please apply for private customization. |
| 21 | + |
| 22 | +## Create Postgresql Cluster Service instance |
| 23 | + |
| 24 | +- Create Postgresql service |
| 25 | +``` |
| 26 | +# drycc resources:create postgresql-cluster:standard-10 `my_pg_001` |
| 27 | +``` |
| 28 | +- View service status |
| 29 | +``` |
| 30 | +# drycc resources:describe `my_pg_001` |
| 31 | +``` |
| 32 | +- Bind service |
| 33 | +``` |
| 34 | +# drycc resources:bind `my_pg_001` |
| 35 | +``` |
| 36 | +- View resource status |
| 37 | +``` |
| 38 | +# drycc resources:describe `my_pg_001` |
| 39 | +``` |
| 40 | + |
| 41 | +## Create Service with values file |
| 42 | + |
| 43 | +`vim values.yaml` |
| 44 | +``` |
| 45 | +# create or update pg instance template yaml |
| 46 | +networkPolicy.allowNamespaces: |
| 47 | + - mx-test1 |
| 48 | +service.type: ClusterIP |
| 49 | +metrics.enabled: true |
| 50 | +backup: |
| 51 | + # whether BackUP should be enabled |
| 52 | + enabled: true |
| 53 | + # Cron schedule for doing base backups |
| 54 | + scheduleCronJob: "20 0 * * 0" |
| 55 | + Amount of base backups to retain |
| 56 | + retainBackups: 2 |
| 57 | + s3: |
| 58 | + awsAccessKeyID: "" |
| 59 | + awsSecretAccessKey: "" |
| 60 | + walGS3Prefix: "s3://xx" |
| 61 | + awsEndpoint: "http://xxxx:9000" |
| 62 | + awsS3ForcePathStyle: "true" |
| 63 | + awsRegion: dx-1 |
| 64 | +``` |
| 65 | +``` |
| 66 | + drycc resources:create postgresql-cluster:standard-10 `my_pg_001` -f ./values.yaml |
| 67 | +``` |
| 68 | + |
| 69 | +## Update Service |
| 70 | +### Create app user and database |
| 71 | + |
| 72 | +- Login database web with admin user & password |
| 73 | + |
| 74 | +- Change administrator initial password |
| 75 | +``` |
| 76 | +ALTER USER administrator WITH ENCRYPTED PASSWORD 'newpassword'; |
| 77 | +``` |
| 78 | +- View total connections number in postgresql cluster; |
| 79 | +``` |
| 80 | +show max_connections ; |
| 81 | +``` |
| 82 | +- CREATE APP USER |
| 83 | +``` |
| 84 | +CREATE USER `myuser` WITH CONNECTION LIMIT `conn limit` LOGIN ENCRYPTED PASSWORD 'password'; |
| 85 | +GRANT `myuser` to administrator ; |
| 86 | +``` |
| 87 | +- CREATE APP DATABASE |
| 88 | +``` |
| 89 | +CREATE DATABASE `mydb` OWNER `myuser`; |
| 90 | +
|
| 91 | +``` |
| 92 | +- CREATE EXTENSIONS |
| 93 | +``` |
| 94 | +CREATE EXTENSION pg_buffercache; |
| 95 | +``` |
| 96 | + |
| 97 | +### Network Access |
| 98 | + |
| 99 | +Default access allow policy: only namespace scope. |
| 100 | + |
| 101 | +- allow `mx-test1` namespace access |
| 102 | + |
| 103 | +`vim values.yaml ` |
| 104 | +``` |
| 105 | +networkPolicy.allowNamespaces: |
| 106 | + - mx-test1 |
| 107 | +``` |
| 108 | +``` |
| 109 | +drycc resources:update postgresql-cluster:standard-10 `my_pg_001` -f ./values.yaml |
| 110 | +``` |
| 111 | + |
| 112 | + - Assign external network IP address |
| 113 | + |
| 114 | +`vim values.yaml` |
| 115 | +``` |
| 116 | + service.type: LoadBlancer |
| 117 | +``` |
| 118 | +``` |
| 119 | +drycc resources:update postgresql-cluster:standard-10 `my_pg_001` -f ./values.yaml |
| 120 | +``` |
| 121 | +- View resource status |
| 122 | +``` |
| 123 | +# drycc resources:describe `my_pg_001` |
| 124 | +``` |
| 125 | + |
| 126 | + ### Manger backup your data `Very important` |
| 127 | + |
| 128 | +`Strongly recommend enabling this feature.` |
| 129 | +`Strongly recommend enabling this feature.` |
| 130 | +`Strongly recommend enabling this feature.` |
| 131 | + |
| 132 | +PG data backup use S3 as backenp store. Choose an independent storage space `outside of the current environment` as your backup space. |
| 133 | + |
| 134 | +`vim values.yaml` |
| 135 | +``` |
| 136 | +backup: |
| 137 | + # whether BackUP should be enabled |
| 138 | + enabled: true |
| 139 | + # Cron schedule for doing base backups |
| 140 | + scheduleCronJob: "20 0 * * 0" |
| 141 | + Amount of base backups to retain |
| 142 | + retainBackups: 2 |
| 143 | + s3: |
| 144 | + awsAccessKeyID: DO9l771LqiwZkhhz |
| 145 | + awsSecretAccessKey: R3Dv0NEmJBo8JFdn1q8jz49ArWwpDjFn |
| 146 | + walGS3Prefix: mx-test |
| 147 | +``` |
| 148 | +``` |
| 149 | +drycc resources:update postgresql-cluster:standard-10 `my_pg_001` -f ./values.yaml |
| 150 | +``` |
| 151 | + |
| 152 | +You can modify multiple content at once, there is no need to modify part of it each time. |
| 153 | + |
| 154 | + |
| 155 | +## Destroy Service |
| 156 | + |
| 157 | +- Unbind service first |
| 158 | +``` |
| 159 | +# drycc resources:unbind `my_pg_001` |
| 160 | +``` |
| 161 | +- Destroy service |
| 162 | +``` |
| 163 | +# drycc resources:destroy `my_pg_001` |
| 164 | +``` |
| 165 | +# 修改pg在容器中分配的动态共享内存不足的问题 |
| 166 | +https://www.cnblogs.com/daniel-hutao/p/17903993.html |
0 commit comments