当前位置:网站首页>虚拟机初始化脚本, 虚拟机相互免秘钥
虚拟机初始化脚本, 虚拟机相互免秘钥
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边栏推荐
- 在Tensorflow2中使用mnist_784数据集进行手写数字识别
- The second bullet of AI development and debugging series: the exploration journey of multi machine distributed debugging
- Slam | how to align timestamps?
- 中国信通院《数据安全产品与服务图谱》,美创科技实现四大板块全覆盖
- 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
- ICDE 2023|TKDE Poster Session(CFP)
- MySQL advanced learning summary 8: overview of InnoDB data storage structure page, internal structure of page, row format
- 预处理和预处理宏
- [100 cases of JVM tuning practice] 01 - introduction of JVM and program counter
- 产品经理应具备的能力
猜你喜欢

How performance testing creates business value

Markdown基础语法

9D电影是怎样的?(+维度空间常识)

【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例

开源物联网平台ThingsBoard的安装
![[daily question] the next day](/img/8a/18329bd9b4a3a4445c8fbbc1ce562b.png)
[daily question] the next day

Mini Golf Course: a good place for leisure and tourism in London

Introduction to the paper | analysis and criticism of using the pre training language model as a knowledge base

教程篇(5.0) 09. RESTful API * FortiEDR * Fortinet 网络安全专家 NSE 5

【JVM调优实战100例】03——JVM堆调优四例
随机推荐
Learning summary of MySQL advanced 6: concept and understanding of index, detailed explanation of b+ tree generation process, comparison between MyISAM and InnoDB
2022编译原理期末考试 回忆版
juypter notebook 修改默认打开文件夹以及默认浏览器
拦截器与过滤器的区别
2022软件工程期末考试 回忆版
M2DGR:多源多场景 地面机器人SLAM数据集(ICRA 2022 )
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
R语言ggplot2可视化:可视化折线图、使用labs函数为折线图添加自定义的X轴标签信息
The difference between interceptor and filter
预处理和预处理宏
Fastdfs installation
[0701] [paper reading] allowing data imbalance issue with perforated input during influence
metric_logger小解
论文导读 | 机器学习在数据库基数估计中的应用
医院在线问诊源码 医院视频问诊源码 医院小程序源码
【JVM调优实战100例】02——虚拟机栈与本地方法栈调优五例
UML 类图
深度学习数学基础
Stm32g0 USB DFU upgrade verification error -2
What are the links of the problem