docker
有一定的了解docker
中一些应用的安装与自制脚本sudo yum remove docker docker-common docker-selinux docker-engine
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
sudo yum install docker-ce
由于下载容器的速度慢,用网上的加速器
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://123c18fe.m.daocloud.io
yum -y install gcc gcc-c++ openssl-devel zlib-devel pcre-devel bzip2* make libjpeg* libpng* pcre libxml2 libxml2-devel curl curl-devel openssl openssl-devel wget
yum -y install ntp
systemctl startntpd
systemctl enable ntpd
ntpdate -u cn.pool.ntp.org
rm -rf /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
yum install passwd openssl openssh-server -y
ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '' -y
ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' -y
ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N '' -y
/etc/ssh/sshd_config
UseDNS 改为 no UsePrivilegeSeparation 改为 no
"s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
"s/UsePAM.*/UsePAM no/g" /etc/ssh/sshd_config
passwd
set ff=unix
#!/bin/bash
sudo yum remove docker docker-common docker-selinux docker-engine -y
sudo yum install yum-utils device-mapper-persistent-data lvm2 -y
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
sudo yum makecache fast
curl -sSL https://get.daocloud.io/daotools/set_mirror.sh | sh -s http://123c18fe.m.daocloud.io
sudo yum install docker-ce -y
systemctl start docker
docker run -it -d centos
a=$(docker ps | awk '{print $1}' |sed -n '2p')
docker exec -it $a -v /bin/bash
yum -y install gcc gcc-c++ openssl-devel zlib-devel pcre-devel bzip2* make libjpeg* libpng* pcre libxml2 libxml2-devel curl curl-devel openssl openssl-devel wget
yum -y install ntp
systemctl start ntpd
systemctl enable ntpd
ntpdate -u cn.pool.ntp.org
rm -rf /etc/localtime
cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
if [ ! -d "/website" ];
then mkdir website
fi
if [ ! -d "/soft" ];
then mkdir soft
fi
cd /soft
#wget -N --no-check-certificate https://nodejs.org/dist/v8.4.0/node-v8.4.0.tar.gz
wget -N --no-check-certificate http://nginx.org/download/nginx-1.10.1.tar.gz
wget -N --no-check-certificate https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.2.3.tgz
wget -N --no-check-certificate http://jaist.dl.sourceforge.net/project/graphicsmagick/graphicsmagick/1.3.20/GraphicsMagick-1.3.20.tar.gz
wget -N --no-check-certificate http://download.redis.io/releases/redis-4.0.0.tar.gz
tar -vxf GraphicsMagick-*.tar.gz
tar -vxf mongodb-linux-x86_64-3.2.3.tgz
#tar -vxf node-*.tar.gz
tar -vxf redis-*.tar.gz
tar -vxf nginx-*.tar.gz
###install1 nginx
cd /soft/nginx*
./configure --with-http_ssl_module && make && make install
#install node
cd /soft/node*
./configure && make && make install
##install1 GraphicsMagick
cd /soft/GraphicsMagick*
./configure && make && make install
####start nginx
/usr/local/nginx/sbin/nginx
#####radis install
cd /soft/redis*
make PREFIX=/usr/local/redis/ install && make install
cd /usr/local/redis/
mkdir etc logs var db
cp /soft/redis*/redis.conf etc
npm install cnpm -g
cnpm install -g pm2
yum install passwd openssl openssh-server -y
ssh-keygen -q -t rsa -b 2048 -f /etc/ssh/ssh_host_rsa_key -N '' -y
ssh-keygen -q -t ecdsa -f /etc/ssh/ssh_host_ecdsa_key -N '' -y
ssh-keygen -t dsa -f /etc/ssh/ssh_host_ed25519_key -N '' -y
cat >> /etc/ssh/sshd_config << EOF
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_ecdsa_key
HostKey /etc/ssh/ssh_host_ed25519_key
SyslogFacility AUTHPRIV
PermitRootLogin yes
PubkeyAuthentication yes
AuthorizedKeysFile .ssh/authorized_keys
PasswordAuthentication yes
ChallengeResponseAuthentication no
GSSAPIAuthentication no
GSSAPICleanupCredentials no
UsePAM no
X11Forwarding yes
UsePrivilegeSeparation no
UseDNS no
Banner /etc/sshbanner
AcceptEnv LANG LC_CTYPE LC_NUMERIC LC_TIME LC_COLLATE LC_MONETARY LC_MESSAGES
AcceptEnv LC_PAPER LC_NAME LC_ADDRESS LC_TELEPHONE LC_MEASUREMENT
AcceptEnv LC_IDENTIFICATION LC_ALL LANGUAGE
AcceptEnv XMODIFIERS
Subsystem sftp /usr/libexec/openssh/sftp-server
EOF
"s/#UsePrivilegeSeparation.*/UsePrivilegeSeparation no/g" /etc/ssh/sshd_config
"s/UsePAM.*/UsePAM no/g" /etc/ssh/sshd_config
ArrPasswd=( a b c d e A B C D E F @ $ % ^ 0 1 2 3 4 5 6 7 8 9 )
for ((i=0;i<15;i++));
do
pas=${pas[@]}$(echo -n ${ArrPasswd[$RANDOM % ${#ArrPasswd[@]}]})
done
echo $pas | passwd --stdin root
exit
if [ hostname -eq $a ]
then exit
done
## docker image < not capital >
ArrImage=( a b c d e d f g )
for ((i=0;i<6;i++));
do
image=${image[@]}$(echo -n ${ArrImage[$RANDOM % ${#ArrImage[@]}]})
done
echo $image
docker commit $a $image
cd /
if [ ! -d "/soft" ];
then mkdir soft
fi
docker save $image > $image.tar
docker run -it -d --privileged=true --hostname=AtomNuby --name=nuby -v /website:/website -v /date/db:/data/db -p 443:443 -p 80:80 -p 4022:22 -p 8782:8782 -p 8792:8792 -p 8783:8783 -p 8784:8784 -p 8682:8682 -p 8692:8692 -p 8683:8683 -p 8684:8684 -p 50014:50014 -p 4009:3009 -p 7017:27017 -p 9736:6379 $image /usr/sbin/sshd -D
docker exec -it nuby bin/bash
echo "docker password : " $pas
#!/bin/bash
ps axu |grep -v 'grep' |egrep "mongo"|awk '{system("kill -9 "$2)}'
/usr/local/mongodb/bin/mongod --dbpath=/data/db --fork --logpath=/data/db/mongodb.log --storageEngine wiredTiger --journal > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "mongodb无认证启动成功"
else
echo "mongodb无认证启动失败"
fi
sleep 5
ArrUsername=( a b c d e A B C D E F G H J K L Z X C V B N M @ 0 1 2 3 4 5 6 7 8 9 )
for ((i=0;i<5;i++));do
username=${username[*]}$(echo -n ${ArrUsername[$RANDOM % ${#ArrUsername[@]}]})
done
ArrPasswd=( a b c d e A B C D E F @ $ % ^ 0 1 2 3 4 5 6 7 8 9 )
for ((i=0;i<15;i++));do
passwd=${passwd[@]}$(echo -n ${ArrPasswd[$RANDOM % ${#ArrPasswd[@]}]})
done
/usr/local/mongodb/bin/mongo << EOF > /dev/null
use admin
db.createRole({role:'sysadmin',roles:[],privileges:[{resource:{anyResource:true},actions:['anyAction']}]})
db.createUser({user:'$username',pwd:'$passwd',roles:[{role:'sysadmin',db:'admin'}]})
db.shutdownServer();
db.shutdownServer();
exit;
EOF
echo "please login admin to create new B2B/B2C/XXWZ table BY 3T "
ps axu |grep -v 'grep' |egrep "mongo"|awk '{system("kill -9 "$2)}'
#echo "please input username"
/usr/local/mongodb/bin/mongod --auth --dbpath=/data/db --fork --logpath=/data/db/mongodb.log --storageEngine wiredTiger --journal > /dev/null 2>&1
if [ $? -eq 0 ]
then
echo "mongodb认证启动成功"
else
echo "mongodb认证启动失败"
fi
sleep 5
ArrUsername=( a b c d e A B C D E F G H J K L Z X C V B N M @ 0 1 2 3 4 5 6 7 8 9 )
for ((i=0;i<5;i++));do
username2=${username2[*]}$(echo -n ${ArrUsername[$RANDOM % ${#ArrUsername[@]}]})
done
ArrPasswd=( a b c d e A B C D E F @ $ % ^ 0 1 2 3 4 5 6 7 8 9 )
for ((i=0;i<15;i++));do
passwd2=${passwd2[@]}$(echo -n ${ArrPasswd[$RANDOM % ${#ArrPasswd[@]}]})
done
echo "please input dbs name"
read dbs
/usr/local/mongodb/bin/mongo << EOF > /dev/null
use admin
db.auth("$username","$passwd")
use $dbs
db.createUser({user:'$username2',pwd:'$passwd2',roles:[{role:'sysadmin',db:'admin'}]})
exit;
EOF
echo "mongodb超级管理员 : " $username
echo "mongodb超级管密码 : " $passwd
echo "数据库名 " $dbs
echo "用户名 : " $username2
echo "密码 : " $passwd2