Python调用Ansible API执行任务 2026-06-10| Python | Ansible 执行Ansible Task#!/usr/bin/env python# ansible verison is 4.10.0 python version 3.6from __future__ import (absolute_import, division, print_function)__metaclass__ = typeimport sysimport jsonfrom ansible ...
阅读更多 request模块封装API 2026-06-10| Python | Requests 基于Session认证
基于Cookie认证import requestsimport hashlibimport loggingimport mathimport refrom bs4 import BeautifulSouplogging.basicConfig(level=logging.DEBUG,format="%(asctime)s %(levelname)s %(mes ...
阅读更多 ansible教程 2026-06-10| DevOps | Ansible 安装ansibleyum方式安装导入阿里云epel yum源
wget http://mirrors.aliyun.com/repo/Centos-7.repowget http://mirrors.aliyun.com/repo/epel-7.repo
安装repo
yum install ansible python2-pip
模块authorized_key
管理用户authorized_k ...
阅读更多 Jenkins教程 2026-06-10| Jenkins | Pipeline Jenkins安装docker
创建网桥docker network create jenkins
初始化Jenkinsdocker run \ --name jenkins-docker \ --rm \ --detach \ --privileged \ --network jenkins \ --network-alias docker \ --env DOCKER_TLS_C ...
阅读更多 git svn常用命令 2026-06-10| DevOps | GIT git查看tag在哪个分支git branch --contains tags/<tag_id>
合并commit id代码获取a分支代码commit id
git checkout agit log
合并commit id到b分支
git checkout bgit cherry-pick <commit_id>git push origin b
取消commit id ...
阅读更多 Vuex状态管理 2026-06-10| VueJS | Vuex Vuex概念Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式,它采用集中式存储管理应用的所有组件的状态。Vuex 的存储管理器分为以下几个部分:
名称
描述
state
即存储状态的数据。在 Vuex 中,存储状态的数据被定义为一个对象,称为 state 对象。它是所有组件共享的数据源
getters
用于从 state 中派生出一些状态,类似于计算属性。Getter ...
阅读更多 清理registry容器仓库镜像 2026-06-10
下载脚本
curl https://raw.githubusercontent.com/burnettk/delete-docker-registry-image/master/delete_docker_registry_image.py | sudo tee /usr/local/bin/delete_docker_registry_image >/dev/null
chmod a+x ...
阅读更多 基于ceph rbd实现harbor HA后端存储 2026-06-10keepalived配置 1.创建keepalived配置文件
vrrp_instance VI_1 { state MASTER interface eth0 virtual_router_id 252 priority 100 advert_int 1 authentication { auth_type PASS auth_pass 123456 } virtual_ipaddress { 192.168.103.134/24 } notify_master "/etc/keepalived/notify.sh master" notify_backup "/etc/keepalived/notify.sh backup" notify_stop "/etc/keepalived/notify.sh stop" }
2.创建notify.sh脚本
#!/bin/bash # contact='root@localhost' notify() { mailsubject="$(hostname) to be $1, vip floating" mailbody="$(date +'%F %T'): vrrp transition, $(hostname) changed to be $1" echo "$mailbody" | mail -s "$mailsubject" $contact } case $1 in master) if [ -d "/data" ];then echo "data dir is exists" else mkdir /data fi rbd_device=`lsblk|grep rbd0` if [ $? == "1" ];then rbd map harbor/harbor else echo "rbd map device is exists" fi mount /dev/rbd0 /data docker-compose -f /opt/harbor/docker-compose.yml up ;; backup) for i in nginx harbor-jobservice harbor-ui harbor-adminserver registry harbor-log;do docker rm -f $i;done umount /dev/rbd0 /data ;; stop) for i in nginx harbor-jobservice harbor-ui harbor-adminserver registry harbor-log;do docker rm -f $i;done umount /dev/rbd0 /data ;; *) echo "Usage: $(basename $0) {master|backup}" exit 1 ;; esac
3.修改notify.sh脚本权限
chmod 755 notify.sh chmod +x notify.sh
4.启动keepalived
systemctl enable keepalived systemctl start keepalived
haproxy配置 1.创建haproxy目录
2.创建harbor配置文件
cat >/opt/haproxy/haproxy.cfg <<EOF global log 127.0.0.1 local2 pidfile /var/run/haproxy.pid maxconn 4000 daemon defaults mode http log global option httplog option redispatch retries 3 timeout http-request 10s timeout queue 1m timeout connect 10s timeout client 1m timeout server 1m timeout http-keep-alive 10s timeout check 10s maxconn 3000 listen status bind 192.168.103.134:8888 mode http stats uri / stats realm Global\ statistics listen mariadb bind 192.168.103.134:3306 mode tcp balance roundrobin option tcplog server harbor01 192.168.103.126:3306 check weight 1 maxconn 2000 server harbor02 192.168.103.127:3306 check weight 1 maxconn 2000 listen redis bind 192.168.103.134:6379 mode tcp balance roundrobin option tcplog server harbor01 192.168.103.126:6379 check weight 1 maxconn 2000 server harbor02 192.168.103.127:6379 check weight 1 maxconn 2000 EOF
3.在harbor01、harbor02启动haproxy容器
docker run -d --net host \ -v /opt/haproxy:/usr/local/etc/haproxy \ --restart always \ --name haproxy \ haproxy
mysql高可用 redis+sentinel高可用
使用Dockerfile构建redis镜像
1.创建构建redis需要的目录
2.创建Dockerfile
cat > /tmp/redis/Dockerfile <<EOF FROM redis:5.0.1 COPY redis.conf /usr/local/etc/redis/redis.conf CMD [ "redis-server", "/usr/local/etc/redis/redis.conf" ] EOF
3.下载redis配置文件
wget http://download.redis.io/redis-stable/redis.conf -P /tmp/redis/
4.编辑redis配置文件
bind 0.0.0.0 requirepass 123456
xxxxxxxxxx BOOTROM MENU 1. Boot with default mode 2. Enter serial submenu 3. Enter startup submenu 4. Enter ethernet submenu 5. Enter filesystem submenu 6. Modify BOOTROM password 7. RebootEnter your choice(1-7): 1bash
docker build -t redis:build-1 /tmp/redis/
使用Dockerfile构建sentinel镜像
1.创建sentinel目录
mkdir /tmp/redis-sentinel
2.创建Dockerfile
cat > /tmp/redis-sentinel/Dockerfile <<EOF FROM redis:5.0.1 COPY redis-sentinel.conf /usr/local/etc/redis/redis-sentinel.conf CMD [ "redis-sentinel", "/usr/local/etc/redis/redis-sentinel.conf" ] EOF
3.创建sentinel配置文件
cat > /tmp/redis-sentinel/redis-sentinel.conf <<EOF daemonize no port 26379 dir "/tmp" sentinel monitor harbor01 192.168.100.11 6379 2 sentinel down-after-milliseconds harbor01 60000 sentinel auth-pass harbor01 123456 sentinel config-epoch harbor01 0 sentinel leader-epoch harbor01 0 EOF
4.构建sentinel镜像
docker build -t redis-sentinel:build-1 /tmp/redis-sentinel/
harbor01节点部署
1.创建redis目录
mkdir -p /opt/redis/conf /opt/redis/data
2.创建redis master、sentinel配置文件
cat >/opt/redis/conf/redis-master.conf <<EOF bind 192.168.103.126 port 6379 daemonize no appendonly no appendfsync always requirepass 123456 masterauth 123456 dir /data EOF
cat >/opt/redis/conf/sentinel.conf <<EOF daemonize no port 26379 dir "/tmp" sentinel myid 649e8d8f77590b4e3b1f41ed64678925deafd5da sentinel deny-scripts-reconfig yes sentinel monitor harbor01 192.168.103.126 6379 2 sentinel down-after-milliseconds harbor01 60000 sentinel auth-pass harbor01 123456 # Generated by CONFIG REWRITE sentinel config-epoch harbor01 0 sentinel leader-epoch harbor01 0 sentinel current-epoch 0 EOF
3.harbor01节点启动redis、sentinel容器
docker run -d \ --net host \ --name redis-harbor01 \ --restart=always \ -p 6379:6379 \ -v /opt/redis/conf/redis-master.conf:/usr/local/etc/redis/redis.conf \ -v /data/:/data/ \ redis:build-1
docker run -d \ --net host \ --name redis-sentinel-harbor01 \ --restart=always \ -p 6378:6378 \ -v /opt/redis/conf/sentinel.conf:/usr/local/etc/redis/redis-sentinel.conf \ redis-sentinel:build-1
harbor02节点部署 1.创建redis目录
mkdir -p /opt/redis/conf /opt/redis/data
2.创建redis master、sentinel配置文
cat >/opt/redis/conf/redis-master.conf <<EOF bind 192.168.103.127 port 6379 daemonize no dir /data masterauth 123456 requirepass 123456 #master node IP and port slaveof 192.168.103.126 6379 appendonly no appendfsync always EOF
cat >/opt/redis/conf/sentinel.conf <<EOF daemonize no port 26379 dir "/tmp" sentinel myid 649e8d8f77590b4e3b1f41ed64678925deafd5da sentinel deny-scripts-reconfig yes sentinel monitor harbor01 192.168.103.126 6379 2 sentinel down-after-milliseconds harbor01 60000 sentinel auth-pass harbor02 123456 # Generated by CONFIG REWRITE sentinel config-epoch harbor01 0 sentinel leader-epoch harbor01 0 sentinel current-epoch 0 EOF
3.harbor01节点启动redis、sentinel容器
docker run -d \ --net host \ --name redis-harbor02 \ --restart=always \ -p 6379:6379 \ -v /opt/redis/conf/redis-master.conf:/usr/local/etc/redis/redis.conf \ -v /data/:/data/ \ redis:build-1
docker run -d \ --net host \ --name redis-sentinel-harbor02 \ --restart=always \ -p 6378:6378 \ -v /opt/redis/conf/sentinel.conf:/usr/local/etc/redis/redis-sentinel.conf \ redis-sentinel:build-1
ceph配置 1.创建ceph rbd存储池
ceph osd create pool harbor 32
阅读更多 Centos配置网卡bond 2026-06-10
配置bond0
ens3f0网卡配置
BOOTPROTO=noneNAME=ens3f0DEVICE=ens3f0ONBOOT=yesMASTER=bond0SLAVE=yes
ens3f1网卡配置
BOOTPROTO=noneNAME=ens3f1DEVICE=ens3f1ONBOOT=yesMASTER=bond0SLAVE=yes
bond0网卡配置
BOOTPROTO=noneNAME= ...
阅读更多 基于docker搭建openvpn 2026-06-10
1.初始化openvpn容器,生成证书文件
在本地创建openvpn目录用来存放openvpn配置
阅读更多