Centos8安装java部署环境

与天地兮比寿,与日月兮齐光。这篇文章主要讲述Centos8安装java部署环境相关的知识,希望能为你提供帮助。
相关软件xshell:连接linux执行命令
xftp:可视化上传文件
edit-plus:可视化编辑文件
jdk安装 验证系统是否自带jdk环境

pm -qa|grep java rpm -qa|grep jdk rpm -qa|grep gcj

卸载opnejdk
yum -y remove copy-jdk-configs-3.7-1.el8.noarch

验证
java -version

解压
tar xf jdk-8u241-linux-x64.tar.gz

配置环境变量
export JAVA_HOME=/usr/soft/jdk/jdk1.8.0_241 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin

配置文件生效
source /etc/profile

mave安装 解压
tar xf apache-maven-3.8.1-bin.tar.gz

配置环境变量
export MAVEN_HOME=/usr/soft/maven/apache-maven-3.8.1 export PATH=$MAVEN_HOME/bin:$PATH

配置文件生效
source /etc/profile

msyql安装 验证系统是否自带mysql环境
rpm -qa | grep mysql

卸载mysql
rpm -ev mysql-libs-* --nodeps

安装mysql
rpm -ivh mysql-community-client-5.7.32-1.el7.x86_64.rpm --force --nodeps rpm -ivh mysql-community-common-5.7.32-1.el7.x86_64.rpm --force --nodeps rpm -ivh mysql-community-libs-5.7.32-1.el7.x86_64.rpm --force --nodeps rpm -ivh mysql-community-server-5.7.32-1.el7.x86_64.rpm --force --nodeps

启动mysql
service mysqld statusservice mysqld start

初始化随机密码
cat /var/log/mysqld.log | more

查看密码
grep pass /var/log/mysqld.log --color

登录修改密码
mysql -uroot -p set global validate_password_policy=LOW; set global validate_password_length=6; set password=\'abcd@1234\'; grant all privileges on *.* to \'root\'@\'%\' identified by \'abcd@1234\';

mysql命令无效安装依赖包
yum install libncurses*

设置开机启动
systemctl enable mysqld systemctl daemon-reload

打开远程访问及端口
update user set host=\'%\' where user=\'root\'; Alter user \'root\'@\'%\' identified by \'abcd@1234\'; grant all privileges on *.* to \'root\'@\'%\' with grant option; FLUSH PRIVILEGES; //查看防火墙状态 systemctl status firewalld //开启防火墙 systemctl start firewalld //设置端口 firewall-cmd --zone=public --add-port=3306/tcp --permanent //重启防火墙 firewall-cmd --reload //查询 firewall-cmd --zone=public --query-port=3306/tcp

设置忽略大小写
/etc/my.cnf lower_case_table_names=1 service mysqld restart

redis安装 解压
tar xf redis-6.2.5.tar.gz

安装gcc环境
yum install gcc-c++

进入解压目录编译与安装
cd /usr/soft/redis/redis-6.2.5/make cd ./src make install

统一管理配置与常用命令
mkdir bin mkdir etc mv redis.conf ./etc/ cd ./src mv mkreleasehdr.sh redis-benchmark redis-check-aof redis-cli redis-server /usr/soft/redis/redis-6.2.5/bin/

编辑redis.conf文件
daemonize改为yes注释bind 127.0.0.1protected-mode改为no修改requirepass默认密码

设置开机启动将以下文本加入到 /etc/rc.d/rc.local中
/usr/soft/redis/redis-6.2.5/bin/redis-server/usr/soft/redis/redis-6.2.5/etc/redis.conf

启动redis服务
cd /usr/soft/redis/redis-6.2.5/bin/ ./redis-server /usr/soft/redis/redis-6.2.5/etc/redis.conf

开放端口
//查看防火墙状态 systemctl status firewalld //开启防火墙 systemctl start firewalld //设置端口 firewall-cmd --zone=public --add-port=6379/tcp --permanent //重启防火墙 firewall-cmd --reload //查询 firewall-cmd --zone=public --query-port=6379/tcp

jenkins安装 安装
rpm -ivh jenkins-2.174-1.1.noarch.rpm

配置jdk路径
/etc/init.d/jenkins /usr/soft/jdk/jdk1.8.0_241/bin/java

设置jenkins用户root权限
/etc/init.d/jenkins $JENKINS_USER="root" chown -R root:root /var/lib/jenkins chown -R root:root /var/cache/jenkins chown -R root:root /var/log/jenkins systemctl restart jenkins

查找jenkins安装目录
whereis jenkins

启动jenkins
service jenkins star

开放端口
//查看防火墙状态 systemctl status firewalld //开启防火墙 systemctl start firewalld //设置端口 firewall-cmd --zone=public --add-port=8080/tcp --permanent //重启防火墙 firewall-cmd --reload //查询 firewall-cmd --zone=public --query-port=8080/tcp

设置jdk路径【Centos8安装java部署环境】系统管理 → 全局工具配置→ JDK
shell脚本
java -jar /usr/jenkinsworkspace/smartaudit/smartaudit.jar

关闭进程
sudo lsof -i:8000 sudo kill -9 850


    推荐阅读