运维工作中经常用到的一些知识总结
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了运维工作中经常用到的一些知识总结相关的知识,希望对你有一定的参考价值。
接上篇:
http://blog.51cto.com/bobo365/2125138
48、容器导出导入:
docker import 容器ID > xxx.tar
cat xxx.tar | docker import - xxx:v1.0
镜像导出导入:
docker save xxx:v1.0 > yyyy.tar.gz
docker load < yyyy.tar.gz
49、docker
卸载:
yum remove docker docker-common docker-selinux docker-engine
安装依赖:
yum -y install yum-utils device-mapper-persistent-data lvm2
设置源:
yum-config-manager --add-repo https://mirrors.ustc.edu.cn/docker-ce/linux/centos/docker-ce.repo
安装:
yum makecache fast
yum -y install docker-ce
docker-enter:
.bashrc_docker
#Some useful commands to use docker.
#Author: [email protected]
#Created:2014-09-25
alias docker-pid="sudo docker inspect --format ‘{{.State.Pid}}‘"
alias docker-ip="sudo docker inspect --format ‘{{ .NetworkSettings.IPAddress }}‘"
#the implementation refs from https://github.com/jpetazzo/nsenter/blob/master/docker-enter
function docker-enter() {
#if [ -e $(dirname "$0")/nsenter ]; then
#Change for centos bash running
if [ -e $(dirname ‘$0‘)/nsenter ]; then
# with boot2docker, nsenter is not in the PATH but it is in the same folder
NSENTER=$(dirname "$0")/nsenter
else
# if nsenter has already been installed with path notified, here will be clarified
NSENTER=$(which nsenter)
#NSENTER=nsenter
fi
[ -z "$NSENTER" ] && echo "WARN Cannot find nsenter" && return
if [ -z "$1" ]; then
echo "Usage: `basename "$0"` CONTAINER [COMMAND [ARG]...]"
echo ""
echo "Enters the Docker CONTAINER and executes the specified COMMAND."
echo "If COMMAND is not specified, runs an interactive shell in CONTAINER."
else
PID=$(sudo docker inspect --format "{{.State.Pid}}" "$1")
if [ -z "$PID" ]; then
echo "WARN Cannot find the given container"
return
fi
shift
OPTS="--target $PID --mount --uts --ipc --net --pid"
if [ -z "$1" ]; then
# No command given.
# Use su to clear all host environment variables except for TERM,
# initialize the environment variables HOME, SHELL, USER, LOGNAME, PATH,
# and start a login shell.
#sudo $NSENTER "$OPTS" su - root
sudo $NSENTER --target $PID --mount --uts --ipc --net --pid su - root
else
# Use env to clear all host environment variables.
sudo $NSENTER --target $PID --mount --uts --ipc --net --pid env -i [email protected]
fi
fi
}
echo "[ -f ~/.bashrc_docker ] && . ~/.bashrc_docker " >> ~/.bashrc; source ~/.bashrc
50、tomcat启动非常慢,要花5~6分钟
http://blog.csdn.net/sxhong/article/details/62889003
有两种解决办法:
1)在Tomcat环境中解决
可以通过配置JRE使用非阻塞的Entropy Source。
在catalina.sh中加入这么一行:-Djava.security.egd=file:/dev/./urandom 即可。
加入后再启动Tomcat,整个启动耗时下降到Server startup in 2912 ms。
2)在JVM环境中解决
打开$JAVA_PATH/jre/lib/security/java.security这个文件,找到下面的内容:
securerandom.source=file:/dev/urandom
替换成
securerandom.source=file:/dev/./urandom
51、定时释放mem脚本
[[email protected] script]# vim freemem.sh
#!/bin/bash
used=`free -m | awk ‘NR==2‘ | awk ‘{print $3}‘`
free=`free -m | awk ‘NR==2‘ | awk ‘{print $4}‘`
echo "===========================" >> /var/log/mem.log
date >> /var/log/mem.log
echo "Memory usage | [Use:${used}MB][Free:${free}MB]" >> /var/log/mem.log
if [ $free -le 6350 ] ; then
sync && echo 1 > /proc/sys/vm/drop_caches
sync && echo 2 > /proc/sys/vm/drop_caches
sync && echo 3 > /proc/sys/vm/drop_caches
echo "bobo365" >> /var/log/mem.log
else
echo "Not required" >> /var/log/mem.log
fi
*/30 * * * * /bin/bash /home/script/freemem.sh &>/dev/null
52、activemq
http://blog.csdn.net/xiaoxing598/article/details/51604999
http://activemq.apache.org/activemq-5153-release.html
tar xf xxx -C /usr/local
cd /usr/local/xxx/bin
./activemq start
vim conf/jetty-realm.properties
#将里面的内容清空,重新添加一行
admin: Admin!123, admin
vim conf/jetty.xml
#修改第30行变成如下
<property name="roles" value="admin" />
vim conf/activemq.xml
保留openwire stomp
53、MFS
curl "http://ppa.moosefs.com/RPM-GPG-KEY-MooseFS" > /etc/pki/rpm-gpg/RPM-GPG-KEY-MooseFS
curl "http://ppa.moosefs.com/MooseFS-3-el7.repo" > /etc/yum.repos.d/MooseFS.repo
yum install moosefs-master moosefs-cgi moosefs-cgiserv moosefs-cli
yum install moosefs-chunkserver
yum install moosefs-metalogger
yum install moosefs-client
cd /etc/mfs/
[[email protected] mfs]# egrep -v "#|^$" mfsexports.cfg
10.150.27.0/24 / rw,alldirs,mapall=mfs:mfs,password=111111
* . rw
[[email protected] mfs]# egrep -v "#|^$" mfshdd.cfg
/mfsdata
[[email protected] mfs]# egrep -v "#|^$" mfsmetalogger.cfg
ASTER_HOST = 10.150.27.113
MASTER_PORT = 9419
[[email protected] mfs]# egrep -v "#|^$" mfschunkserver.cfg
MASTER_HOST = mfsmaster
MASTER_PORT = 9420
AUTH_CODE = 111111
mkdir /mfsdata
chown -R mfs.mfs /mfsdata/
客户端:
mkdir /mnt/mfs
chown -R mfs.mfs /mnt/mfs/
mfsmount /mnt/mfs -H 10.150.27.113 -o mfspassword=111111
[[email protected] mfs]# more /etc/hosts
10.150.27.113 bobo365 mfsmaster
http://10.150.27.113:9425
1、启动master
2、启动所有chunkserver
3、启动metalogger
4、挂载客户端
停止反序。
systemctl start moosefs-master.service
systemctl start moosefs-chunkserver.service
systemctl start moosefs-cgiserv.service
systemctl start moosefs-metalogger.service
systemctl status moosefs-master.service
systemctl status moosefs-chunkserver.service
systemctl status moosefs-cgiserv.service
systemctl status moosefs-metalogger.service
systemctl enable moosefs-master.service
systemctl enable moosefs-chunkserver.service
systemctl enable moosefs-cgiserv.service
systemctl enable moosefs-metalogger.service
more /etc/rc.local
mfsmount /mnt/mfs -H 10.150.27.113 -o mfspassword=111111
以上是关于运维工作中经常用到的一些知识总结的主要内容,如果未能解决你的问题,请参考以下文章