Home
- Details
- Written by: po3dno
- Category: MariaDB
- Hits: 1120
A MariaDB Support customer recently asked how they could automatically drop old partitions after 6 months. MariaDB does not have a mechanism to do this automatically out-of-the-box, but it is not too difficult to create a custom stored procedure and an event to call the procedure on the desired schedule. In fact, it is also possible to go even further and create a stored procedure that can also automatically add new partitions. In this blog post, I will show how to write stored procedures that perform these tasks.
PARTITIONED TABLE DEFINITION
For this demonstration, I’ll use a table definition based on one from MySQL’s documentation on range partitioning, with some minor changes:
DROP TABLE IF EXISTS db1.quarterly_report_status;
CREATE TABLE db1.quarterly_report_status (
report_id INT NOT NULL,
report_status VARCHAR(20) NOT NULL,
report_updated TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP
) ENGINE=InnoDB
PARTITION BY RANGE ( UNIX_TIMESTAMP(report_updated) ) (
PARTITION p_first VALUES LESS THAN ( UNIX_TIMESTAMP('2016-10-01 00:00:00')),
PARTITION p201610 VALUES LESS THAN ( UNIX_TIMESTAMP('2016-11-01 00:00:00')),
PARTITION p201611 VALUES LESS THAN ( UNIX_TIMESTAMP('2016-12-01 00:00:00')),
PARTITION p201612 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-01-01 00:00:00')),
PARTITION p201701 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-02-01 00:00:00')),
PARTITION p201702 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-03-01 00:00:00')),
PARTITION p201703 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-04-01 00:00:00')),
PARTITION p201704 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-05-01 00:00:00')),
PARTITION p201705 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-06-01 00:00:00')),
PARTITION p201706 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-07-01 00:00:00')),
PARTITION p201707 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-08-01 00:00:00')),
PARTITION p201708 VALUES LESS THAN ( UNIX_TIMESTAMP('2017-09-01 00:00:00')),
PARTITION p_future VALUES LESS THAN (MAXVALUE)
);
- Details
- Written by: po3dno
- Category: Windows
- Hits: 1087
3. Right-click on regedit icon, click Run as administrator
4. Go to HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Power\PowerSettings\238C9FA8-0AAD-41ED-83F4-97BE242C8F20\7bc4a2f9-d8fc-4469-b07b-33eb785aaca0
5. Double click on Attributes
6. Enter number 2.
7. Go to Advanced power settings (click on Windows button, write power options, click on Power Options, in the selected plan click on the Change plan settings, click on the Change advanced power settings).
8. Click on the Change settings that are currently unavailableMinimum value
0 (Never idle to sleep)
- Details
- Written by: po3dno
- Category: Windows
- Hits: 1083
Отсутствие схем электропитания вероятнее всего связано с новым режимом питания на устройствах с аккумулятором в версии 1709 . Если щелкнуть значок батареи, то можно видеть слайдер, который появится только, если выбрана схема «Сбалансированная».
Схемы можно восстановить следующими способами: сделать схему «Высокая производительность» или «Экономия энергии» активной, при этом активная схема появится в Панели управления, или же создать дубликаты этих схем, и тогда появятся обе схемы. В Командной строке нужно выполнить команды.
Сделать схему активной: powercfg.exe /setactive <GUID схемы питания>
Создать дупликат схемы: powercfg -duplicatescheme <GUID схемы питания>
Вместо <GUID схемы питания> нужно вставить GUID соответствующей схемы.
Для схемы "Сбалансированная" - 381b4222-f694-41f0-9685-ff5bb260df2e
Для схемы "Экономия энергии" - a1841308-3541-4fab-bc81-f71556f20b4a
Для схемы "Высокая производительность" - 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
- Details
- Written by: po3dno
- Category: Other
- Hits: 1138
ether1 = ISP1
ether2 = ISP2
ether3 = bridge
Step 0.
Macs if need
set [ find default-name=ether1 ] mac-address=x name=ISP1
set [ find default-name=ether2 ] mac-address=x name=ISP2
Step 1.
Add dynamic client on ether1 & ether2 (WAN1 & WAN2)
/ip dhcp-clientadd add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ISP1 use-peer-dns=no use-peer-ntp=noadd add-default-route=no dhcp-options=hostname,clientid disabled=no interface=ISP2 use-peer-dns=no use-peer-ntp=no |
Step 2: Add Lan Interface IP . ( ether3 )
|
1
2
|
/ip addressadd address=192.168.88.1/24 interface=ether3 network=192.168.88.0 |
Step 3: Add Firewall Nat rule.
/ip firewall natadd action=masquerade chain=srcnat disabled=yes out-interface=ISP1
add action=masquerade chain=srcnat disabled=yes out-interface=ISP2 |
Step 4: Add firewall Mangle Rules
/ip firewall mangleadd action=mark-connection chain=prerouting comment=ISP1 connection-state=new disabled=yes in-interface=ISP1 new-connection-mark=ISP1-conn passthrough=yes
add action=mark-routing chain=output comment=ISP1 connection-mark=ISP1-conn disabled=yes new-routing-mark=ISP1-route passthrough=yes add action=mark-connection chain=prerouting comment=ISP2 connection-state=new disabled=yes in-interface=ISP2 new-connection-mark=ISP2-conn passthrough=yes add action=mark-routing chain=output comment=ISP2 connection-mark=ISP2-conn disabled=yes new-routing-mark=ISP2-route passthrough=yes add action=mark-connection chain=prerouting comment=ISP1 connection-state=new disabled=yes dst-address-type=!local in-interface=bridge new-connection-mark=ISP1-conn passthrough=yes per-connection-classifier=both-addresses:2/0 add action=mark-connection chain=prerouting comment=ISP2 connection-state=new disabled=yes dst-address-type=!local in-interface=bridge new-connection-mark=ISP2-conn passthrough=yes per-connection-classifier=both-addresses:2/1 add action=mark-routing chain=prerouting comment=ISP1 connection-mark=ISP1-conn disabled=yes in-interface=bridge new-routing-mark=ISP1-route passthrough=yes add action=mark-routing chain=prerouting comment=ISP2 connection-mark=ISP2-conn disabled=yes in-interface=bridge new-routing-mark=ISP2-route passthrough=yes add action=mark-connection chain=input disabled=yes in-interface=ISP1 new-connection-mark=ISP1-conn passthrough=yes add action=mark-routing chain=output connection-mark=ISP1-conn disabled=yes new-routing-mark=ISP1-route passthrough=no add action=mark-connection chain=input disabled=yes in-interface=ISP2 new-connection-mark=ISP2-conn passthrough=yes add action=mark-routing chain=output connection-mark=ISP2-conn disabled=yes new-routing-mark=ISP2-route passthrough=no add action=mark-connection chain=forward disabled=yes in-interface=ISP1 new-connection-mark=ISP1-conn-f passthrough=no add action=mark-routing chain=prerouting connection-mark=ISP1-conn-f disabled=yes in-interface=bridge new-routing-mark=ISP1-route add action=mark-connection chain=forward disabled=yes in-interface=ISP2 new-connection-mark=ISP2-conn-f passthrough=no add action=mark-routing chain=prerouting connection-mark=ISP2-conn-f disabled=yes in-interface=bridge new-routing-mark=ISP2-route |
Step 5: Add Routes ( Setting temporary gateway)
/ip routeadd check-gateway=ping comment="Ether1-Wan routing gateway" distance=1 gateway=192.168.0.1 routing-mark=ISP1-routeadd check-gateway=ping comment="Ether2-Wan routing gateway" distance=1 gateway=192.168.1.1 routing-mark=ISP2-routeadd comment=Ether1-Wan distance=1 gateway=192.168.0.1add comment=Ether2-Wan distance=2 gateway=192.168.1.1 |
step 6: Create New Script with name change_gw and copy below lines.
|
:global newgw [/ip dhcp-client get [find interface="ISP1" ] gateway ]
:global activegw [/ip route get [/ip route find comment="Ether1-Wan"] gateway ] :if ($newgw != $activegw) do={ /ip route set [find comment="Ether1-Wan"] gateway=$newgw /ip route set [find comment="Ether1-Wan routing gateway"] gateway=$newgw } :global newgw [/ip dhcp-client get [find interface="ISP2" ] gateway ] :global activegw [/ip route get [/ip route find comment="Ether2-Wan"] gateway ] :if ($newgw != $activegw) do={ /ip route set [find comment="Ether2-Wan"] gateway=$newgw /ip route set [find comment="Ether2-Wan routing gateway"] gateway=$newgw } |
Step 7: Final Step.
- Details
- Written by: po3dno
- Category: Other
- Hits: 1012
It is possible to go back to a more classic iptables setup. First, stop and mask the firewalld service:
systemctl stop firewalld
systemctl mask firewalld
Then, install the iptables-services package:
yum install iptables-services
Enable the service at boot-time:
systemctl enable iptables
Managing the service
systemctl [stop|start|restart] iptables
Saving your firewall rules can be done as follows:
service iptables save
or
/usr/libexec/iptables/iptables.init save