不喜欢出去跟人社交,有这时间我还不如安安静静研究学习。噢对了,rpm包的方式安装java不需要配置环境变量。直接rpm -ivh就完事了。还有就是要查看mysql日志的话,他的位置一般在:/var/log/mysqld.log。
little tips
为了我们在修改配置文件的时候方便点,可以设置添加行号。
代码语言:javascript复制# cd 到root主目录
cd ~
vim .vimrc
# 添加如下内容
:set number
# 保存退出即可
实列1-apollo部署:数据库操作,配置文件内容修改
代码语言:javascript复制 1 tar -xzvf ./apollo.tar.gz -C /opt/ # 解压该压缩包到opt/目录下
2
3 # 使用sed -i 命令修改配置文件的第十九行,修改为:spring.datasource.password = Kuaiye*2021
4 sed -i '19c spring.datasource.password = Kuaiye*2021' /opt/apollo/portal/config/application-github.properties
5 sed -i '19c spring.datasource.password = Kuaiye*2021' /opt/apollo/admin/config/application-github.properties
6 sed -i '19c spring.datasource.password = Kuaiye*2021' /opt/apollo/config/config/application-github.properties
7
8 # $a:在配置文件最后一行添加内容:[client]
9 sed -i '$a [client]' /etc/my.cnf
10 sed -i '$a password= Kuaiye*2021' /etc/my.cnf
11 # 操作数据库,这种对数据库的操作方式是对配置文件:my.cnf修改来完成的,实际中不建议操作,因为密码直接写在了my.cnf文件中,稍微厉害的人就能发现密码,从而对数据库产生安全威胁。
12 mysql -u root << EOF
13 create database ApolloConfigDB;
14 create database ApolloPortalDB;
15 use ApolloConfigDB;
16 source ./../apolloconfigdb.sql;
17 use ApolloPortalDB;
18 source ./../apolloportaldb.sql;
19 EOF
20
21 # 启动
22 /opt/apollo/config/scripts/startup.sh && /opt/apollo/admin/scripts/startup.sh && /opt/apollo/portal/scripts/startup.sh
Mysql java以离线rpm包方式自动部署
代码语言:javascript复制 1 # data:2022.1.10
2 # author:liudongdong
3 # content:mysql and java
4 # version:mysql-5.7 java-openjdk.1.8.0
5
6 # install java
7 rpm -ivh jdk-8u311-linux-x64.rpm
8 java -version
9
10
11 # install mysql
12 yum localinstall -y ./mysql-community-common-5.7.35-1.el7.x86_64.rpm
13 yum localinstall -y ./mysql-community-libs-5.7.35-1.el7.x86_64.rpm
14 yum localinstall -y ./mysql-community-client-5.7.35-1.el7.x86_64.rpm
15 yum localinstall -y ./mysql-community-server-5.7.35-1.el7.x86_64.rpm
16
17 systemctl start mysqld
18 systemctl enable mysqld
19 systemctl status mysqld
20
21 #sed -i '$a [client]' /etc/.my.cnf
22 #sed -i '$a password= Kuaiye*2021' /etc/.my.cnf
23
24 password=$(cat /var/log/mysqld.log |grep "generated"|cut -d : -f 4|cut -d' ' -f 2)
25 echo "请及时修改mysql密码,修改语句为:ALTER USER 'root'@'localhost' IDENTIFIED BY 'Kuaiye*2021';"
26 echo "mysql初始密码为:${password}"
27 mysql -u root -p
卸载Mysql脚本
代码语言:javascript复制 1 #! /bin/bash
2
3 rpm -ev --nodeps mysql-community-common-5.7.35-1.el7.x86_64
4 rpm -ev --nodeps mysql-community-client-5.7.35-1.el7.x86_64
5 rpm -ev --nodeps mysql-community-server-5.7.35-1.el7.x86_64
6 rpm -ev --nodeps mysql-community-libs-5.7.35-1.el7.x86_64
7
8 rpm -qa|grep mysql
9
10 rm -rf /usr/lib64/mysql
11 rm -rf /usr/share/mysql
12
13 echo "complete!"