linux命令安装组件,Linux安装各种组件

[TOC]

Linux安装各种组件

=============================

## 安装JDK

官网下载最新JDK

```

http://www.oracle.com/technetwork/cn/java/javase/downloads/jdk8-downloads-2133151-zhs.html

```

or 用wget命令下载

wget --no-cookies --no-check-certificate --header "Cookie: gpw_e24=http%3A%2F%2Fwww.oracle.com%2F; oraclelicense=accept-securebackup-cookie" http://download.oracle.com/otn-pub/java/jdk/8u172-b11/a58eab1ec242421181065cdc37240b08/jdk-8u172-linux-x64.tar.gz

调用SCP命令复制JDK至LINUX目录

```linux

scp jdk-8u112-linux-x64.tar.gz 用户名@主机IP: 目标主机目录

```

调用tar解压JDK

```linux

cd 目标主机目录

tar -zvxf jdk-8u112-linux-x64.tar.gz

```

SU至root登录

```linux

su root

```

复制解压出来的JDK目录至/usr/local/ 视个人喜好而定

```linux

cp -r jdk-8u112-linux-x64 /usr/local/jdk-8u112-linux-x64

```

修改JAVA环境变量

**方法一 :**

```linux

vi /etc/profile

```

**方法二:**

**`在/etc/profile.d/目录上创建名为setup_jdk_env.sh的脚本文件:`**

```

# 创建shell脚本文件

vi /etc/profile.d/setup_jdk_env.sh

```

**`在脚本上执行编写jdk相关的环境变量配置:`**

```shell

#!/bin/bash

export JAVA_HOME=/opt/local/java/jdk1.8.0_131

export JRE_HOME=$JAVA_HOME/jre

export CLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib

export PATH=$PATH:$JAVA_HOME/bin:$JRE_HOME/bin

```

> **`JAVA_HOME`** 为你的jdk根目录,**`很重要`**

**`chmod更改文件为可执行:`**

```

chmod +x /etc/profile.d/setup_jdk_env.sh

```

**`执行文件,并用source命令将/etc/profie重新引入:`**

```

sh /etc/profile.d/setup_jdk_env.sh

```

**`将修改的环境变量索引至系统以测试:`**

```linux

source /etc/profile

```

运行java -version查看

```linux

java -version

java version "1.8.0_112"

Java(TM) SE Runtime Environment (build 1.8.0_112-b15)

Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

```

运行javac -version查看

```linux

javac -version

javac 1.8.0_112

```

如果成功,退出root

```linux

exit

```

执行命令 . /etc/profile[^excute-etc]

```linux

. /etc/profile

```

再次运行java -version与javac -version确认JDK是否安装成功

## 安装Apache

下载Apache

```

http://httpd.apache.org/

```

复制至目标主机

```linux

scp httpd-2.2.31.tar.gz 用户名@主机IP: 目标主机目录

```

tar解压

```linux

cd 目标主机目录

tar -zvxf httpd-2.2.31.tar.gz

```

改用root用户登录

```linux

su root

```

cd至解压好的httpd-X目录

```linux

cd httpd-2.2.31/

```

配置Apache

```linux

./configure --prefix=/usr/local/apache

```

编译

```linux

make

```

安装

```linux

make install

```

备份参数文件

```linux

cd /usr/local/apache/conf/

cp -a httpd.conf httpd.conf_bak

```

修改配置参数

```linux

vi /usr/local/apache/conf/httpd.conf

```

测试

```linux

cd /usr/local/apache/bin

./apachectl -k start

```

结果

```linux

ps -ef | grep apache | grep -v grep

root 8051 1 0 18:13 ? 00:00:00 /usr/local/apache/bin/httpd -k start

daemon 8052 8051 0 18:13 ? 00:00:00 /usr/local/apache/bin/httpd -k start

daemon 8053 8051 0 18:13 ? 00:00:00 /usr/local/apache/bin/httpd -k start

daemon 8054 8051 0 18:13 ? 00:00:00 /usr/local/apache/bin/httpd -k start

daemon 8055 8051 0 18:13 ? 00:00:00 /usr/local/apache/bin/httpd -k start

daemon 8056 8051 0 18:13 ? 00:00:00 /usr/local/apache/bin/httpd -k start

```

## 安装Tomcat

官网下载最新版Tomcat

```linux

http://tomcat.apache.org/download-80.cgi

```

远程复制Tomcat至目标机器

```linux

scp apache-tomcat-8.5.9.tar.gz 用户名@目标机器IP: 目标机器目录

```

解压Tomcat

```linux

tar -zvxf apache-tomcat-8.5.9.tar.gz

```

切换至root用户

```linux

su root

```

剪切Tomcat至/usr/local/目录(视个人喜好而定)

```linux

mv apache-tomcat-8.5.9 /usr/local/

```

确保本地已配置Java环境变量

```linux

java -version

java version "1.8.0_112"

Java(TM) SE Runtime Environment (build 1.8.0_112-b15)

Java HotSpot(TM) 64-Bit Server VM (build 25.112-b15, mixed mode)

javac -version

javac 1.8.0_112

```

