Linux部署笔记分享

# Linux部署

## 安装lrzsz
1. 安装lrzsz: yum -y install lrzsz
2. 进入tmp目录
3. rz 上传安装文件
jdk-8u65-linux-x64.tar.gz
apache-tomcat-8.0.28.tar.gz
oracle-xe-11.2.0-1.0.x86_64.rpm.zip
redis-3.2.4.tar.gz
apache-activemq-5.14.0-bin.tar.gz
elasticsearch-2.4.0.tar.gz

## 安装JDK
1. 解压 JDK: tar -zxvf jdk-8u65-linux-x64.tar.gz .
1、*.tar 用 tar –xvf 解压
2、*.gz 用 gzip -d或者gunzip 解压
3、*.tar.gz和*.tgz 用 tar –xzf 解压
4、*.bz2 用 bzip2 -d或者用bunzip2 解压
5、*.tar.bz2用tar –xjf 解压
6、*.Z 用 uncompress 解压
7、*.tar.Z 用tar –xZf 解压
8、*.rar 用 unrar e解压
9、*.zip 用 unzip 解压

2. 将安装目录移动到 /usr下
mv ./jdk1.8.0_65/ /usr/

3. 创建链接简化目录操作
ln -s /usr/jdk1.8.0_65/ /usr/jdk

4. 编辑环境变量path 、JAVA_HOME
vi /etc/profile

在文件末尾添加
JAVA_HOME=/usr/jdk
export CLASSPATH=.:$JAVA_HOME/lib
export PATH=$JAVA_HOME/bin:$PATH

:wq 退出
重启 shutdown -r now (source /etc/profile )

```
dd 删除行 , i 添加内容 , x删除当前字符
:wq 保存
:q! 不保存
```

## 安装Tomcat服务器
1. 解压tomcat到opt目录
tar -zxvf apache-tomcat-8.0.28.tar.gz -C /opt
2. 创建链接简化目录操作
ln -s /opt/apache-tomcat-8.0.28 /opt/tomcat
3. 启动tomcat
/opt/tomcat/bin/start.sh
4. 自动开机启动

```
1、编辑startup.sh
#chkconfig: 2345 80 90
#description:tomcat auto start
#processname: tomcat

2、编辑catalina.sh
./export 搜索
export JAVA_HOME = /usr/jdk
export CATALINA_BASE=/opt/tomcat
export CATALINA_HOME=/opt/tomcat
export CATALINA_TMPDIR=/opt/tomcat/temp

3、link start.sh 到 /etc/init.d/tomcat
ln -s /opt/tomcat/bin/startup.sh /etc/init.d/tomcat

3、添加服务
chkconfig --add tomcat
chkconfig tomcat on
```

## 安装Oracle数据库
1. 解压zip安装包: unzip oracle-xe-11.2.0-1.0.x86_64.rpm.zip
2. 进入 Disk1,安装oracle11g xe
rpm -ivh oracle-xe-11.2.0-1.0.x86_64.rpm
备注: 卸载 rpm -e --nodeps oracle-xe-11.2.0-1.0.x86_64
3. /etc/init.d/oracle-xe文件中是有包含Oracle环境变量的一些参数的,我们只需要从中复制中其中的 ORALCE_HOME,ORALCE_BASE,PATH,ORALCE_SID 到 /etc/profile 中
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/xe
export ORACLE_SID=XE
export ORACLE_BASE=/u01/app/oracle
export PATH=$ORACLE_HOME/bin:$PATH
LSNR=$ORACLE_HOME/bin/lsnrctl
SQLPLUS=$ORACLE_HOME/bin/sqlplus
ORACLE_OWNER=oracle
4. :wq 保存退出, 输入命令: source /etc/profile
5. 完成数据库配置 /etc/init.d/oracle-xe configure
6. 自动开机启动 chkconfig oracle-xe on

错误 :ORA-00130: invalid listener address '(ADDRESS=(PROTOCOL=TCP)(HOST=host-10-0-0-10)(PORT=1521))'
解决: 配置/etc/hosts 文件
127.0.0.1 host-10-0-0-10

## 创建oracle账号 bos 、crm
- 创建bos、crm账号

- bos、crm 账户锁定解决
alter user bos account unlock;
alter user bos identified by bos;

alter user crm account unlock;
alter user crm identified by crm;

## 安装redis
1. 安装gcc
yum install -y gcc g++ gcc-c++ make
2. 下载解压 redis
wget http://download.redis.io/releases/redis-3.0.0.tar.gz
tar zxvf redis-3.0.0.tar.gz
cd redis-3.0.0
3. 进入redis目录,执行make
make MALLOC=libc
4. 启动 关闭 redis
- 启动redis
src/redis-server &
- 关闭redis
src/redis-cli shutdown
5. redis 开机启动
创建链接 ln -s /usr/redis.3.0.0 /usr/redis
修改 redis.config
```
daemonize yes
```
vi /etc/init.d/redis

