当前位置:网站首页>虚拟机初始化脚本, 虚拟机相互免秘钥
虚拟机初始化脚本, 虚拟机相互免秘钥
2022-07-02 17:54:00 【向上的狼】
一、虚拟机初始化脚本
#!/bin/bash
## -bash: ./lucky.sh: /bin/bash^M: bad interpreter: No such file or directory
## vim或者vi的命令模式下,输入命令 set fileformat=unix 即可解决换行问题
echo -e "\e[1;31m【----------------------------------------在opt和var创建lucky文件夹】\e[0m"
sleep5
mkdir -p /opt/lucky
mkdir -p /var/lucky
mkdir -p /usr/local/script
echo -e "\e[1;31m【----------------------------------------禁用防火墙】\e[0m"
sleep 5
systemctl stop firewalld
systemctl disable firewalld
systemctl status firewalld
echo -e "\e[1;32m【----------------------------------------修改selinux】\e[0m"
sleep 5
sed -i '/^SELINUX=/c SELINUX=disabled' /etc/selinux/config
echo -e "\e[1;32m【----------------------------------------安装wget】\e[0m"
sleep 5
yum install wget -y
echo -e "\e[1;33m【----------------------------------------修改yum源】\e[0m"
sleep 5
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-
7.repo
yum clean all
yum makecache
echo -e "\e[1;33m【----------------------------------------安装常用软件】\e[0m"
yum install man man-pages ntp vim lrzsz zip unzip telnet perl net-tools -y
echo -e "\e[1;34m【----------------------------------------同步系统时间】\e[0m"
yum info ntp && ntpdate cn.ntp.org.cn
echo -e "\e[1;34m【----------------------------------------DNS域名配置】\e[0m"
sleep 5
echo "192.168.58.100 basenode" >> /etc/hosts
echo "192.168.58.161 bd1601" >> /etc/hosts
echo "192.168.58.162 bd1602" >> /etc/hosts
echo "192.168.58.163 bd1603" >> /etc/hosts
echo -e "\e[1;34m【----------------------------------------安装JDK】\e[0m"
sleep 5
rpm -ivh jdk-8u231-linux-x64.rpm
echo 'export JAVA_HOME=/usr/java/jdk1.8.0_231-amd64' >> /etc/profile
echo 'export PATH=$JAVA_HOME/bin:$PATH' >> /etc/profile
source /etc/profile
echo -e "\e[1;35m【----------------------------------------安装Tomcat】\e[0m"
sleep 5
tar -zxf apache-tomcat-8.5.47.tar.gz
mv apache-tomcat-8.5.47 /opt/lucky/
echo -e "\e[1;35m【----------------------------------------安装Mysql】\e[0m"
sleep 5
rpm -e --nodeps `rpm -qa | grep mariadb`
tar -xvf mysql-5.7.28-1.el7.x86_64.rpm-bundle.tar
rpm -ivh mysql-community-common-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-libs-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-client-5.7.28-1.el7.x86_64.rpm
rpm -ivh mysql-community-server-5.7.28-1.el7.x86_64.rpm
systemctl start mysqld
systemctl enable mysqld
temppasswd=`grep "A temporary password" /var/log/mysqld.log | awk '{ print
$NF}'`
mysql -uroot -p$temppasswd --connect-expired-password << EOF
set global validate_password_policy=low;
set global validate_password_length=6;
alter user [email protected] identified by '123456';
use mysql;
update user set host='%' where user = 'root';
commit;
quit
EOF
systemctl restart mysqld
echo -e "\e[1;35m【----------------------------------------安装Nginx】\e[0m"
sleep 5
echo -e "\e[1;36m【----------------------------------------设置开机启动项】\e[0m"
sleep 5
touch /usr/local/script/auto_ntpdate.sh
echo '#!/bin/bash' >> /usr/local/script/auto_ntpdate.sh
echo 'yum info ntp && ntpdate cn.ntp.org.cn' >>
/usr/local/script/auto_ntpdate.sh
chmod u+x /usr/local/script/auto_ntpdate.sh
echo '/usr/local/script/auto_ntpdate.sh' >> /etc/rc.local
chmod u+x /etc/rc.local
echo -e "\e[1;36m【----------------------------------------删除文件】\e[0m"
sleep 5
rm -rf apache-tomcat-8.5.47.tar.gz
rm -rf jdk-8u231-linux-x64.rpm
rm -rf mysql*
rm -rf *.sh
echo -e "\e[1;36m【----------------------------------------关闭计算器,拍快照】
\e[0m"
sleep 5
shutdown -h now二、虚拟机相互免秘钥
##三台主机分别生成秘钥
【123】ssh-keygen -t rsa -P '' -f ~/.ssh/id_rsa
##host验证
【123】vim /etc/ssh/ssh_config 在最后添加
StrictHostKeyChecking no
UserKnownHostsFile /dev/null
##将秘钥分别拷贝给自己和别人
【123】ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
【123】ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
【123】ssh-copy-id -i ~/.ssh/id_rsa.pub [email protected]
123456
##关闭主机拍摄快照
power off边栏推荐
- 【JVM调优实战100例】01——JVM的介绍与程序计数器
- 从list转化成map的时候,如果根据某一属性可能会导致key重复而异常,可以设置处理这种重复的方式
- Stratégie touristique d'été de Singapour: un jour pour visiter l'île de San taosha à Singapour
- Slam | how to align timestamps?
- Looking for innocence in New York -- a beautiful day at the discovery center of Legoland, New Jersey
- R language dplyr package filter function filters dataframe data. If the name of the data column (variable) to be filtered contains quotation marks, you need to use!! SYM syntax processing, otherwise n
- Imitation Jingdong magnifying glass effect (pink teacher version)
- 全志A33使用主线U-Boot
- Fastdfs installation
- R language ggplot2 visualization: gganimate package creates dynamic histogram animation (GIF) and uses transition_ The States function displays a histogram step by step along a given dimension in the
猜你喜欢

【每日一题】第二天

Obligatoire pour les débutants, cliquez sur deux boutons pour passer à un contenu différent

学生抖音宣传母校被吐槽“招生减章”,网友:哈哈哈哈哈哈

Tips for material UV masking

Have you stepped on the nine common pits in the e-commerce system?

ICDE 2023|TKDE Poster Session(CFP)

Excel finds the same value in a column, deletes the row or replaces it with a blank value

Singapore summer tourism strategy: play Singapore Sentosa Island in one day
![[daily question] the next day](/img/8a/18329bd9b4a3a4445c8fbbc1ce562b.png)
[daily question] the next day

论文导读 | 机器学习在数据库基数估计中的应用
随机推荐
中国信通院《数据安全产品与服务图谱》,美创科技实现四大板块全覆盖
医院在线问诊源码 医院视频问诊源码 医院小程序源码
Processing strategy of message queue message loss and repeated message sending
R language uses lrtest function of epidisplay package to perform likelihood ratio test on multiple GLM models (logisti regression). Compare whether the performance of the two models is different, and
Obligatoire pour les débutants, cliquez sur deux boutons pour passer à un contenu différent
论文导读 | 关于将预训练语言模型作为知识库的分析与批评
Talk about the design of red envelope activities in e-commerce system
How to enable the run dashboard function of idea
R语言dplyr包filter函数筛选dataframe数据、如果需要筛选的数据列(变量)名称中包含引号则需要使用!!sym语法处理、否则因为无法处理引号筛选不到任何数据
R language ggplot2 visual Facet: gganimate package is based on Transition_ Time function to create dynamic scatter animation (GIF)
二进制操作
Leetcode (154) -- find the minimum value II in the rotation sort array
ORA-01455: converting column overflows integer datatype
Slam | how to align timestamps?
2022软件工程期末考试 回忆版
[论文阅读] CA-Net: Leveraging Contextual Features for Lung Cancer Prediction
Tips for material UV masking
Hospital online inquiry source code hospital video inquiry source code hospital applet source code
R语言ggplot2可视化:gganimate包创建动态柱状图动画(gif)、使用transition_states函数在动画中沿给定维度逐步显示柱状图
产品经理应具备的能力