liunx jdk tomcat mysql nginx_linux jdk tomcat mysql nginx 安装配置.txt

centos6.3 64位

jdk-8u60-linux-x64.tar.gz

MySQL-server-5.5.46-1.el6.x86_64.rpm

MySQL-client-5.5.46-1.el6.x86_64.rpm

MySQL-devel-5.5.46-1.el6.x86_64.rpm

---------

MySQL-server-5.6.13-1.el6.x86_64.rpm

MySQL-client-5.6.13-1.el6.x86_64.rpm

MySQL-devel-5.6.13-1.el6.x86_64.rpm

---------

redhat 5

MySQL-server-5.6.13-1.rhel5.x86_64.rpm

MySQL-client-5.6.13-1.rhel5.x86_64.rpm

MySQL-devel-5.6.13-1.rhel5.x86_64.rpm

apache-tomcat-8.0.26.tar.gz

nginx-1.11.9.tar.gz

openssl-fips-2.0.9.tar.gz

pcre-8.40.tar.gz

zlib-1.2.11.tar.gz

安装vim编辑器

yum install vim

创建www目录

mkdir www

uname -a 查看cpu位数

一.安装jdk

1.rpm -qa|grep java

2.tar -zxvf jdk-8u60-linux-x64.tar.gz

3.增加JAVA_HOME环境变量

vim /etc/profile

在最后面增加:

#set java environment

JAVA_HOME=/www/java/jdk1.8.0_60

PATH=$JAVA_HOME/bin:$PATH

CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

export JAVA_HOME CLASSPATH PATH

保存退出

使得刚刚添加到环境变量生效:

source /etc/profile

ln -s -f /www/java/jdk1.8.0_60/jre/bin/java /usr/bin/java

ln -s -f /www/java/jdk1.8.0_60/bin/javac /usr/bin/javac

#c.进入 /usr/bin/目录

#cd /usr/bin

#ln -s -f /www/java/jdk1.8.0_60/jre/bin/java /usr/bin/java

#ln -s -f /www/java/jdk1.8.0_60/bin/javac /usr/bin/javac

二、安装mysql

1.rpm -Uvh MySQL-server-5.5.46-1.el6.x86_64.rpm MySQL-client-5.5.46-1.el6.x86_64.rpm MySQL-devel-5.5.46-1.el6.x86_64.rpm

2.增加开机启动服务

chkconfig --list | grep mysql

chkconfig --level 35 mysqld on

service mysqld start

netstat -nat

3.修改密码并授权

/usr/bin/mysqladmin -u root password 'developer'

4.检查安全性

/usr/bin/mysql_secure_installation

5.授权

mysql -u root -p

use mysql;

创建用户:create user 'master'@'%' identified by 'test';

授权用户:grant all on *.* to 'master'@'%' identified by 'test';

刷新权限:flush privileges;

#GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'developer' WITH GRANT OPTION; //授权远程登陆

#【GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'developer' 这样不能给别的用户授权】

#FLUSH PRIVILEGES;//重载授权表:

#SHOW VARIABLES WHERE Variable_name LIKE 'character\_set\_%' OR Variable_name LIKE 'collation%';

show engines;

show variables like 'chara%';

撤销授权

REVOKE privilege ON databasename.tablename FROM 'username'@'host';

6.增加防火墙端口允许

vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

重启防火墙

/etc/init.d/iptables restart

7.配置my.cnf

cp usr/share/mysql/my-small.cnf /etc/my.cnf

vim /etc/my.cnf 配置文件

[client]

default-character-set=utf8

[mysql]

default-character-set = utf8

[mysqld]

character_set_server=utf8

collation-server=utf8_general_ci

lower_case_table_names=1

character_set_client=utf8

备份:/etc/crontab,/usr/local/sbin/sql_bak.sh,chmod 744 sql_bak.sh,重启生效 service crond restart

注意:centos7.3 在安装完成后要执行 mysqld --initialize --user=mysql

**************************************************************************************************************

