docker 安装-jdk安装-hadoop安装-nginx安装-tomcat安装
一、docker 安装
1.下载文件地址:
1) https://download.docker.com/
2) https://download.docker.com/linux/static/stable/x86_64/
3)https://docs.docker.com/get-docker/
2.下载的路径/opt/yuan/解压缩包
[root@localhost yuan]# tar -zxvf /opt/yuan/docker-24.0.1.tgz -C /opt/module
3.将解压出来的docker文件内容移动到 /usr/bin/ 目录下
cp docker/* /usr/bin/
[root@localhost module]# cp -r /opt/module/docker/* /usr/bin/
4.将docker注册为service的文件
vi /etc/systemd/system/docker.service
vi /opt/module/docker.service
[Unit]
Description=Docker Application Container Engine
Documentation=https://docs.docker.com
After=network-online.target firewalld.service
Wants=network-online.target
[Service]
Type=notify
# the default is not to use systemd for cgroups because the delegate issues still
# exists and systemd currently does not support the cgroup feature set required
# for containers run by docker
ExecStart=/usr/bin/dockerd
ExecReload=/bin/kill -s HUP $MAINPID
# Having non-zero Limit*s causes performance problems due to accounting overhead
# in the kernel. We recommend using cgroups to do container-local accounting.
LimitNOFILE=infinity
LimitNPROC=infinity
LimitCORE=infinity
# Uncomment TasksMax if your systemd version supports it.
# Only systemd 226 and above support this version.
#TasksMax=infinity
TimeoutStartSec=0
# set delegate yes so that systemd does not reset the cgroups of docker containers
Delegate=yes
# kill only the docker process, not all processes in the cgroup
KillMode=process
# restart the docker process if it exits prematurely
Restart=on-failure
StartLimitBurst=3
StartLimitInterval=60s
[Install]
WantedBy=multi-user.target
4.添加权限
#添加文件权限并启动docker
chmod +x /etc/systemd/system/docker.service
[root@localhost module]# cp -r /opt/module/docker.service/* /etc/systemd/system/docker.service
[root@localhost module]# chmod +x /etc/systemd/system/docker.service
5.启动docker
#重新加载配置文件
[root@localhost module]# systemctl daemon-reload
#启动Docker
[root@localhost module]# systemctl start docker
#设置开机自启
[root@localhost module]# systemctl enable docker.service
6.验证docker
#查看Docker状态
[root@localhost module]# systemctl status docker
#查看Docker版本
[root@localhost module]# docker -v
7.卸载
1)#通过 uname -r 命令查看你当前的内核版本
[root@localhost module]# uname -r
2)#执行卸载命令
[root@localhost module]# sudo yum remove docker \
docker-client \
docker-client-latest \
docker-common \
docker-latest \
docker-latest-logrotate \
docker-logrotate \
docker-engine
3)#删除 docker.service 文件
[root@localhost module]# rm -r /etc/systemd/system/docker.service
二、jdk安装
1、下载jdk
https://www.oracle.com/java/technologies/downloads/
2、用 xftp传输工具将 JDK 导入到opt目录下面的yuan文件夹下面
/opt/yuan/jdk-8u212-linux-x64.tar.gz [root@localhost ~ ]# ls /opt/ yuan
3、解压JDK到/opt/module目录
// 文件压缩包解压到指定位置 [root@localhost ~ ]# tar -zxvf jdk-8u212-linux-x64.tar.gz -C /opt/module/ [root@localhost~ ]# unzip -d /opt/module /jdk [root@localhost~ ]# tar -zxvf /opt/yuan/jdk-8u212-linux-x64.tar.gz -C /opt/module/
4、配置 JDK 环境变量
// 根据路径创建一个文件 'vi java_jdk_profile', // [root@localhost~ ]# vi /etc/systemd/system/hadoop_jdk_profile [root@localhost sofware]# vi .bash_profile [root@localhost sofware]# sudo vim /etc/profile.d/my_env.sh export JAVA_HOME=/opt/module/jdk_1.8.0_321 export CLASSPATH=.:$JAVA_HOME/lib:$JAVA_HOME/jre/lib export PATH=$PATH:$JAVA_HOME/bin:$JAVA_HOME/jre/bin -------------------------------------------------------------------------- #JAVA_HOME export JAVA_HOME=/opt/module/jdk1.8.0_212 export PATH=$PATH:$JAVA_HOME/bin
5、source 一下/etc/profile 文件,让新的环境变量 PATH 生效
[root@localhost~ ]# source /etc/systemd/system/hadoop_jdk_profile [root@localhost~ ]# source /opt/module/hadoop_jdk_profile
6、测试JDK是否安装成功
[root@localhost~ ]# javac [root@localhost~ ]# java -version //注意:如果能看到结果,则代表 Java 安装成功。 重启(如果 java -version 可以用就不用重启) [root@localhost~ ] reboot //重启电脑
7、卸载jdk
卸载虚拟机自带的 JDK 注意:如果你的虚拟机是最小化安装不需要执行这一步。 [root@hadoop100 ~]# rpm -qa | grep -i java | xargs -n1 rpm -e /*--nodeps --rpm -qa:查询所安装的所有 rpm 软件包 --grep -i:忽略大小写 --xargs -n1:表示每次只传递一个参数 --rpm -e –nodeps:强制卸载软件 */
8、jdk安装遇到的问题
#centos7下javac:未找到命令的问题: #执行安装 yum install java-devel,yum install java #javac 或者 java -version Vi编辑常用快捷键 复制:ctrl+insert 粘贴:shift+insert 按Esc保存退出编译,shift+zz退出.
三、hadoop安装
1、Hadoop 下载
1) https://archive.apache.org/dist/hadoop/ 2) https://archive.apache.org/dist/hadoop/common/hadoop-3.1.3/
2、用 xftp传输工具将hadoop-3.1.3.tar.gz
导入到opt目录下面的yuan文件夹
/opt/yuan/hadoop-3.1.3.tar.gz [root@localhost ~ ]# ls /opt/ yuan
3、解压安装文件到/opt/module
[root@localhost ~ ]# tar -zxvf /opt/yuan/hadoop-3.1.3.tar.gz -C /opt/module // 查看是否解压成功 [root@localhost ~ ]# ls /opt/module/
4、hadoop环境配置
#根据文件路径打开 vi /etc/systemd/system/hadoop_jdk_profile文件
#HADOOP_HOME export HADOOP_HOME=/opt/module/hadoop-3.1.3 export PATH=$PATH:$HADOOP_HOME/bin export PATH=$PATH:$HADOOP_HOME/sbin
5、修改后的文件重新生效
[root@localhost~ ]# source /etc/systemd/system/hadoop_jdk_profile
6、测试是否安装成功
[root@localhost hadoop-3.1.3 ]# hadoop version Hadoop 3.1.3
7、重启(如果 Hadoop
命令不能用再重启虚拟机)
[root@localhost hadoop-3.1.3 ]# sudo reboot
四、nginx安装
1、下载nginx,zlib、openssl、pcre
1) http://nginx.org/en/download.html 2) http://sourceforge.net/projects/pcre/files/pcre/ 3) http://www.zlib.net/fossils/ 4) https://www.openssl.org/ 4) http://ftp.gnu.org/gnu/gcc/gcc-5.1.0/ # c编译器 yum -y install gcc gcc-c++ autoconf automake make # 解析正则的pcre库 yum install -y pcre pcre-devel # 添加对gzip的支持 yum install -y zlib zlib-devel # SSL yum -y install gcc pcre pcre-devel zlib zlib-devel openssl openssl-devel 依赖包安装顺序依次为:openssl、zlib、pcre, 最后安装Nginx包。 #Nginx包 wget http://nginx.org/download/nginx-1.16.1.tar.gz #查文件的路径位置 whereis openssl
2、解压Nginx依赖包
tar -zxvf /opt/yuan/openssl-3.0.3.tar.gz-C /opt/module tar -zxvf /opt/yuan/zlib-1.2.12.tar.gz -C /opt/module tar -zxvf /opt/yuan/pcre2-10.40.tar.gz -C /opt/module tar -zxvf /opt/yuan/nginx-1.21.6.tar.gz -C /opt/module
3、进入解压后的opt/module/nginx-1.21.6,执行./configure
# openssl、zlib、pcre, Nginx包,解压文件后进入对应的文件目录执行./configure完成后, 回到pcre openssl、zlib、pcre、 Nginx目录下执行make,在执行make install [root@localhost openssl-3.0.3]# ./configure [root@localhost zlib-1.2.12]# ./configure [root@localhost pcre2-10.40]# ./configure [root@localhost nginx-1.21.6]# ./configure #如果执行./configure没有执行,给./configure根据文件路径配置 --prefix=/usr/local/nginx #路径修改个人路径 --with-http_ssl_module --with-pcre=../pcre-8.42 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.1.0h
4、Nginx的使用make && make install的区别
#./configure 配置环境 # make 是编译。就是把源码包编译成二进制可执行文件 # make install 安装。 # make && make install 的意思是: # make 与 make install 是两个命令,在 ./configuration 生成了Makefile之后执行编译安装; # 与:&& 一起的还有||,&&是与,||是或; # make && make install 的意思就是在执行完 make 后,如果没有发生错误就执行make install 。 [root@localhost openssl-3.0.3]# make && make install [root@localhost zlib-1.2.12]# make && make install [root@localhost pcre2-10.40]# make && make install [root@localhost nginx-1.21.6]# make && make install [root@localhost nginx-1.21.6]# make && make install
5、启动Nginx(直接用默认配置启动测试即可)
[root@localhost nginx-1.21.6]# cd /usr/local/nginx/sbin [root@localhost sbin]# ./nginx
6、开放端口
#开放nginx默认使用的80端口,并重启防火墙 # 开放80端口 [root@localhost nginx-1.21.6]# firewall-cmd --zone=public --add-port=80/tcp --permanent # 立即生效 [root@localhost nginx-1.21.6]# firewall-cmd --reload #查看开放的端口号 [root@localhost nginx-1.21.6]# firewall-cmd --list-all #设置开放的端口号 [root@localhost nginx-1.21.6]# firewall-cmd --add-service=http –permanent [root@localhost nginx-1.21.6]# sudo firewall-cmd --add-port=80/tcp --permanent #重启防火墙 [root@localhost nginx-1.21.6]# firewall-cmd –reload
7、设置nginx开机自启
在/etc/systemd/system/hadoop_jdk_profile
目录创建一个启动脚本
[root@localhost~ ]# vi /etc/systemd/system/nginx.service -----------------------------第1种添加方式---------------------------------------------- #对服务的说明 [Unit] #描述服务 Description=nginx - high performance web server #描述服务类别 After=network.target remote-fs.target nss-lookup.target #服务的一些具体运行参数的设置 [Service] #后台运行的形式 Type=forking #PID文件的路径 PIDFile=/home/Software/Nginx/nginx-1.19.8/logs/nginx.pid #启动准备 ExecStartPre=/home/Software/Nginx/nginx-1.19.8/sbin/nginx -t -c /home/Software/Nginx/nginx-1.19.8/conf/nginx.conf #启动命令 ExecStart=/home/Software/Nginx/nginx-1.19.8/sbin/nginx -c /home/Software/Nginx/nginx-1.19.8/conf/nginx.conf #重启命令 ExecReload=/home/Software/Nginx/nginx-1.19.8/sbin/nginx -s reload #停止命令 ExecStop=/home/Software/Nginx/nginx-1.19.8/sbin/nginx -s stop #给服务分配临时空间 PrivateTmp=true [Install] #服务用户的模式 WantedBy=multi-user.target -----------------------------------------------------第2种形式--------------------------------------------------- [Unit] #描述服务 Description=nginx service #描述服务类别 After=network.target remote-fs.target nss-lookup.target #服务的一些具体运行参数的设置 [Service] #后台运行的形式 Type=forking #启动准备 ExecStart=/usr/local/nginx/sbin/nginx #重启命令 ExecReload=/usr/local/nginx/sbin/nginx -s reload #停止命令 ExecStop=/usr/local/nginx/sbin/nginx -s quit #给服务分配临时空间 PrivateTmp=true [Install] WantedBy=multi-user.target
8、常用命令验证
#设置开机自启 systemctl enable nginx.service [root@localhost sbin]# systemctl enable nginx.service #停止开机自动启动 systemctl disable nginx.service [root@localhost sbin]# systemctl disable nginx.service #查看状态 systemctl status nginx.service [root@localhost sbin]# systemctl status nginx.service #重新加载配置文件 systemctl reload nginx.service [root@localhost sbin]# systemctl reload nginx.service #重启服务 systemctl restart nginx.service [root@localhost sbin]# systemctl restart nginx.service ----------------------------------------第2种方式---------------------------------------------- 1.重启命令 在/usr/local/nginx/sbin目录下执行./nginx 2.关闭命令 在/usr/local/nginx/sbin目录执行./nginx-S stop 3.重新加载命令 在/usr/local/nginx/sbin目录下执行./nginx-s reload
五、Tomcat 安装
1)Tomcat下载
https://archive.apache.org/dist/tomcat/tomcat-9/v9.0.22/bin/
2、使用
将下载好的apache-tomcat-9.0.22.tar.gz,上传的Linux中的opt/yuan/opt/yuan/apache-tomcat-9.0.22.tar.gz
3、解压缩包
[root@localhost /]# tar -zxvf /opt/yuan/apache-tomcat-9.0.22.tar.gz -C /opt/module
4、启动服务
[root@localhost /]# cd /opt/module/apache-tomcat-9.0.22/bin [root@localhost bin]# ./startup.sh
5、检查是否有tomcat进程
[root@localhost /]# cd /opt/module/apache-tomcat-9.0.22/bin [root@host-192-168-0-153 bin]# ./startup.sh
6、查询端口是否有进程守护,如8080为端口号
[root@localhost bin]# netstat -an | grep 8080 -bash: netstat: 未找到命令 [root@localhost ~]# yum -y install net-tools <!--安装依赖程序--> [root@localhost bin]# netstat -an | grep 8080
7、tomcat配置文件
------------------------------------------------------------------------------- 配置文件 cd /usr/lib/systemd/system [root@localhost ~]# vi /etc/systemd/system/hadoop_jdk_profile [Unit] Description=Tomcat After=syslog.target network.target remote-fs.target nss-lookup.target [Service] Type=oneshot ExecStart=/opt/module/apache-tomcat-9.0.22/bin/startup.sh ExecStop=/opt/module/apache-tomcat-9.0.22/bin/shutdown.sh ExecReload=/bin/kill -s HUP $MAINPID RemainAfterExit=yes [Install] WantedBy=multi-user.targe -------------------------------------------------------------------------- #tomcat环境变量目录 #JAVA_HOME export JAVA_HOME=/opt/module/jdk1.8.0_212 export PATH=$PATH:$JAVA_HOME/bin CATALINA_HOME=/opt/module/apache-tomcat-9.0.22 PATH=$PATH:$CATALINA_HOME/bin export PATH JAVA_HOME CLASSPATH CATALINA_HOME
8、重新启动tomcat的文件属性,把tomcat 修改为可运行的文件
[root@localhost~ ]# source /etc/systemd/system/hadoop_jdk_profile [root@localhost~ ]# chmod a+x /etc/systemd/system/hadoop_jdk_profile
9、设置服务运行级别(配置开机自启)---尝试
[root@host-192-168-0-153 bin]# chkconfig --add tomcat9 [root@localhost bin]# ./startup.sh /*报错异常 Neither the JAVA_HOME nor the JRE_HOME environment variable is defined At least one of these environment variable is needed to run this program 解决方法如下:*/ 2)启动服务器的tomcat失败 [root@localhost bin]# find / -name setclasspath.sh /opt/module/apache-tomcat-9.0.22/bin/setclasspath.s #如果不清楚setclasspath.sh文件位置,可以使用find命令或者locate命令搜索 find / -name setclasspath.sh //然后使用vi或vim命令打开setclasspath.sh文件进行修改 [root@localhost bin]# /opt/module/apache-tomcat-9.0.22/bin/vi setclasspath.sh 3)在setclasspath.sh文件的开头部分添加JAVA_HOME和JRE_HOME的环境变量路径。如下: //注意,可能我们并不知道JAVA_HOME和JRE_HOME环境变量的值,可以通过如下命令查看 echo $JAVA_HOME echo $JRE_HOME //然后把结果添加倒setclasspath.sh文件的开头部分,注意这里的/jdk和/jdk/jre是我主机上通过echo JAVA_HOME等命令查询出来的结果,具体值还得看自己服务器上的安装路径. export JAVA_HOME=/opt/module/jdk1.8.0_212 export JRE_HOME=/opt/module/jdk1.8.0_212/jre //再重启tomcat [root@localhost bin]# vi setclasspath.sh
10、修改tomcat默认端口,进入conf目录,编辑server.xml
//修改8080端口为你需要的端口,默认8080端口并不安全 <Connector executor="tomcatThreadPool" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
11、启动Tomcat服务
// ./catalina.sh start 和 ./startup.sh 都能启动tomcat。 // ./catalina.sh stop 或 ./shutdown.sh 停止tomcat。 //进入apache-tomcat-9.0.22 /bin目录 [root@localhost bin]# ./startup.sh
12、关闭Tomcat服务
//进入apache-tomcat-9.0.22 /bin目录 [root@localhost bin]# ./shutdown.sh
13、验证tomcat安装成功
//查看Tomcat启动是否正常 安装lsof命令: [root@localhost bin]# yum install -y lsof 验证命令: [root@localhost bin]# lsof -i:8080 //查询tomcat命令: [root@localhost bin]# ps -ef|grep tomcat //查看日志 [root@localhost bin]# cd /opt/module/apache-tomcat-9.0.22/logs //杀死进程 [root@localhost bin]# kill -9 pid