Docker版本CentOS 7.6 Docker CE 19.03.9
/pass n 查找文件里的关键词;
cd conf/
cp ./* /etc/fdfs/
conf 目录下的配置文件拷贝到 /etc/fdfs 目录下
tar -zxvf xxx.tar.gz 解压文件 (记得cd到解压目录)
z代表gzip的压缩包;x代表解压;v代表显示过程信息;f代表后面接的是文件
**windows杀死进程命令: **
netstat -ano | findstr port(端口号)
tasklist | findstr 2000(进程号)
taskkill -PID <进程号> -F //强制关闭某个进程
mac osx杀死进程命令:
sudo lsof -nP -iTCP -sTCP:LISTEN 或者
sudo lsof -n -P | grep LISTEN
sudo lsof -i tcp:<输入端口号>
sudo kill -9 PID
jar打包
java -jar hello-springboot2-0.0.1-SNAPSHOT.jar --server.port=8089
java -jar hello-springboot2-0.0.1-SNAPSHOT.jar
mvn clean package -Dmaven.test.skip=true
Mysql相关
sudo su root
docker images
docker search mysql
docker pull mysql:8.0.29
docker run -p 3306:3306 --name mysql \
-v /home/lighthouse/mysql/conf:/etc/mysql/conf.d \
-v /home/lighthouse/mysql/logs:/logs \
-v /home/lighthouse/mysql/data:/var/lib/mysql \
-e MYSQL_ROOT_PASSWORD=Mysql4mblog0719! --restart=always -d mysql:8.0.29
参数讲解: -p是将docker中mysql端口号3306映射成为12345端口,也可以选择不映射,使用默认的3306
--name mysql: 运行服务的取名
-v是将主机目录下的文件挂载到容器中路径下(/root是我本人用户)
-e MYSQL_ROOT_PASSWORD:初始化root用户密码
-d mysql:8.0.29 : 后台运行mysql8.0.29
grep “password” /var/log/mysqld.log
mysql -uroot -p {你的密码}
set password for ‘root’@’localhost’ = password(‘密码’);
update mysql.user set host=’%’ where user=’root’ and host=’localhost’;
sudo service mysqld start/restart/stop
select host,user,plugin,authentication_string from mysql.user;
mysql -u root -p {你的密码}
ALTER user 'root'@'%' IDENTIFIED WITH mysql_native_password BY '{你的密码}';
FLUSH PRIVILEGES;
show databases;
use db_mblog;
show tables;
更改8.0以上数据库root密码:
ALTER USER 'root'@'localhost' IDENTIFIED BY '{你的密码}';
flush privileges;
Docker相关
docker ps -a
docker rm container_id
systemctl start firewalld
systemctl stop firewalld
systemctl status firewalld
docker container update --restart=always mysql
注意永久关闭防火墙后,再次开启,还需systemctl daemon-reload
systemctl restart docker.service,否则网站会挂掉
ps -ef |grep docker 查看docker是否启动。
systemctl start docker 启动docker
systemctl status docker 查看docker 服务状态
systemctl enable docker 设置开机自启动
systemctl restart network
(/usr/bin/docker-current: Error response from daemon: driver failed programming external connectivity on endpoint determined_snyder (b40a33994c3498d73f9a70e06b6e4076b66fb79e9a2fbc7ec8f67ec41710ba73): iptables failed: iptables --wait -t nat -A DOCKER -p tcp -d 0/0 --dport 8000 -j DNAT --to-destination 172.17.0.6:8000 ! -i docker0: iptables: No chain/target/match by that name.
(exit status 1).))错误执行以下命令重启
sudo service docker restart
docker run -itd --name mysql -p 3306:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql
systemctl daemon-reload
systemctl restart docker.service
netstat -nptl
iptables -L
iptables -L INPUT --line-numbers
(docker 服务启动的时候,docker服务会向iptables注册一个链,以便让docker服务管理的containner所暴露的端口之间进行通信
通过命令可以查看iptables链)
service iptables save
service iptables restart
docker rename nginx nginx_1.22.0
docker volume ls
docker exec -it mblog-4.0.0 bash(进入mblog项目容器)
docker cp /root/storage/avatars cb6a0a1cf13d(也可以是容器名):/app/mblog/storage/ (将root下的文件拷贝到容器中指定目录下)
不进入容器,telnet localhost 6379
auth {你的密码} 删除Alt+back space
进入容器后,redis-cli
auth {你的密码}
docker cp /usr/local/nginx/ssl/Nginx/ 36f2af3d0278:/etc/nginx/ssl/Nginx
docker-compose down\ docker-compose up -d (message-service)
from Docker教程合集2019
docker rm $(docker ps -a -q)
docker container prune
docker inspect ubuntu
docker top 查看容器进程
docker logs -f --tail=3 -t ubuntu
docker export nginx > ./blog/docker/nginx.tar
cat nginx.tar | docker import – importednginx:ilatest(镜像仓库和tag)
docker images n*
Nginx相关
cd /usr/local/nginx/sbin
./nginx -V(查看版本号)
linux服务器上docker(先docker exec -it nginx bash进入容器再查看)
nginx -V
docker run --name nginx -p 80:80 -d nginx或者
docker run --name nginx -p 80:80 -d nginx:1.22.0
whereis nginx
mkdir -p /usr/local/nginx/{conf,html,logs,ssl}(退出容器后的操作)
docker cp a153191a7865:/etc/nginx/nginx.conf /usr/local/nginx/conf/
docker cp /root/storage/logo2.png cb6a0a1cf13d:/app/mblog/storage/templates/youth/dist/images/logo/
docker exec nginx(容器名) nginx -s reload(重新加载新配置,Nginx可以hot-reload配置而不重新启动,修改完配置文件一定要记得用这个命令重启)
docker exec nginx(容器名) nginx -t(测试验证配置文件问题)
apt-get update
apt-get install vim
vi -r default.conf(恢复)
rm -f .default.conf.swp(编辑脚本时,强制退出导致的)
docker run \
--name nginx \
-p 443:443 -p 80:80 \
-v /usr/local/nginx/logs:/var/log/nginx \
-v /usr/local/nginx/html:/usr/share/nginx/html \
-v /usr/local/nginx/conf/nginx.conf:/etc/nginx/nginx.conf \
-v /usr/local/nginx/conf.d:/etc/nginx/conf.d \
-v /usr/local/nginx/ssl:/etc/nginx/ssl/ \
--privileged=true -d --restart=always nginx:1.22.0
docker run --name redis -d -p 6379:6379 redis:7.0.0 --requirepass P@assword123! --privileged=true
docker run hello-world
docker info查看docker存储位置
upstream springboothub.com {
server 101.32.220.246:32768 weight=1;
}
Docker查看日志
docker logs --since 30m cb6a0a1cf13d
docker logs cb6a0a1cf13d
docker inspect --format '{{.LogPath}}' cb6a0a1cf13d
dmesg | grep mysql(查看自动退出的原因)
tail -f /var/log/secure(实时监控尝试登录的IP信息)
查找文件
find / -name mblog-4.0.0
grep -r “secretkey_path” .(当前目录查找)(from k8s 4-5 11:00)
grep -v “vmware”(不包含vmware)
vi进去 :157 定位到157行(from k8s 4-5 11:00)
chmod 755 data(from k8s 4-5 11:00)
docker images | grep -v “vmware”(剔除vmware开头的文件)
公用命令
scp local_file remote_username@remote_ip:remote_folder
或
scp local_file remote_username@remote_ip:remote_file
第1,2个指定了用户名,命令执行后需要再输入密码,第1个仅指定了远程的目录,文件名字不变,第2个指定了文件名
df -lh
fdisk -l
cp -r 文件夹 递归拷贝
ls -l --time-style='+%Y-%m-%d %H:%M:%S'(显示到秒)
ls -lht
history
查看系统日志-i是不区分大小写
cat /var/log/messages|grep kube-apiserver|grep -i failed
which docker
mv zoo_sample.cfg zoo.cfg
yum install -y lrzsz上传下载文件工具
chown imooc(用户名):imooc(用户名) /product
# root用户 $普通用户
ps aux
ps auxf(查看进程树) 或者运行 netstat -vatn 来检查所有的 TCP 连接
ll -h /var/log/btmp(查看登录记录文件大小)
top(top查看LINUX服务器资源占用情况,https://blog.csdn.net/J080624/article/details/80526310)
who /var/log/wtmp (查看登陆过的用户)
lastb(等同于查看 /var/log/btmp 文件内容)
lastb | head
lastb | less
lastb lwc -i
lastb -n 20或者-20
lastb | awk '{ print $3}' | sort | uniq -c | sort -n
grep "Failed password for root" /var/log/secure | awk '{print $11}' | sort | uniq -c | sort -nr | more (查看ssh登录失败IP)
w(登录系统去看下是否有其它人陌生人也在线上)
gg(跳转到文件头部)
shift+G(跳转到文件尾部)
vim esc情况下,y复制选中内容,p粘贴
n(向下重复搜索)
N(向上重复搜索)
free -h(查看内存使用情况)
crontab -e
service sshd restart
ssh-keygen -t rsa -C springboothub.com.rsakey
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:kKvDUE9NFnWIuw44FKbGy9mPw5XyW8V3QftBJq1vrOY springboothub.com.rsakey
cd /
cd /root/.ssh
chmod 700 ~/.ssh
lsattr
-------------e-- ./id_rsa.pub
----ia-------e-- ./authorized_keys
-------------e-- ./id_rsa
chattr -i authorized_keys
cat id_rsa.pub >> authorized_keys(执行以上命令后成功)
chattr -a authorized_keys
chmod 600 authorized_keys(执行以上命令后成功)
执行完记得保护:
chattr +i authorized_keys
chattr +a authorized_keys
打包命令:
nohup java -jar guns-order-0.0.1.jar &
jar -tf mblog-latest.jar查看jar里的内容
curl message-service:9090\ docker exec -it cb6 bash\ 进入容器apt-get update\ apt-get install net-tools\ netstat -an|grep 9090
k8s:
kubectl version
kubectl run kubernetes-bootcamp --image=jocatalin/kubernetes-bootcamp:v1 --port=8080
kubectl logs kubernetes-bootcamp-6b7849c495-2sgql -f
kubectl describe pods kubernetes-bootcamp-6b7849c495-2sgql
kubectl exec -it kubernetes-bootcamp-6b7849c495-2sgql bash
开启命令:systemctl start firewalld
临时关闭命令:systemctl stop firewalld
永久关闭命令:systemctl disable firewalld
防火墙状态命令: systemctl status firewalld
journalctl -xefu kubelet
kubectl get pods -o wide
kubectl get pods -l app=nginx
kubectl get secret
kubectl get deploy
kubectl describe pod nginx
kubectl create -f nginx-pod.yml
kubectl apply -f nginx-pod.yml
kubectl set image pods nginx nginx=nginx:1.22.0(修改镜像版本,用命令作修改,apply不会变化,还是读取配置文件中的内容,只承认通过配置文件修改的内容)
kubectl logs ${ kubectl get pods NAME} 容器名
kubectl delete pod nginx
kubectl logs -f nginx
kubectl get nodes:node 列表
kubectl delete node xxx.xx.xxx-ip:删除 inactive 的 dead node (通过 ip)
calicoctl get nodes:calico node 列表
calicoctl delete node xxx: 删除 dead node(通过 calicoctl get node(s)出来的NAME)
calicoctl node run: 在新节点上跑 calico node ,让新的 node 生效 (bgp peer)
calicoctl node status: 查看状态,确认没有问题
kubectl expose deploy kubernetes-bootcamp --type="NodePort" --target-port=8080 --port=80
kubectl get services(简写:svc)
kubectl get deploy
kubectl get pods -o wide
kubectl get secrets
kubectl get sa(serviceaccount)
kubectl get sa -o yaml
kubectl get sa -o json
kubectl get pods nginx -o json
kubectl scale deploy kubernetes-bootcamp --replicas=4
curl 10.0.4.5:26904
kubectl describe service kubernetes-bootcamp
netstat -ntpl|grep 26904
kubectl -n kube-system get deploy
kubectl -n kube-system get pods -o wide
kubectl -n kube-system get svc
kubectl run busybox --rm=true --image=busybox --restart=Never --tty -i
wget -q0 - 10.68.102.205:8080
cd kubernetes-starter/
kubectl create/delete 7-8 1955 -f target/services/kube-dns.yaml
scp -r /etc/kubernetes/ca/ root@10.0.4.5:/etc/kubernetes/ca/
42e3a0b34253819db706db56eff848e9
Gitlab:
git init
git remote add origin ssh://git@43.142.158.6:2222/hashghost/microservice.git
git add .
git status
git reset
vi .gitignore
git commit -m "init"
git push origin master
iptables:
iptables -L INPUT --line-numbers(line前面两个杠)
iptables -t nat -nL
iptables -D INPUT 7
iptables -I INPUT -s 112.10.196.0/24 -p tcp --dport 43956 -j ACCEPT
iptables -I INPUT -s 39.170.43.0/24 -p tcp --dport 2375 -j ACCEPT
iptables -I INPUT -s 112.10.196.0/24 -p tcp --dport 2375 -j ACCEPT
harbor
docker-compose down
./prepare
docker-compose up -d
注意:本文归作者所有,未经作者允许,不得转载