8000 m · mgicode/mgicode-k8s-shell@b3ef180 · GitHub
[go: up one dir, main page]

Skip to content

Commit b3ef180

Browse files
committed
m
1 parent 99e9d6d commit b3ef180

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+3585
-8
lines changed

01.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
2+
1、把mgicode-frame 变成几个小的jar
3+
4+
2、gradle 改成 maven
5+
6+
3、调通每个组件
7+
8+
4、生成的改进 插件使用 mgicode 插件,基于该插件生成
9+
10+
5、docker化,使用者直接下载docker即可
11+
12+
6、k8s化
13+
14+
7、vuejs化
15+
16+
8、和前台串起来(reactjs)
17+

04k8s(10.1.12.20-29)/01k8sadmin/01.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,18 @@ EOF
101101
mkdir -p /etc/docker/
102102
cat > /etc/docker/daemon.json << EOF
103103
{
104-
"registry-mirrors": ["http://2f02dbc7.m.daocloud.io", "https://docker.mirrors.ustc.edu.cn", "hub-mirror.c.163.com"],
104+
"registry-mirrors": ["https://ap1xf0lr.mirror.aliyuncs.com","http://2f02dbc7.m.daocloud.io", "https://docker.mirrors.ustc.edu.cn", "hub-mirror.c.163.com"],
105105
"max-concurrent-downloads": 10,
106106
"insecure-registries":["10.1.12.61:5000","10.1.11.60:5000"]
107107
}
108108
EOF
109+
systemctl daemon-reload
110+
systemctl restart docker
109111

110112
cat /etc/docker/daemon.json
111113

112114

115+
113116
cp -rf docker.service /etc/systemd/system/docker.service
114117
sudo systemctl daemon-reload
115118
sudo systemctl stop firewalld

04k8s(10.1.12.20-29)/01k8sadmin/03 env.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,7 @@ export BOOTSTRAP_TOKEN="$BOOTSTRAP_TOKEN"
1313
EOF
1414

1515
cat /etc/profile
16-
17-
1816
cp /etc/profile2 /etc/profile
19-
20-
2117
cp /etc/profile /etc/profile1
2218