```
# chkconfig: 2345 10 90
# description: Start and Stop redis

PATH=/usr/local/bin:/sbin:/usr/bin:/bin
REDISPORT=6379
EXEC=/usr/redis/src/redis-server
REDIS_CLI=/usr/redis/src/redis-cli

PIDFILE=/var/run/redis.pid
CONF="/use/redis/redis.conf"
AUTH="1234"

case "$1" in
start)
if [ -f $PIDFILE ]
then
echo "$PIDFILE exists, process is already running or crashed."
else
echo "Starting Redis server..."
$EXEC $CONF
fi
if [ "$?"="0" ]
then
echo "Redis is running..."
fi
;;
stop)
if [ ! -f $PIDFILE ]
then
echo "$PIDFILE exists, process is not running."
else
PID=$(cat $PIDFILE)
echo "Stopping..."
$REDIS_CLI -p $REDISPORT SHUTDOWN
sleep 2
while [ -x $PIDFILE ]
do
echo "Waiting for Redis to shutdown..."
sleep 1
done
echo "Redis stopped"
fi
;;
restart|force-reload)
${0} stop
${0} start
;;
*)
echo "Usage: /etc/init.d/redis {start|stop|restart|force-reload}" >&2
exit 1
esac
```
6、 启动redis 关闭redis 服务
- 尝试启动或停止redis
service redis start
service redis stop
- 开启服务自启动
chkconfig redis on

## 安装activeMQ
1. 解压 activeMQ
tar -zxvf apache-activemq-5.14.0-bin.tar.gz
2. 复制activeMQ 到 usr目录
mv apache-activemq-5.14.0 /usr
3. 进入activeMQ的bin目录
./activemq start
4. 查看端口 是否启动
netstat -an | grep 61616
5. 创建链接 ln -s /usr/apache-activemq-5.14.0/ /usr/activemq
6. 复制启动文件 cp /usr/activemq/bin/activemq /etc/init.d
7. 编辑 /etc/init.d/activemq

在第二行添加

```
#### BEGIN INIT INFO
# Provides: activemq
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 6
# chkconfig: 2345 64 36
# Short-Description: ActiveMQ server
### END INIT INFO
```

在最后一个#后添加

```
export JAVA_HOME=/usr/jdk
ACTIVEMQ_HOME=/usr/activemq
```
8. 添加到系统服务
chkconfig --add activemq
chkconfig activemq on

## 安装elasticSearch
1. 解压 tar -zxvf elasticsearch-2.4.0.tar.gz
2. 移动到usr目录 mv elasticsearch-2.4.0/ /usr/
3. 改名为elasticsearch: mv elasticsearch-2.4.0 elasticsearch
4. 运行elasticSearch
/usr/elasticsearch/bin/elasticsearch -d
`使用root运行 -Des.insecure.allow.root=true`
5. 外网访问
修改配置文件 config/elasticsearch.yml
network.host: 0.0.0.0
6. 安装 es head插件
进入bin目录
./plugin install mobz/elasticsearch-head
7. 安装ik分词器
rz 上传 elasticsearch-analysis-ik-2.x.zip
- 进入target/release目录
拷贝文件到 %es%/plugins/analysis-ik
`cp -r ./ /usr/elasticsearch/plugins/analysis-ik/`
- 进入target/release/config 目录
将所有配置文件,复制 %es%/config 下
`cp -r ./ /usr/elasticsearch/config/ `
- 配置elasticsearch.yml
加入 index.analysis.analyzer.ik.type: "ik"
- 访问
http://ip:9200/_analyze?analyzer=ik&pretty=true&text=我是中国人

8. 服务自启动
进入/etc/init.d 编写脚本
vi elasticsearch

```
#!/bin/bash
#chkconfig:2345 80 05
#description:elasticsearch service
RETVAL=0
start(){
export JAVA_HOME=/usr/jdk
echo -n "start elasticsearch"
cd /usr/elasticsearch/
bin/elasticsearch -d -Des.insecure.allow.root=true
}
stop(){
echo "elasticsearch service is stoped..."
}
case $1 in
start)
start
;;
stop)
stop
;;
esac
exit $RETVAL
```
8. 添加到系统服务
chkconfig --add elasticsearch
chkconfig elasticsearch on

## Oracle 错误
- ORA-01089: immediate shutdown in progress - no operations are permitted
今天shutdown immediate关数据库的时候出现ORA-01089: immediate shutdown in progress - no operations are permitted的错误。
ps -ef|grep ora_发现oracle的各个后台进程仍然在运行着,说明数据库没有关闭成功。
解决方法如下:
先exit退出,重新登录:
[oracle@localhost trace]$ sqlplus /nolog
SQL>conn /as sysdba
Connected to an idle instance.
接着,使用shutdown abort强制关闭数据库:
SQL>shutdown abort;
ORACLE instance shut down.
最后,使用startup force打开数据库:
SQL>startup force;
ORACLE instance started.

Total System Global Area 849530880 bytes
Fixed Size 1339824 bytes
Variable Size 641732176 bytes
Database Buffers 201326592 bytes
Redo Buffers 5132288 bytes
Database mounted.
Database opened.

打开数据库之后,再次使用shutdown immediate关闭数据库:
SQL>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
问题解决。

- ORA-00020:maximum number of processes (150) exceeded 错误解决方法
SQL> conn sys/123456 as sysdba ;
SQL> show parameter processes;
NAME TYPE VALUE
--
aq_tm_processes integer 1
db_writer_processes integer 1
job_queue_processes integer 10
log_archive_max_processes integer 1
processes integer 150

一看怎么已经改了,依然是150,后来通过网上看到,单纯的改配置文件无效,而后就通过以下sql进行了修改

SQL> alter system set processes=500 scope = spfile;

done;

SQL> create pfile from spfile;

done;

这里执行时间有可能会提示权限不足,这个时间用dba权限即可

然后重启数据库,再次show,已经修改成了500

猜你喜欢

转载自www.cnblogs.com/onlyxiu/p/9216978.html