redhat:mysql 5.7.18

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

# Disabling symbolic-links is recommended to prevent assorted security risks

symbolic-links=0

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

user = mysql

port = 3306

server_id = 1

character-set-server=utf8

collation-server=utf8_general_ci

lower_case_table_names=1 #忽略大小写

[client]

default-character-set=utf8

[mysql]

default-character-set = utf8

**************************************************************************************************************

7.service mysqld restart

三、安装tomcat

1.解压

tar -zxvf apache-tomcat-8.0.26.tar.gz

2.添加必要包

tomcat/lib 里添加 mysql-connector-java-5.1.7-bin.jar

3.配置tomcat /bin/catalina.sh 参数

export JAVA_OPTS="-Xms256m -Xmx512m -Xss1024K"

#export JAVA_OPTS="-server -Xms1024M -Xmx1024M -Xss1024k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:PermSize=256M -XX:MaxPermSize=512M -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=31 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true"

tomcat8 优化:

export CATALINA_OPTS="-server -Xms1024M -Xmx1024M -Xss1024k -XX:+AggressiveOpts -XX:+UseBiasedLocking -XX:+DisableExplicitGC -XX:MaxTenuringThreshold=8 -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -Djava.awt.headless=true"

4.添加service

ln -s /www/tomcat/bin/startup.sh /etc/init.d/tomcat8

chmod +x /etc/init.d/tomcat8

vim /etc/init.d/tomcat8

:set ff=unix

#chkconfig --add tomcat8

#chkconfig --level 35 tomcat8 on

service tomcat8 start 启动

chkconfig --del tomcat8 //删除

debug.sh

#!/bin/sh

JPDA_ADDRESS="0.0.0.0:8000"

export JPDA_ADDRESS

echo " debug : $JPDA_ADDRESS"

set -m

/data/www/server/apache-tomcat-8.5.49/bin/./catalina.sh jpda start

tail -f /data/www/server/apache-tomcat-8.5.49/logs/catalina.out

四、安装nginx

http://nginx.org/en/linux_packages.html#RHEL-CentOS

以下安装作废:

1.下载相关包

下载nginx: wget http://nginx.org/download/nginx-1.11.9.tar.gz

下载openssl : wget http://www.openssl.org/source/openssl-fips-2.0.9.tar.gz

下载zlib : wget http://zlib.net/zlib-1.2.11.tar.gz

下载pcre : #wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

wget https://jaist.dl.sourceforge.net/project/pcre/pcre/8.44/pcre-8.44.tar.gz

如果没有安装c++编译环境,还得安装,通过yum install gcc-c++完成安装

2.编译安装

安装openssl :

tar zxvf openssl-fips-2.0.9.tar.gz

cd openssl-fips-2.0.9

./config && make && make install

安装pcre:

tar zxvf pcre-8.40.tar.gz

cd pcre-8.40

./configure && make && make install

安装zlib:

tar zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure && make && make install

安装nginx

tar zxvf nginx-1.11.9.tar.gz

cd nginx-1.11.9

# ./configure --with-http_ssl_module && make && make install

./configure && make && make install

启动nginx

/usr/local/nginx/sbin/nginx

出现错误提示

error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

原因

在RedHat 64位机器上nginx读取的pcre文件为/lib64/libpcre.so.1文件,默认安装pcre时libpcre.so文件安装在/usr/local/lib/目录下,所以输入/opt/nginx/sbin/nginx -V 找不到文件路径!!

解决办法

1.首先确定安装了pcre.

2.root权限下添加软链接 /usr/local/lib/libpcre.so.1 到 /lib64/

ln -s /usr/local/lib/libpcre.so.1 /lib64/

如果是32位机器启动时报错:

error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

解决办法

ln -s /usr/local/lib/libpcre.so.1 /lib

3.增加service

写脚本加入service

#ln -s /usr/local/nginx/sbin/nginx /etc/init.d/nginx

4.增加防火墙例外

vim /etc/sysconfig/iptables

-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT

重启防火墙