2319

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
NODE_IPS="10.1.12.80 10.1.12.81"
2+
NODE_NAME="balance01 balance02 "
3+
4+
####################1、初始化etcd机器,免证登录,改名,改ip并重启####################
5+
6+
chmod 777 /common/ssh.sh
7+
/common/ssh.sh "$NODE_IPS" "$NODE_NAME"
8+
9+
10+
#第一步先做 KeepAlived、HAProxy、consulTemplate
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
2+
NODE_IPS="10.1.12.80 10.1.12.81"
3+
NODE_NAME="balance01 balance02 "
4+
5+
6+
#/usr/sbin/keepalived -P -C -d -D -S 7 -f /etc/keepalived/keepalived.conf
7+
8+
mkdir -p /balanceKeepAlive/
9+
cd /balanceKeepAlive/
10+
cat > /balanceKeepAlive/keepalive.service <<EOF
11+
[Unit]
12+
Description=balanceKeepAlive agent
13+
Requires=network-online.target
14+
After=network-online.target
15+
16+
#
17+
[Service]
18+
Restart=on-failure
19+
#ExecStart=/usr/local/sbin/keepalived -f /etc/keepalived/keepalived.conf
20+
ExecStart=/usr/local/sbin/keepalived -P -C -d -D -S 7 --dont-fork --log-console -f /etc/keepalived/keepalived.conf
21+
#ExecStart=/usr/local/sbin/keepalived -f /etc/keepalived/keepalived.conf --dont-fork --log-console
22+
#ExecStart=/usr/local/sbin/keepalived -P -C -d -D --log-console -f /etc/keepalived/keepalived.conf
23+
24+
25+
ExecReload=/bin/kill -HUP $MAINPID
26+
27+
[Install]
28+
WantedBy=multi-user.target
29+
EOF
30+
31+
echo -e "\033[32m ############### keepalive.service ########### \033[0m"
32+
cat /balanceKeepAlive/keepalive.service
33+
echo -e "\033[32m ###########内容显示完成########### \033[0m"
34+
35+
sleep 5
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# author:pengrk
2+
# email:546711211@qq.com
3+
# qq group:573283836
4+
5+
NODE_IPS="10.1.12.80 10.1.12.81"
6+
NODE_NAME="balance01 balance02 "
7+
8+
KEEPALIVE_MASTER_IP="10.1.12.80"
9+
KEEPALIVE_VIP="10.1.12.90"
10+
ETH_NAME="ens160" #eth0
11+
12+
# iptables -I INPUT -i eth0 -d 224.0.0.0/8 -p vrrp -j ACCEPT
13+
# iptables -I OUTPUT -o eth0 -d 224.0.0.0/8 -p vrrp -j ACCEPT
14+
# service iptables save
15+
16+
cd /balanceKeepAlive/
17+
18+
KEEPALIVE_STATE=""
19+
KEEPALIVE_PRIORITY=""
20+
nopreempt=""
21+
function calSlaveConf()
22+
{
23+
if [ ${KEEPALIVE_MASTER_IP} = $1 ]; then
24+
KEEPALIVE_STATE="MASTER"
25+
KEEPALIVE_PRIORITY="150"
26+
nopreempt=""
27+
else
28+
KEEPALIVE_STATE="BACKUP"
29+
KEEPALIVE_PRIORITY="100"
30+
nopreempt="nopreempt"
31+
fi
32+
return 1
33+
}
34+
35+
36+
37+
for ip in $NODE_IPS ;do
38+
39+
calSlaveConf "$ip"
40+
cat > /balanceKeepAlive/keepAliveConfig${ip##*.} <<EOF
41+
global_defs {
42+
router_id Haproxy${ip##*.}  #当前节点名
43+
}
44+
vrrp_script chk_haproxy {
45+
script "killall -0 haproxy"
46+
interval 2
47+
weight 2
48+
}
49+
vrrp_instance VI_1 {
50+
state ${KEEPALIVE_STATE} #指定Haproxy节点为主节点 备用节点上设置为BACKUP即可
51+
interface ${ETH_NAME} #绑定虚拟IP的网络接口
52+
virtual_router_id 51 #VRRP组名,两个节点的设置必须一样,以指明各个节点属于同一VRRP组
53+
priority ${KEEPALIVE_PRIORITY} #主节点的优先级(1-254之间),备用节点必须比主节点优先级低
54+
${nopreempt}
55+
advert_int 1 #组播信息发送间隔,两个节点设置必须一样
56+
virtual_ipaddress { #指定虚拟IP, 两个节点设置必须一样,可以多个
57+
${KEEPALIVE_VIP}
58+
}
59+
}
60+
61+
track_script {
62+
chk_haproxy
63+
}
64+
65+
EOF
66+
67+
echo -e "\033[32m ###############/balanceKeepAlive/keepAliveConfig${ip##*.} ########### \033[0m"
68+
cat /balanceKeepAlive/keepAliveConfig${ip##*.}
69+
echo -e "\033[32m ###########内容显示完成########### \033[0m"
70+
71+
sleep 5
72+
73+
done;
74+
75+
76+
# vrrp_script chk_haproxy {
77+
# script "killall -0 haproxy"
78+
# interval 2
79+
# weight 2
80+
# }
81+
# vrrp_instance VI_1 {
82+
# interface ens160
83+
# state MASTER
84+
# virtual_router_id 27
85+
# priority 101 # 101 on master, 100 on backup (Make sure to change this on HAPROXY node2)
86+
# virtual_ipaddress {
87+
# ${VIP} # the virtual IP's
88+
# }
89+
# track_script {
90+
# chk_haproxy
91+
# }
92+
# }
93+
94+
95+
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# author:pengrk
2+
# email:546711211@qq.com
3+
# qq group:573283836
4+
5+
# wget wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-3.4.4.tgz
6+
7+
8+
#/usr/local/bin/redis-cli
9+
10+
#3.3 创建安装的shell
11+
cat > /balanceKeepAlive/install-client.sh <<EOF
12+
13+
#echo " export PATH=/usr/local/bin:\$PATH " >> /etc/profile
14+
#source /etc/profile
15+
16+
mkdir -p /balanceKeepAliveWorking/
17+
cd /balanceKeepAliveWorking/
18+
19+
yum -y install gcc openssl-devel libyaml-devel libffi-dev
20+
yum -y install gcc automake autoconf libtool make wget
21+
yum -y install libnl3-devel ipset-devel iptables-devel libnfnetlink-devel net-snmp-devel
22+
#wget wget http://www.keepalived.org/software/keepalived-1.3.9.tar.gz
23+
wget http://${FILE_SERVER_IP}/keepalived-1.3.9.tar.gz
24+
tar xzvf keepalived-1.3.9.tar.gz
25+
26+
#make MALLOC=libc
27+
cd keepalived-1.3.9/&&./configure&& make MALLOC=libc && make install
28+
29+
echo -e "\033[32m ###############/usr/local/sbin至少包括keepalived文件########### \033[0m"
30+
ls /usr/sbin/keepalived
31+
ls /etc/keepalived/keepalived.conf
32+
echo -e "\033[32m ###########内容显示完成########### \033[0m"
33+
34+
#keepalive
35+
mkdir -p /usr/local/etc/keepalived/
36+
cp /etc/keepalived/keepalived.conf /usr/local/etc/keepalived/keepalived.conf
37+
38+
#VRRP协议也需要设置防火墙,需要和ip相类似
39+
#-d 10.0.0.0/8 ,ens160 需要修改############
40+
#****************important****************########
41+
#iptables -I INPUT -i ens160 -d 10.0.0.0/8 -p vrrp -j ACCEPT
42+
#iptables -I OUTPUT -o ens160 -d 10.0.0.0/8 -p vrrp -j ACCEPT
43+
#iptables-save >/etc/iptables-script
44+
#echo '/sbin/iptables-restore /etc/iptables-script' >>/etc/rc.d/rc.local
45+
46+
sysctl -w net.ipv6.conf.eth0.accept_dad=0
47+
48+
#chkconfig --add keepalived
49+
#chkconfig --level 12345 keepalived on
50+
51+
systemctl daemon-reload
52+
systemctl enable keepalive
53+
systemctl start keepalive
54+
systemctl status keepalive
55+
56+
sleep 3
57+
58+
EOF
59+
60+
echo -e "\033[32m ############### /balanceKeepAlive/install-client.sh ########### \033[0m"
61+
cat /balanceKeepAlive/install-client.sh
62+
echo -e "\033[32m ###########内容显示完成########### \033[0m"
63+
64+
sleep 2;
65+
66+
67+
68+
# iptables的配置文件保存在/etc/sysconfig/iptables-config下,书写了iptables规则以后如果需要保存规则,则可以使用命令:iptables-save,使用此命令保存的规则位置可以是任意的,此时保存的规则在重启机器后无法自动生效,需要使用命令iptables-restore恢复,或者写入开机启动脚本/etc/rc.d/rc.local里面。
69+
# 以下为教材里使用的命令:
70+
# 保存规则:#iptables-save >/etc/iptables-script
71+
# 恢复规则:#iptables-restore>/etc/iptables-script
72+
# 保存和恢复的位置只要是两者一致就可以了,如果iptables-script没有则需要创建。
73+
# 若想开机自动启用脚本,则可以使用以下命令放到系统初始化Shell脚本/etc/rc.d/rc.local中
74+
# #echo '/sbin/iptables-restore /etc/iptables-script' >>/etc/rc.d/rc.local
75+
# 但近日查看一些资料,发现规则保存的位置在/etc/sysconfig/iptables下,所以一些资料就有了
76+
# 保存规则:#iptables-save >/etc/sysconfig/iptables
77+
# 恢复规则:#iptables-restore>/etc/sysconfig/iptables
78+
# 若想开机自动启用脚本,则可以使用以下命令放到系统初始化Shell脚本/etc/rc.d/rc.local中
79+
# #echo '/sbin/iptables-restore /etc/sysconfig/iptables' >>/etc/rc.d/rc.local
80+
# 此外还有一命令保存规则 #service iptables save,如下图:
81+
# 规则自动保存到了/etc/sysconfig/iptables,用此命令保存的规则开机会自动生效,所以为了统一期间,建议以后规则的保存都保存在/etc/sysconfig/iptables下。
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# author:pengrk
2+
# email:546711211@qq.com
3+
# qq group:573283836
4+
5+
NODE_IPS="10.1.12.80 10.1.12.81"
6+
NODE_NAME="balance01 balance02 "
7+
8+
#t重新运行,需要生成CONSUL_KEY_TOKEN
9+
clearScript="
10+
systemctl stop keepalive;
11+
systemctl disable keepalive;
12+
13+
rm -rf /etc/systemd/system/keepalive.service
14+
15+
rm -rf /balanceKeepAliveWorking/;
16+
rm -rf /usr/local/sbin/keepalived;
17+
rm -rf /usr/local/etc/keepalived/;
18+
rm -rf /etc/keepalived/keepalived.conf
19+
20+
"
21+
22+
checkScript="
23+
echo -e \"\033[32m #######/balanceKeepAlive/install-client.sh ####### \033[0m\"
24+
ls /balanceKeepAlive/install-client.sh
25+
echo -e \"\033[32m ###############内容显示完成########### \033[0m\"
26+
27+
echo -e \"\033[32m ######## /etc/systemd/system/keepalive.service ###### \033[0m\"
28+
ls /etc/systemd/system/keepalive.service
29+
echo -e \"\033[32m ###############内容显示完成########### \033[0m\"
30+
31+
echo -e \"\033[32m ##########/etc/keepalived/keepalived.conf ######## \033[0m\"
32+
ls /etc/keepalived/keepalived.conf
33+
cat /etc/keepalived/keepalived.conf
34+
echo -e \"\033[32m ###############内容显示完成########### \033[0m\"
35+
"
36+
37+
#3.3 安装keepalive
38+
for ip in $NODE_IPS ;do
39+
echo "清除$ip中的keepalive安装的所有内容..."
40+
ssh root@$ip "$clearScript"
41+
42+
echo "安装$ip的keepalive..."
43+
ssh root@$ip "mkdir -p /balanceKeepAliveWorking/; mkdir -p /etc/keepalived/;"
44+
45+
scp /balanceKeepAlive/keepAliveConfig${ip##*.} root@$ip:/etc/keepalived/keepalived.conf
46+
scp /balanceKeepAlive/keepalive.service root@$ip:/etc/systemd/system/keepalive.service
47+
scp /balanceKeepAlive/install-client.sh root@$ip:/balanceKeepAliveWorking/install-client.sh
48+
ssh root@$ip "chmod 777 /balanceKeepAliveWorking/install-client.sh; /balanceKeepAliveWorking/install-client.sh;"
49+
50+
ssh root@$ip "$checkScript"
51+
sleep 5
52+
53+
done
54+
55+
56+
sleep 20
57+
58+
for ip in $NODE_IPS ;do
59+
echo "查看状态..."
60+
ssh root@$ip "ip addr ; "
61+
#查看日志
62+
ssh root@$ip "cat /var/log/messages ; "
63+
64+
sleep 5
65+
done
66+
67+
68+
69+
70+
71+
72+
73+
#stop a, look the b has the vip
74+
#stop b start a look the a has the vip
75+
76+
# ps -ef
77+
78+
#/usr/local/sbin/keepalived -D
79+
80+
81+
82+

0 commit comments

Comments
 (0)
0