🦄 个人主页——🎐个人主页 🎐✨🍁
🪁🍁🪁🍁🪁🍁🪁🍁 感谢点赞和关注 ,每天进步一点点!加油!🪁🍁🪁🍁🪁🍁🪁🍁
目录
一、安装下载
二、执行安装
一、安装下载
下载地址:
https://dev.mysql.com/get/Downloads/MySQL-5.7/mysql-5.7.44-el7-x86_64.tar.gz
脚本和tar包结构
my.cnf 配置文件
[root@windp-aio opt]# cat config/my.cnf
[mysql]
socket=/var/lib/mysql/mysql.sock
# set mysql client default chararter
default-character-set=utf8
[mysqld]
socket=/var/lib/mysql/mysql.sock
# set mysql server port
port = 3306
# set mysql install base dir
basedir=/usr/local/mysql
# set the data store dir
datadir=/usr/local/mysql/data
# set the number of allow max connnection
max_connections=200
# set server charactre default encoding
character-set-server=utf8
# the storage engine
default-storage-engine=INNODB
lower_case_table_names=1
max_allowed_packet=16M
explicit_defaults_for_timestamp=true
[mysql.server]
user=mysql
basedir=/usr/local/mysql
二、执行安装
install_mysql.sh 安装脚本
#! /bin/bash
#
# Author: kangll
# CreateTime: 2023-11-10
# Desc: install mysql5.7.44
#
echo "******** INSTALL MYSQL *********"
BASEDIR=$(cd "$(dirname "$0")"; pwd)
# 卸载原有的mariadb
OLD_MYSQL=`rpm -qa|grep mariadb`
profile=/etc/profile
for mariadb in $OLD_MYSQL
do
rpm -e --nodeps $mariadb
done
# 删除原有的my.cnf
rm -rf /etc/my.cnf
#添加用户组 用户
groupadd mysql
useradd -g mysql mysql
#解压mysql包并修改名称
tar -zxvf $BASEDIR/mysql-5.7.44-el7-x86_64.tar.gz -C /usr/local
mv /usr/local/mysql-5.7.44-el7-x86_64 /usr/local/mysql
#更改所属的组和用户
chown -R mysql /usr/local/mysql
chgrp -R mysql /usr/local/mysql
mkdir -p /usr/local/mysql/data
mkdir -p /usr/local/mysql/log
chown -R mysql:mysql /usr/local/mysql/data
#粘贴配置文件my.cnf 内容见八 中的 my.cnf
cp $BASEDIR/config/my.cnf /usr/local/mysql/
# 安装mysql
/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql/ --datadir=/usr/local/mysql/data/
# 设置文件及目录权限:
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
chown 777 /usr/local/mysql/my.cnf
chmod +x /etc/init.d/mysqld
mkdir /var/lib/mysql
chmod 777 /var/lib/mysql
# 启动mysql
/etc/init.d/mysqld start
# 设置开机启动
chkconfig --level 35 mysqld on
chmod +x /etc/rc.d/init.d/mysqld
chkconfig --add mysqld
# 修改环境变量
ln -s /usr/local/mysql/bin/mysql /usr/bin
ln -s /var/lib/mysql/mysql.sock /tmp/
cat > /etc/profile.d/mysql.sh
执行完脚本 成功登录
ssh 操作需要免密 附上 本机免密脚本 ssh_keygen.sh
#! /bin/bash
#
#Author: kangll
#CreateTime: 2023-11-10
#Desc: 本机免密
#
set -x
# get ip
ip=$(ip addr show | grep -E 'inet [0-9]' | awk '{print $2}' | awk -F '/' '{print $1}' | sed -n '$p')
ssh_hosts=${ip}
ssh_networkname=(windp-aio)
ssh_passwd=winner@001
# 定义修改/etc/hosts文件的方法
#echo "开始修改地址映射"
#for ((i=0;i> /etc/hosts
# fi
#done
expect -v
if [ `echo $?` -ne 0 ];then
echo "安装expect命令"
yum install -y expect
fi
################################
#
################################
create_ssh_pub(){
echo "生成本地ssh公钥"
/usr/bin/expect /dev/null
fi
done
参考链接:ansible 实现自动化部署ambari(纯离线)_ansible ambari-CSDN博客