Resource plans in GBase 8a (e.g., plan_day, plan_night) are not directly bound to time and do not support cron expressions. Their automated switching relies entirely on external schedulers — such as Linux crontab — that execute ACTIVE / DEACTIVE commands at the right moment.
Core Mechanism: External Trigger, Internal Execution
A resource plan is just a "policy container" — it takes effect only when activated (ACTIVE). GBase 8a has no built‑in timer, so the full automation chain is:
- External scheduler (crontab, etc.) fires at the scheduled time.
- A script connects to the database and runs the
ACTIVE/DEACTIVE RESOURCE PLANcommand. - The plan swap takes effect.
Manual Switching Commands
-- Activate the daytime plan
ACTIVE RESOURCE PLAN plan_day ON VC vc1;
-- Deactivate the current plan
DEACTIVE RESOURCE PLAN ON VC vc1;
-- Activate the nighttime plan
ACTIVE RESOURCE PLAN plan_night ON VC vc1;
Automating with Crontab
-
Create a switching script (e.g.,
switch_plan.sh):
#!/bin/bash
GC_CLI_PATH=/opt/gbase/bin/gccli
VC_NAME=vc1
USER=gbase
PASSWORD='your_password'
# Deactivate the current plan, then activate the nighttime plan
$GC_CLI_PATH -u$USER -p$PASSWORD -e "DEACTIVE RESOURCE PLAN ON VC $VC_NAME; ACTIVE RESOURCE PLAN plan_night ON VC $VC_NAME;"
- Set up crontab entries:
# Activate daytime plan every day at 8:00 AM
0 8 * * * /opt/gbase/bin/gccli -ugbase -p'password' -e "ACTIVE RESOURCE PLAN plan_day ON VC vc1;"
# Switch to nighttime plan every day at 8:00 PM
0 20 * * * /home/gbase/switch_plan.sh
Make sure the executing user is allowed in /etc/cron.allow.
Why No Built‑in Cron‑Like Scheduler?
- Separation of concerns: The database focuses on enforcing resource limits; external tools handle complex scheduling logic.
- Flexibility: External scripts can switch plans based on load or other conditions, not just time.
- Maintainability: Adjusting switch times only requires changing the external script — no database object modifications, reducing risk.
Production Recommendations
- Prefer enterprise scheduling platforms (like GDOM) or job orchestration systems.
- Ensure the account running the commands (e.g.,
gbase) has the necessary privileges. - Add logging and error alerts to your scripts so you can monitor switch events in your gbase database.
This design keeps the gbase database lean and gives you full control over when and how resource plans change.
Top comments (0)