
## 命令

重启服务:

```
kubectl --kubeconfig=homelab.yaml  --namespace=coal-master rollout restart deployment nginx
```


更新k8s配置文件

```
kubectl apply --kubeconfig=homelab.yaml  -k .\k8s\master\
```






## 部署 debian
安装redis
```bash
sudo apt install -y lsb-release curl gpg
curl -fsSL https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg

echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list

sudo apt-get update
sudo apt-get install -y redis
```

安装pg

```bash
sudo sh -c 'echo "deb https://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install postgresql-16
sudo apt-get -y install postgresql-16-postgis-3

```

安装timescaledb插件

```bash
sudo apt-get -y install postgresql-server-dev-16

sudo apt-get install -y libkrb5-dev
sudo apt-get install -y cmake

git clone https://github.com/timescale/timescaledb

cd timescaledb

git checkout 2.13.0

./bootstrap

cd build && make

make install

# 添加到配置文件 shared_preload_libraries = 'timescaledb'

systemctl restart postgresql 

```



安装jdk17

```
apt install -y openjdk-17-jdk

```


全库备份

```
cd /data/backup && sudo -u postgres  pg_dumpall | gzip > /data/backup/$(date +"%Y%m%d%H%M%S").sql.gz

```

rabbitmq 初始化

```
rabbitmq add_vhost /coal


```


添加数据采集rabbitmq用户


```

docker compose exec -it rabbitmq bash

rabbitmqctl add_user datacollector datacollector
rabbitmqctl set_permissions --vhost /coal/test datacollector '' 'sysExchange|amq.default' 'pms\.client\.*|dataCollector\.*|weight20\.*'

```





本地端口映射


```

D:\dev\gost-windows-amd64.exe -L=tcp://:5672/192.168.59.128:5672
```

## 问题
```

(HTTP code 500) server error - Ports are not available: exposing port TCP 0.0.0.0:5672 -> 0.0.0.0:0: listen tcp 0.0.0.0:5672: bind: An attempt was made to access a socket in a way forbidden by its access permissions.

net stop hns
net start hns

```
