剛安裝完的 CentOS,在預設畫面都是顯示目前路徑,並不是完整路徑,在使用上常常要下 pwd 去確認目前的路徑,這部份只要在 /etc/profile 上加上一段指令,之後就會出現完整路徑。
CentOS
WOL (Wake On Lan) Wake On Lan remote boot function-you can boot the computer outside
Wake on LAN-you can boot your computer when you are outside
Because I have two PCs at home, one Windows 10 and one Linux CentOS 7, I don’t know if the machine is too old or there is a power problem. Sometimes it hangs up suddenly. When I went home, I saw him resting and shut down there. While waiting to press the boot button, I searched for information on the Internet and found WOL (Wake On Lan) about the method of booting on the Internet, so I wanted to give it a try, and then I set it up. In fact, it is not difficult. One problem, his environment is executed under the LAN, but if you are outside, you have to use some other methods. If you have a router at home that supports the DMZ function, you can set the external IP to the internal IP. But there is another problem. If you don’t have a fixed IP, it won’t work. Later, I used a useless mobile phone to do remote WOL (Wake On Lan). The information is as follows.
use tools
- Settings on the WOL host (Windows 10 / CentOS 7)
- Teamviewer HOST
- Wake On Lan (Android / Free)
如何將 Docker 升級至最新版本
最近在安裝 Docker 時發現,怎麼使用 yum install -y docker
安裝的 Docker 版本都會是 Docker version 1.13.1 (官網),這版本已經是 2017年2月8日,好舊的版本,目前官方都已經更新到 Docker version 20.10.3 (官網) 2021年2月1日。
整理了一下,如何將舊版本強制更新至最新版流程。
使用的OS為 CentOS7
一、確認目前的版本
可使用以下指令確認,並記錄目前已安裝的套件docker -v
or docker version
rpm -qa | grep docker
[root@web ~]# docker -v Docker version 1.13.1, build 0be3e21/1.13.1 [root@web ~]# rpm -qa | grep docker docker-common-1.13.1-203.git0be3e21.el7.centos.x86_64 docker-client-1.13.1-203.git0be3e21.el7.centos.x86_64 docker-1.13.1-203.git0be3e21.el7.centos.x86_64
Docker 日誌放在哪?
雖然我們可以透過 docker logs <container name> 去看 container 裡的日誌,但是如果 docker 服務壞了,我們要去哪裡找呢?
Docker 日誌
Docker 日誌 一般是交给了 Upstart(Ubuntu 14.04) 或者 systemd (CentOS 7, Ubuntu 16.04)。前者一般位於 /var/log/upstart/docker.log 下,後者一般通過 jounarlctl -u docker 来讀取。不同系统的位置都不一樣,可以參考下表:
OS系統 | 日誌路徑 |
Ubuntu(14.04) | /var/log/upstart/docker.log |
Ubuntu(16.04) | journalctl -u docker.service |
CentOS | journalctl -u docker.service |
Fedora | journalctl -u docker.service |
如何在 Mysql Server 增加用戶權限
環境說明:
CentOS Linux release 7.9.2009 (Core)
MariaDB Ver 15.1 Distrib 5.5.68-MariaDB
常用指令:
[root@mysql ~]# mysql -uroot -p -h 192.168.0.2 -P 3306
-u 使用者帳號
-p 使用都密碼
-h 連線目標的IP(192.168.0.2),如果是本地則不需加入
-P 大P 是端口(port),預設為3306,若目標端口(port)有指定則需要填寫
一、登入 Mysql
[root@mysql ~]# mysql -uroot -p Enter password: ******** Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 3 Server version: 5.5.68-MariaDB MariaDB Server Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
如何建立私人的 docker registry 架設教學 (一)
一、建立自己的 docker registry 主機
參考docker registry 來源:https://hub.docker.com/_/registry
環境:CentOS 7
- Docker-Registry:私倉主機(docker-registry.com.cc:5000)
- nginx:連線至Docker_Registry主機進行 image push 流程
Docker-Registry主機上執行指令:docker run -d -p 5000:5000 -v /home/docker-registry/storage:/var/lib/registry --name registry registry:latest
[root@Docker-Registry ~]# docker run -d -p 5000:5000 -v /home/docker-registry/storage:/var/lib/registry --name registry registry:latest Unable to find image 'registry:latest' locally Trying to pull repository docker.io/library/registry ... latest: Pulling from docker.io/library/registry cbdbe7a5bc2a: Pull complete 47112e65547d: Pull complete 46bcb632e506: Pull complete c1cc712bcecd: Pull complete 3db6272dcbfa: Pull complete Digest: sha256:8be26f81ffea54106bae012c6f349df70f4d5e7e2ec01b143c46e2c03b9e551d Status: Downloaded newer image for docker.io/registry:latest 4c8c0b3e0981716be24d49c360a46c38ccdeaafd9f52ee541a250e8154f17941
指令說明:
-d 背景執行
-p 5000:5000 使用5000 port
-v 將本地的 /home/docker-registry/storage 關連至 /var/lib/registry
–name docker令名,可自定
registry:latest 取得docker hub 上 registry 最新的版本
建立完成後,可執行 docker ps -a
查看是否正常運行
[root@Docker-Registry ~]# docker ps -a CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 4c8c0b3e0981 registry:latest "/entrypoint.sh /e..." 18 minutes ago Up 18 minutes 0.0.0.0:5000->5000/tcp registry
如何建立一個私人的https
自己用 CA 簽自己的 certificate
- 先幫自己的 CA 生一組 key & certificate
- 幫自己的主機生一組 key & CSR
- 用自己的主機簽 CSR 讓他變成 certificate
openssl genrsa -des3 -out ca.key 4096
由於 CA 的 key 只有在簽 certificate 的時候會用到,不像 certificate 的 key 服務本身會用到,所以這邊可以加上 des3
,會要你輸入一個密碼加密。
openssl req -x509 -new -nodes -key ca.key -sha256 -days 365 -out ca.crt
接下來我們幫 CA 生一組 certificate,通常這個天數會久不少。
openssl genrsa -out host.key 4096
這組是主機上的服務要用的 key ,就不加密了。
openssl req -new -key host.key -sha256 -out host.csr
最後來簽這個 CSR 產生 certificate
openssl x509 -req -in host.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out host.crt -days 30 -sha256
如何從 Hub Docker 下載你要的image建立你的 Docker
目前 Hub Docker (https://hub.docker.com/) 上有需多 images 可以 pull 下來,這樣一來可以省去你去放光碟片,一步一步安裝你要的軟體。
使用 docker pull centos:latest
centos(為提供者):latest(為最新版號,你也可以指定你要的版本)
[root@localhost]# docker pull centos Using default tag: latest latest: Pulling from library/centos 8a29a15cefae: Pull complete Digest: sha256:fe8d824220415eed5477b63addf40fb06c3b049404242b31982106ac204f6700 Status: Downloaded newer image for centos:latest