使用Docker遇到的问题

使用Docker遇到的问题

  1. **Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? **

    重新配置daemon,并重启docker

    1
    2
    systemctl daemon-reload
    systemctl restart docker.service
  2. ES运行内存不足

    1
    2
    3
    4
    5
    6
    7
    8
    9
    # 登陆docker容器进行修改
    docker exec -it 容器名 /bin/bash
    cd ../etc/elasticsearch
    vim jvm.options

    # jvm.options
    # 修改-Xms和-Xmx
    -Xms128m
    -Xmx128m
  3. 查看logs

    1
    docker container logs 容器名
  4. 在容器出现错误时修改内部文件的办法

    1
    2
    3
    4
    #找到docker容器的文件路径
    find / -name 出现错误的文件名
    #进入并修改文件
    vim 文件路径

Shell 数组

Shell 数组

1
2
3
4
5
6
7
8
9
10
11
#!/bin/bash

soft = (
nginx-1.6.1.tar.gz
mysql-5.1.17.tar.gz
php-5.3.3.tar.gz
/etc/sysctl.conf
)
echo "tHIS SOFT TOTAL ${#soft[@]} !"
tar -xzf ${soft[0]} ;cd nginx-1.6.1 ;./configure ;make install

自动化运维

自动化运维

1. 自动禁止恶意IP访问

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
# 从访问记录log里获取恶意ip访问信息

SEC_FILE=/var/log/secure
# 筛选恶意访问(密码错误多次[>=4次])多次的ip
IP_ADDR=`tail -n 1000 $SEC_FILE | grep "Failed password" | egrep -o "([0-9]{1,3}\.){3}[0-9]{1,3}" | sort -nr | uniq -c | awk ' $1>=4 {print $2}'`
IPTABLE_CONF=/etc/sysconfig/iptables
echo
cat <<EOF
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
---------------------welcome to use ssh login drop failed ip------------------
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
EOF
for i in `echo $IP_ADDR`
do
# 抓取防火墙中对应的ip信息
cat $IPTABLE_CONF | grep $i >/dev/null

# 判断是否已经存在对应ip的拒绝信息, 如存在, 就不添加相应信息
if [ $? -ne 0];then
sed -i "/lo/a -A INPUT -s $i -m state --state NEW -m tcp -p tcp --dropt 22 -j DROP" $IPTABLE_CONF
else
echo "This $i is exists in the iptables."
fi
done

/etc/init.d/iptables restart

2.网络自动化部署以及管理

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/bin/bash
# Auto change Server Files


# 缺少ip.txt
if [ ! -f ip.txt ];then
echo "Please Create ip.txt Files, the ip.txt contents models are as follows: "
cat <<EOF
192.168.149.128
192.168.149.129
EOF
exit
fi
# 缺少参数
if [ -z "$1" ];then
echo "Usage: $0 command, example{Src_Files|Src_Dir Des_dir}. "
exit
fi
# 抓去ip.txt的行数
count='cat ip.txt | wc -l'
rm -rf ip.txt.swp
i=0
while ((i< $count))
do
i=`expr $i + 1`
# 抓去ip.txt的第$i行的ip并赋予至ip.txt.swp
sed "${i}s/^/&${i} /g" ip.txt >>ip.txt.swp
# 获取需要同步的ip
IP=`awk -v I="$i" '{if(I==$1)print $2}' ip.txt.swp`
# 同步语句
scp -r $1 root@${IP}:$2

done

3.批量远程服务器执行命令

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

if [ ! -f ip.txt ];then
echo "Please Create ip.txt Files, the ip.txt contents models are as follows: "
cat <<EOF
192.168.149.128
192.168.149.129
EOF
exit
fi

if [ -z "$*" ];then
echo "Usage: $0 command, example {rm /tmp/test.txt | mkdir /tmp/20140228}"
exit
fi

count='cat ip.txt | wc -l'
rm -rf ip.txt.swp
i=0
while ((i< $count))
do
i=`expr $i + 1`
# 抓去ip.txt的第$i行的ip并赋予至ip.txt.swp
sed "${i}s/^/&${i} /g" ip.txt >>ip.txt.swp
# 获取需要同步的ip
IP=`awk -v I="$i" '{if(I==$1)print $2}' ip.txt.swp`
# 命令语句, 并输出操作返回结果
ssh -q -l root $IP "$*";echo "The $IP Execution Command: $* succeed";sleep 2"
done

