# mysql安装包是否存在,不存在则下载 if [ ! -f ${software_dir}'/'${mysql_package_xz} ]; then if ! command -v wget; then echo"=====>安装wget命令" yum -y install wget >/dev/null 2>&1 fi
echo"=====>下载mysql安装包到:$software_dir" wget $mysql_package_url fi
echo"=====>启动mysql服务" systemctl restart mysql > /dev/null 2>&1
echo"=====>设置mysql配置,修改密码,远程访问" mysql_password=`awk '/A temporary password/{print $NF}' ./log/mysql.log` mysql -uroot -p"$mysql_password" -e " alter user 'root'@'localhost' identified with mysql_native_password by '$mysql_init_password'; use mysql; update user set host='%' where user='root' limit 1; flush privileges;" --connect-expired-password >/dev/null 2>&1
# redis安装包是否存在,不存在则下载 if [ ! -f ${software_dir}'/'${redis_package_gz} ]; then if ! command -v wget; then echo"=====>安装wget命令" yum -y install wget >/dev/null 2>&1 fi
echo"=====>下载redis安装包到:$software_dir" wget --no-check-certificate $redis_package_url fi
echo"=====>编译安装redis" make >/dev/null 2>&1 && make install >/dev/null 2>&1
# 文件统一管理 mkdir etc bin mv redis.conf ${redis_dir}/etc cd src mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-check-rdb redis-cli redis-server ${redis_dir}/bin
echo"=====>设置redis自启动" cp${redis_dir}/utils/redis_init_script $redis_initd sed 's:EXEC=/usr/local/bin/redis-server:EXEC=/usr/local/redis/bin/redis-server:' -i $redis_initd sed 's:CLIEXEC=/usr/local/bin/redis-cli:CLIEXEC=/usr/local/redis/bin/redis-cli:' -i $redis_initd sed '19c CONF=/usr/local/redis/etc/redis.conf' -i $redis_initd chkconfig redis on
echo"=====>修改redis配置" sed 's:daemonize no:daemonize yes:' -i $redis_config sed 's:bind 127.0.0.1:# bind 127.0.0.1:' -i $redis_config sed 's:# requirepass foobared:requirepass admin123456:' -i $redis_config
# mysql安装包是否存在,不存在则下载 if [ ! -f ${software_dir}'/'${nginx_package_gz} ]; then if ! command -v wget; then echo"=====>安装wget命令" yum -y install wget >/dev/null 2>&1 fi
echo"=====>下载nginx安装包到:$software_dir" wget $nginx_package_url fi
# java安装包是否存在,不存在则下载 if [ ! -f ${software_dir}'/'${java_package_gz} ]; then if ! command -v wget; then echo"=====>安装wget命令" yum -y install wget >/dev/null 2>&1 fi
echo"=====>下载java安装包到:$software_dir" wget $java_package_url fi
# nacos安装包是否存在,不存在则下载 if [ ! -f ${software_dir}'/'${nacos_package_gz} ]; then if ! command -v wget; then echo"=====>安装wget命令" yum -y install wget >/dev/null 2>&1 fi
echo"=====>下载nacos安装包到:$software_dir" wget $nacos_package_url fi
echo"=====>解压缩nacos安装包" tar -xf $nacos_package_gz
# 创建目录 create_dir $nacos_dir
# 移动文件 mv nacos $nacos_dir/$nacos_version
echo"=====>执行sql" mysql -u$mysql_username -p"$mysql_password" -e "create database nacos_config;" --connect-expired-password >/dev/null 2>&1 mysql -u$mysql_username -p"$mysql_password" -Dnacos_config < $nacos_conf_sql >/dev/null 2>&1
echo"=====>修改配置文件" sed '33c spring.datasource.platform=mysql' -i $nacos_conf_properties sed '36c db.num=1' -i $nacos_conf_properties sed '39c db.url.0=jdbc:mysql://127.0.0.1:3306/nacos_config?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true&useUnicode=true&useSSL=false&serverTimezone=Asia/Shanghai' -i $nacos_conf_properties sed '40c db.user.0='$mysql_username -i $nacos_conf_properties sed '41c db.password.0='$mysql_password -i $nacos_conf_properties