service iptables start

或者

/etc/init.d/iptables restart

五、时间设置

修改时间,与客户端时间一致

date

tzselect

mv /etc/localtime /etc/localtime.bak

cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

date

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

六、redhat 系统 安装mysql

1.RPM包下载地址:

http://dev.mysql.com/downloads/repo/yum/

wget https://repo.mysql.com//mysql57-community-release-el5-8.noarch.rpm

2.安装

rpm -Uvh mysql57-community-release-el5-8.noarch.rpm

2.1、选择要安装的MySQL版本

2.2、安装MySQL,默认安装的版本是5.7,所以不需要做任何的修改

yum -y install mysql-community-server

2.3、安装其他版本,假如你想安装MySQL5.6或者其他版本,需要修改 /etc/yum.repos.d/mysql-community.repo文件。

vi /etc/yum.repos.d/mysql-community.repo

将[mysql57-community]内的enabled=1修改为enabled=0

将[mysql56-community]内的enabled=0修改为enabled=1

保存并退出

然后再执行 yum -y install mysql-community-server 安装的版本就是MySQL5.6了,选择MySQL5.5或者MySQL8.0的方法一样,

把要选择的版本的[mysqlXX-community]下面的enabled=0改为enabled=1,不需要的版本的[mysqlXX-community]下面的enabled=1改为enabled=0,

然后再执行yum -y install mysql-community-server安装。

3、启动MySQL服务

3.1service mysqld start

3.2、查看MySQL状态

service mysqld status

3.3、安装其他MySQL产品和组件

yum --disablerepo=\* --enablerepo='mysql*-community*' list available

yum install package-name #package-name 为你选择要安装的包名如:mysql-community-client

4、密码

对于MySQL5.7版本,系统初始化之后会生成root账户的密码,保存在日志文件里,使用grep 'temporary password' /var/log/mysqld.log 查看初始密码,

MySQL5.7的密码要求至少包含一个大写字母,一个小写字母,一个数字和一个特殊字符,并且总密码长度至少为8个字符。

mysql -uroot -p

输入你上面查看到的初始密码

ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';

修改root@localhost账户的密码为MyNewPass4!

七:crontab 定时备份

1.进入 /usr/local/sbin

2.写脚本文件 db.sh

#!/bin/sh

###############################

#此脚本用来全量备份

###############################

#设置用户名和密码

v_host="数据库IP"

v_port="数据库端口"

v_user="数据库用户名"

v_password="数据库密码"

#mysql安装全路径

MysqlDir=/usr/local/mysql/bin

#备份数据库

database="数据库"

#设置备份路径,创建备份文件夹

BackupDir=/www/Mysql_Backup

Full_Backup=$BackupDir/$database

mkdir -p $Full_Backup/$(date +%Y%m%d)

#开始备份,记录备份开始时间

echo '=========='$(date +"%Y-%m-%d %H:%M:%S")'=========='"备份开始">>$Full_Backup/$database.log

$MysqlDir/mysqldump -h$v_host -P$v_port -u$v_user -p$v_password --single-transaction --flush-logs --databases $database>$Full_Backup/$(date +%Y%m%d)/$database.sql

#压缩备份文件

gzip $Full_Backup/$(date +%Y%m%d)/$database.sql

echo '=========='$(date +"%Y-%m-%d %H:%M:%S")'=========='"备份完成">>$Full_Backup/$database.log

3.将脚本加入crontab

crontab -e

#表示每天10:07分执行

07 10 * * * /usr/local/sbin/db.sh >> /www/mysqlBak.log 2>&1

crontab -l 查看任务

4.重启crontab

service crond restart

5.查看日志

cd /var/log

vim cron

一键复制

编辑

Web IDE

原始数据

按行查看

历史

已标记关键词 清除标记
表情包
插入表情
评论将由博主筛选后显示,对所有人可见 | 还能输入1000个字符
相关推荐
©️2020 CSDN 皮肤主题: 深蓝海洋 设计师:CSDN官方博客 返回首页