2024-02-25 20:02:12 -05:00
Migration from Digital Ocean to Hetzner, covering about 120 servers (20 db, 80 task, 20 app)
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
## Tweet
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
> "Time for a big server transition. I’ m moving the servers from Digital Ocean to Hetzner. Every database server (postgresql, mongo, redis x 4, elasticsearch, prometheus, consul, and sentry) is making the move. I’ m going to do it all at once, which means about an hour of downtime."
> "Afterwards, you shouldn't notice anything different, although these are bare metal servers, so theoretically they should be faster and more reliable."
```
2024-02-25 12:30:42 -05:00
make maintenance_on
make celery_stop
2024-02-25 20:02:12 -05:00
```
2024-02-25 12:30:42 -05:00
2024-02-25 20:02:12 -05:00
## Postgres
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
> Edit postgres/consul_service.json: db-postgres2 -> hdb-postgres-1
```
2024-02-18 17:17:05 -05:00
aps -l db-postgres2,hdb-postgres-1,hdb-postgres-2 -t consul
aps -l hdb-postgres-1 -t pg_promote
2024-02-25 20:02:12 -05:00
```
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
## Mongo
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
```
2024-02-18 17:17:05 -05:00
sshdo db-mongo-primary1
2024-02-25 13:54:14 -05:00
sudo docker exec -it mongo mongo
2024-02-18 17:17:05 -05:00
rs.config()
rs.reconfig()
2024-02-25 20:02:12 -05:00
```
## Mongo analytics
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
> Edit mongo/tasks/main.yml: mongo_analytics_secondary
```
2024-02-25 13:54:14 -05:00
aps -l db-mongo-analytics2,hdb-mongo-analytics-1 -t consul
2024-02-25 20:02:12 -05:00
```
## Redis
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
> Edit redis/tasks/main.yml: redis_secondary
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
```
2024-02-25 12:30:42 -05:00
aps -l hdb-redis-user-1,hdb-redis-user-2,db-redis-user -t consul
aps -l hdb-redis-session-1,hdb-redis-session-2,db-redis-sessions -t consul
aps -l hdb-redis-story-1,hdb-redis-story-2,db-redis-story1 -t consul
aps -l hdb-redis-pubsub,db-redis-pubsub -t consul
2024-02-19 17:43:45 -05:00
apd -l hdb-redis-user-1,hdb-redis-session-1,hdb-redis-story-1,hdb-redis-pubsub -t replicaofnoone
2024-02-25 20:02:12 -05:00
```
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
## Elasticsearch
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
> Edit elasticsearch/tasks/main.yml: elasticsearch_secondary
```
2024-02-25 13:54:14 -05:00
aps -l db-elasticsearch1,hdb-elasticsearch-1 -t consul
2024-02-25 20:02:12 -05:00
```
> Eventually `MUserSearch.remove_all()`
2024-02-18 17:17:05 -05:00
2024-02-25 20:02:12 -05:00
## Test hwww.newsblur.com
```
2024-02-25 12:30:42 -05:00
ansible-playbook ansible/deploy.yml -l happ-web-01 --tags maintenance_off
2024-02-25 20:02:12 -05:00
```
## Looks good? Launch
2024-02-25 12:30:42 -05:00
2024-02-25 20:02:12 -05:00
> Haproxy on DO to redirect to Hetzner
```
2024-02-18 17:21:03 -05:00
aps -l www -t haproxy
2024-02-25 20:02:12 -05:00
```
> Change DNS to point to Hetzner
```
2024-02-25 12:30:42 -05:00
make maintenance_off
2024-02-25 20:02:12 -05:00
```
2024-02-25 15:41:35 -05:00