4.Rsync+SSH批量自动化部署

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/bin/bash

# 刷新函数
flush(){
if [ ! -f rsync.list ];then
echo "Please Create rsync.list Files, the rsync.list contents should be look like as follow:"
cat <<EOF
192.168.149.128 src_dir des_dir
192.168.149.127 src_dir des_dir
EOF
exit
fi

rm -rf rsync.list.swp ; cat rsync.list | grep -v "#" >rsync.list.swp
COUNT=`cat rsync.list.swp | wc -l`
i=0
while ((${i} < $COUNT))
do
i = `expr $i + 1`
Line=`sed -n "${i}p" rsync.list.swp`
IP=`echo $Line | awk '{print $1}'`
SRC=`echo $Line | awk '{print $2}'`
DES=`echo $Line | awk '{print $3}'`
rsync -ap --delete ${SRC}/ root@${IP}:${DES}/
done
}

# 重启
restart(){
if [ ! -f restart.list ];then
echo "Please Create restart.list Files, the rsync.list contents should be look like as follow:"
cat <<EOF
192.168.149.128 Command
192.168.149.127 Command
EOF
exit
fi
rm -rf restart.list.swp ; cat restart.list | grep -v "#" >>restart.list.swp
COUNT=`cat restart.list.swp | wc -l`
i=0
while ((${i} < $COUNT))
do
i = `expr $i + 1`
Line=`sed -n "${i}p" restart.list.swp`
IP=`echo $Line | awk '{print $1}'`
Command=`echo $Line | awk '{print $2}'`
ssh -l root $IP "sh $Command;echo 'The $IP Exec Command and : sh $Command success'"
done
}

case $i in
flush )
flush
;;
restart )
restart
;;
*)
echo "Usage: $0 command, example{flush|restart}"

4.增量备份脚本

  • 完整备份

    完整的将文件全部备份

    tar -g /tmp/snapshot -czvf /tmp/2014_full_system_data.tar.gz /data/sh/

  • 增量备份

    将新增的文件进行备份

    tar -g /tmp/snapshot -czvf /tmp/2014_add01_system_data.tar.gz /data/sh/

一般是周日进行完整备份,每天进行一次增量备份

定时备份:

1
确定今天是周几: date +%u
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/bash

# 所有文件
SOURCE_DIR=(
$*
)

TARGET_DIR=/data/backup/

YEAR=`date +%Y`
MONTH=`date +%m`
DAY=`date +%d`
WEEK=`date +%u`
A_NAME=`date +%H%M`
FILES=${A_NAME}_system_backup.tgz
CODE=$?

if [ -z "$*" ];then
echo "Please Enter Your Backup Files or Directories"
echo "Usage: { $0 /boot /etc }"
exit
fi

if [ ! -d $TARGET_DIR/$YEAR/$MONTH/$DAY ];then
mkdir -p $TARGET_DIR/$YEAR/$MONTH/$DAY
echo "The $TARGET_DIR Created success"
fi
Full_Backup(){
if [ "$WEEK" -eq "7" ];then
rm -rf $TARGET_DIR/snapshot
cd $TARGET_DIR/$YEAR/$MONTH/$DAY ;tar -g $TARGET_DIR/snapshot -czvf $FILES ${SOURCE_DIR[@]}
[ "$CODE" == "0" ]&&echo "These Full_backup System Files $TARGET_DIR/$YEAR/$MONTH/$DAY/$FILES Backup Success"
fi
}
Add_Backup(){
if [ "$WEEK" -ne "7" ];then
cd $TARGET_DIR/$YEAR/$MONTH/$DAY ;tar -g $TARGET_DIR/snapshot -czvf $FILES ${SOURCE_DIR[@]}
[ "$CODE" == "0" ]&&echo "These Add_backup System Files $TARGET_DIR/$YEAR/$MONTH/$DAY/$FILES Backup Success"
fi
}
sleep 3
Full_Backup;Add_Backup

Change-To-Chinese

简单的网站测试

测试测试测试

中译英重要单词

中译英重要单词

