#!/bin/bash
install_mysql_cli(){
rpm -qa|grep mariadb|xargs rpm -e --nodeps
cd /data/src
mkdir /data/app/mysql/data -p
tar -xf mysql-5.7.31-1.el7.x86_64.rpm-bundle.tar
rpm -ivh mysql-community-common-5.7.31-1.el7.x86_64.rpm mysql-community-libs-5.7.31-1.el7.x86_64.rpm mysql-community-client-5.7.31-1.el7.x86_64.rpm
}
install(){
cd /data/src
unzip nacos-server-1.4.3_2.zip -d /data/app/nacos-server-1.4.3_2
sed -i '/\$HOME\/jdk\/java/iset JAVA_HOME=\/data\/app\/jdk1.8.0_341' /data/app/nacos-server-1.4.3_2/bin/startup.sh
sed -i 's/$HOME\/jdk\/java/\/data\/app\/jdk1.8.0_341/g' /data/app/nacos-server-1.4.3_2/bin/startup.sh
sed -i -e '31 s/^/#/' -i -e '32 s/^/#/' -i -e '33 s/^/#/' /data/app/nacos-server-1.4.3_2/bin/startup.sh
sed -i 's/export MODE=\"cluster\"/export MODE=\"standalone\"/' /data/app/nacos-server-1.4.3_2/bin/startup.sh
echo "Please input mysql address:"
read mysql_addr
sed -i "s/127.0.0.1/$mysql_addr/g" /data/app/nacos-server-1.4.3_2/conf/application.properties
sed -i 's/db.password.0=root/db.password.0=zte@1234/' /data/app/nacos-server-1.4.3_2/conf/application.properties
chmod 777 /data/app/nacos-server-1.4.3_2/bin/*.sh
ln -sf /data/app/jdk1.8.0_341/bin/javac /usr/bin/javac
ln -sf /data/app/jdk1.8.0_341/bin/jar /usr/bin/jar
ln -sf /data/app/jdk1.8.0_341/bin/java //bin/java
mysql -uroot -pzte@1234 -h$mysql_addr -Dnacos < /data/app/nacos-server-1.4.3_2/conf/nacos-mysql.sql
mysql -uroot -pzte@1234 -h$mysql_addr -Dnacos < /data/app/nacos-server-1.4.3_2/conf/schema.sql
}
auto_start(){
cat>>/etc/systemd/system/nacos.service<<EOF
[Unit]
Description=nacos
After=network.target
[Service]
Type=forking
ExecStart=/data/app/nacos-server-1.4.3_2/bin/startup.sh -m standalone
ExecReload=/data/app/nacos-server-1.4.3_2/bin/shutdown.sh
ExecStop=/data/app/nacos-server-1.4.3_2/bin/shutdown.sh
PrivateTmp=true
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable nacos
systemctl start nacos
}
chk_install(){
batchNo=$(systemctl status nacos|grep Active)
if [[ $batchNo == *"active (running)"* ]];then
echo "nacos install complete."
else
echo "nacos install has problem."
fi
}
main(){
install_mysql_cli
install $1
auto_start
chk_install
}
main "$@"
服务器部署中间件及依赖包的脚本,在centos 7.6系统可用
需积分: 0 45 浏览量
更新于2023-10-11
收藏 4KB GZ 举报
#!/bin/bash
get_char(){
SAVEDSTTY=`stty -g`
stty -echo
stty cbreak
dd if=/dev/tty bs=1 count=1 2> /dev/null
stty -raw
stty echo
stty $SAVEDSTTY
}
wt(){
SCRIPT=$(whiptail --title "CheckList" --menu \
"Choosed deploy mode" 15 60 2 \
"01-single" "Single deploy mode." \
"02-distribute" "Distribute deploy mode." 3>&1 1>&2 2>&3)
exitstatus=$?
if [ $exitstatus = 0 ]; then
echo "Your chooses are:" $SCRIPT
read -r -p "Are You Sure? [Y/n] " input
case $input