开源组件部署
jdk1.8.0_141及以上
tomcat 7.0.45及以上9以下
nginx 1.12.1
mongoDb 3.4.6
mysql 5.6.37
elasticsearch 5.4.2
一、安装软件
jdk1.8.0_141
1.jdk压缩包放到 /work 下 解压 tar -zxvf jdk-8u141-linux-x64.tar.gz
2.设置环境变量
vim /etc/profile 在最下面 添加
JAVA_HOME=/work/jdk1.8.0_141
PATH=$JAVA_HOME/bin:$PATH
CLASSPATH=$JAVA_HOME/jre/lib/ext:$JAVA_HOME/lib/toos.jar
export PATH JAVA_HOME CLASSPATH
3.执行命令 source /etc/profile 使设置生效
4.java -version 查看安装是否成功
tomcat 7.0.85
1.tomcat 压缩包放到 /work 下 解压 tar -zxvf apache-tomcat-7.0.85.tar.gz
2.启动 tomcat 执行./work/tomcat/bin/startup.sh
3.访问127.0.0.1:8080 是否安装成功
4.关闭tomcat /work/tomcat/bin/shutdown.sh
nginx 1.12.2
1.nginx 压缩包放到 /work下 解压并安装
vi /etc/resolv.conf
nameserver 223.5.5.5
cd /etc/yum.repos.d
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
yum install nginx
systemctl stop firewalld.service
2.启动nginx systemctl start nginx.service
3.访问127.0.0.1 是否安装成功
4.修改配置文件/etc/nginx/conf.d/default.conf 如下配置
此处存放目录为:
/work/nginx/console/index.html
/work/nginx/hut/index.html
upstream url{
server 127.0.0.1:8080;
}
server {
listen 80;
server_name localhost;
root /work/nginx;
location ^~ /console {
proxy_pass http://url;
}
location /html {
index index.html;
}
}
5.重启nginx systemctl restart nginx.service
6.注意,要求关闭selinux
setenforce 0
可以用 getenforce 命令来检查
mongoDb 3.4.6
1.mongoDb 压缩包放到 /work 下 解压 tar -zxvf mongodb-linux-x86_64-rhel70-3.4.6.tar.gz
2.新建配置文件mongodb.cnf
#Where to store the data.
dbpath=/work/mongodb-linux-x86_64-rhel70-3.4.6/data
#where to log
logpath=/work/mongodb-linux-x86_64-rhel70-3.4.6/mongodb.log
logappend=true
bind_ip=127.0.0.1
port=19130
3.新建文件
mkdir /work/mongodb-linux-x86_64-rhel70-3.4.6/data
touch /work/mongodb-linux-x86_64-rhel70-3.4.6/mongodb.log
4.启动 ./mongod -f ../mongodb.cnf --fork,注意mongod在mongo目录的bin下
mysql 5.6
1.下载并安装MySQL包 5.6 版本文件
wget http://repo.mysql.com/mysql-community-release-el6-5.noarch.rpm
2.yum安装
yum -y install mysql-community-release-el6-5.noarch.rpm
yum -y install mysql-community-server
3.MySQL数据库设置
首先启动MySQL `systemctl start mysqld.service`
查看MySQL运行状态,运行状态如图:systemctl status mysqld.service
此时MySQL已经开始正常运行,不过要想进入MySQL还得先找出此时root用户的密码,通过如下命令可以在日志文件中找出密码:`grep "password" /var/log/mysqld.log`
如下命令进入数据库:mysql -u root -p
输入初始密码,此时不能做任何事情,因为MySQL默认必须修改密码之后才能操作数据库:
set password for root@localhost=password('root');
FLUSH PRIVILEGES;
4.执行数据schema初始化
数据库 mydb
create database mydb
use mydb
source /work/install/sql/db.sql
elasticsearch 5.4.2
1.elasticsearch 压缩包放到 /work 下 解压 tar -zxvf elasticsearch-5.4.2.tar.gz
2.解压elasticsearch-analysis-ik-5.4.2.zip 放到 安装目录的 plugins/ik
3.如果是以root用户登录并执行的上述命令,则会看到的错误提示需要新建用户 命令如下
useradd elasearch
修改文件所有用户chown -R elasearch /work/elasticsearch-5.4.2/
4.启动
su elasearch
./bin/elasticsearch &
5.elasticsearch的库
特别注意,elasticsearch配置:
/work/elasticsearch-5.4.2/config/elasticsearch.yml
添加
network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
bootstrap.system_call_filter: false
es默认集群名字为cluster.name: my-application
在内网连通的情况下会自动寻找集群
测试es开启的时候,一定要指定一个与默认cluster.name不一致的名字
6.注意问题
修改以下错误需切换root用户
错误1: max number of threads [1024] for user [elasearch] is too low, increase to at least [2048]
添加或修改 /etc/security/limits.d/90-nproc.conf 中下面这句话
* softnproc 4096
错误2:max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
执行 在/etc/sysctl.conf 最后一行添加 vm.max_map_count=262144
错误3:max file descriptors [65535] for elasticsearch process likely too low, increase to at least [65536]
执行 ulimit -n 65536
错误4 :system call bootstrap.system_call_filter: false
添加 vim /etc/security/limits.conf
soft memlock unlimited
hard memlock unlimited
错误5 :max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
执行 cp /etc/security/limits.conf /etc/security/limits.conf.bak
cat /etc/security/limits.conf | grep -v "elasearch" > /tmp/system_limits.conf
echo "elasearch hard nofile 65536" >> /tmp/system_limits.conf
echo "elasearch soft nofile 65536" >> /tmp/system_limits.conf
mv /tmp/system_limits.conf /etc/security/limits.conf