词性
装饰品 n. ornament
绳结 n. knot
人类社会学 n. anthropology
合适的 adj. appropriate
狡猾 n. cunning
诱惑力 n. glamour
诱惑 v. tempt
干扰,打断 v. intervene;
然而 conj. whereas
官僚主义 n. bureaucracy
自尊心 n. ego
初步的 adj. preliminary
律师 n. lawyer; counsel;
曲解 v. distort
赞同 v. endorse; approve;
争吵 v. dispute;
谬论 n. fallacy
嘲笑,轻蔑 v. tease; comtempt
尽管 prep. although; though; despite; in spite of;
似乎说得过去的 adj. plausible
伤亡人数 n. casualty; toll;
往返航班 n. shuttle
主张 v. argue;
死亡 v. perish; die;
草图 n. draft;
意识到;理解 v. perceive
猜测 v. speculate

倾诉欲

倾诉欲

每个人都会有困难的时候。

有些困难看似不起眼,可它永远垒在那里,无时无刻不想着拌你一脚,你一时觉得无所谓,也许搬个铲子动土的时间,不如拿来赚更多的钱。

可真当它动起火来,真将你绊倒在地的时候,你哗啦地翻下山坡,卷起后面一片沙尘,摔得你鼻青脸肿,随后再在山顶上瞧着你,嘲笑你还得上来。

或者你觉得它太过危险,你注意到了后面的险山峻岭。可你此时此刻再无多余的心思去顾虑它,你双手抱住了一摞顶天的,不管是什么东西,背上背了沉重的背包,小腿以下甚至已经敷满了皑皑白雪。可你知道你迟早会遇到那颗扎根在泥土里的尖石头。

你过分焦虑,你知道它越来越近,你知道它注定要扳倒你。你想尽办法躲开,也许是向左走一点,也许是向右多偏离一些,尽管可能高山上的暴风最终将让你迷失方向。

突然你胸口挂着的通讯器的杂声消失了,那边传来了轻声呼吸,和一声问候。

或许会让她顿时害怕,或许会让她马上调整新的频道,或许她会嫌弃你,或许她会说你无趣。你想过所有的可能,可你也憋不住了,你还是要向她倾诉,你说你马上就要迈过去了,可害怕又失败了。你说那个脑袋拔尖儿的玩意儿真不是个东西。

她的一声轻笑,一声逗趣儿般的若怪你太榆木脑袋般的“笨蛋”,再轻轻地缓和呼吸。

可她仍然再继续好奇,问你怎么还能被一小颗石头难倒了,想你翻过山之后能看到怎样的美景。突然觉得那个石头好像只是刚刚冒头的春笋,只是想向你打个招呼,想呼吸呼吸新鲜空气。突然觉得背着的哪里是背包,明明是背着那个不扭头就见不着模样,却散着清香,靠着耳边说着悄悄话,还有呼吸声,还有那轻轻的笑的女孩儿。脚边的雪一下子就化了,化成了拂过万千花丛的微风。手上抱着的,也是给她精心准备的什么礼物。

你一直说,一口气将群山的蜿蜒曲折说给她听,一口气再将山脚的茂密树林和可爱鸟兽、和山腰转角的几支说不出名字的花和丛跟她描述的明明白白的。

直到你真的攀上山顶,你意识到那边的她早就听的迷迷糊糊了,好像梦到了就站在你身边,看到了山后的风景。

也许是海,也许是青葱绿林,也许是戈壁滩,也许是沙漠古迹,再或许,还是群山。

可你意识到了,山后是什么,不重要。

重要的是有人听着,一直听着。


"说爱你的平铺直叙法"


Diary

Diary 2020-02-02

​ 好多父母甚至根本不知道如何教育孩子,他们只是凭着一个身份和嘴上的爱,以及自私和懒惰在教育孩子。

​ 他们期望他们可以不需要再付出就可以获得孩子的一切,获得孩子的收入养活自己,获得孩子的身份展开话题,获得孩子的自尊满足自己的虚荣。

​ 他们大张旗鼓的夺走了孩子的灵魂。

​ 孩子甚至还没有意识到。

​ 就变成了父母的一条狗。

First-Post

第一次发布博客

​ Hello World!

​ Hello this blog of mine!

​ This is the first time trying to post a new blog, and I have no idea what to say.

​ But I just can’t wait to do something in it.

​ I know I forget it a long time, and throw it to a corner even forget it.

​ Here is what I have to say, it’s too easy for me to post a blog without money, VIP or anything else. Programmer can do anything by himself!


​ Here is the main sector of what I have to describe.

​ The site of my blog contains all of writing which I love or want to remember or just eager to write down.

​ It will include such as a diary, a span conclusion, and a little technology sharing.

​ Hope I can remember to write all down.

​ Hope you could find anything you like or approve! Thanks!

​ Anyway, good night, every one!