定位至tomcat bin目录

```linux

cd /usr/local/apache-tomcat-8.5.9/bin

```

启动Tomcat

```linux

./startup.sh

```

**礼成**

## 安装Zookeeper

官网下载最新版zookeeper

```

http://zookeeper.apache.org/releases.html#download

```

远程复制至目标机器

```shell

scp zookeeper-3.4.9.tar.gz 用户名@目标机器IP: 目标机器目录/

```

登录目标机器,并解压

```shell

tar -zvxf zookeeper-3.4.9.tar.gz

```

移动至相关目录

```shell

mv zookeeper-3.4.9 /usr/local/

```

定位至zookeeper目录

```linux

cd /usr/local/zookeeper-3.4.9

```

进入conf配置zookeeper,备份原来的zoo_sample.cfg,并生成一份可用于zookeeper运行的zoo.cfg

```linux

cd conf

cp -a zoo_sample.cfg zoo.cfg

vi zoo.cfg

```

定位至bin目录并启动zookeeper

```linux

cd /usr/local/zookeeper-3.4.9/bin/

./zkServer.sh start

ZooKeeper JMX enabled by default

Using config: /usr/local/zookeeper-3.4.9/bin/../conf/zoo.cfg

Starting zookeeper ... STARTED

```

查看进程,确认zookeeper启动成功

```

ps -ef | grep zookeeper

```

## 安装MySql

## 安装Redis

官网下载最新版Redis

```

https://redis.io/download

```

远程复制至目标主机

```linux

scp redis-3.2.6.tar.gz 用户名@目标主机IP: 目标地址

```

ssh登录至目标主机并解压

```linux

tar -zvxf redis-3.2.6.tar.gz

```

切换至Root用户

```linux

su root

```

剪切Redis至目标目录

```linux

mv redis-3.2.6 /usr/local/redis-3.2.6

```

**正式安装Redis**

定位至Redis目录

```linux

cd /usr/local/redis-3.2.6

```

编译Redis

```linux

make

```

安装Redis

```linux

make install

```

为方便管理,可以新建一个Redis目录,并将相关的文件Copy至新目录

```linux

mkdir -p /usr/local/redis/bin

mkdir -p /usr/local/redis/conf

mv /usr/local/redis-3.2.6/redis.conf /usr/local/redis/conf

cd /usr/local/redis-3.2.6/src

mv mkreleasdhdr.sh redis-benchmark redis-check-aof redis-cli redis-server /usr/local/redis/bin

```

测试启动redis服务

```linux

cd /usr/local/redis/bin

./redis-server

```

这时,如果服务启动成功,则显示如下界面

```linux

11951:C 11 Dec 23:21:16.929 # Warning: no config file specified, using the default config. In order to specify a config file use ./redis-server /path/to/redis.conf

11951:M 11 Dec 23:21:16.930 * Increased maximum number of open files to 10032 (it was originally set to 1024).

_._

_.-``__ ''-._

_.-`` `. `_. ''-._ Redis 3.2.6 (00000000/0) 64 bit

.-`` .-```. ```\/ _.,_ ''-._

( ' , .-` | `, ) Running in standalone mode

|`-._`-...-` __...-.``-._|'` _.-'| Port: 6379

| `-._ `._ / _.-' | PID: 11951

`-._ `-._ `-./ _.-' _.-'

|`-._`-._ `-.__.-' _.-'_.-'|

| `-._`-._ _.-'_.-' | http://redis.io

`-._ `-._`-.__.-'_.-' _.-'

|`-._`-._ `-.__.-' _.-'_.-'|

| `-._`-._ _.-'_.-' |

`-._ `-._`-.__.-'_.-' _.-'

`-._ `-.__.-' _.-'

`-._ _.-'

`-.__.-'

11951:M 11 Dec 23:21:16.930 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.

11951:M 11 Dec 23:21:16.930 # Server started, Redis version 3.2.6

11951:M 11 Dec 23:21:16.930 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.

11951:M 11 Dec 23:21:16.931 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.

11951:M 11 Dec 23:21:16.931 * DB loaded from disk: 0.000 seconds

11951:M 11 Dec 23:21:16.931 * The server is now ready to accept connections on port 6379

```

这时启动的服务是在前台运行的,所以如果Linux关闭会话,则服务也会退出!要解决这个问题,就需要配置Redis 的daemonize,将其改为yes

```linux

cd /usr/local/redis/conf

cat -n redis.conf | grep daemonize

vi -128 redis.conf

```

上述代码,先用cat -n 显示行号,并通过grep 查找关键字,确定daemonize所在行(如在128行),然后再能过vi -128直接将vi定位至128行,方便修改

改完后,再次启动redis-server,并指定配置文件

```linux

./redis-server /usr/local/redis/conf/redis.conf

```

[^excute-etc]: `. /etc/profile .与/之间有空格`

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值