一、安装前的准备
1、Linux端创建存放软件的文件夹
2、使用Xftp工具将软件上传
3、温馨提示(编辑文件的操作)
1、使用vim filename(文件名)编辑文件
2、查找关键字,vim编辑并打开文件后,在命令行或文件内容任意地方输入“/关键字”,例如:/daemonize + enter(回车键) → 若没有找到“daemonize”关键字,则继续按enter(回车键)
3、按i字母键进入编辑模式,上、下键进行移动
4、按esc键,退出编辑模式
5、按Shift键 + : (冒号)键 + w字母键 + q字母键 + ! (感叹号)键,保存并退出
二、安装JDK软件(/*注释的文字为提示*/
不要复制 )
1、Linux端安装JDK软件
1.1 将JDK解压到/usr/local/文件目录下
[ root@localhost / ] # cd / software `/*去software文件夹*/`
[ root@localhost software] # ll `/*查看文件*/`
总用量 193412
- rw- r-- r-- . 1 root root 9625824 9 月 10 14 : 18 apache- tomcat- 8.5 .34 . tar. gz
- rw- r-- r-- . 1 root root 185646832 9 月 10 14 : 19 jdk- 8 u181- linux- x64. tar. gz
- rw- r-- r-- . 1 root root 1032630 9 月 10 14 : 19 nginx- 1.16 .1 . tar. gz
- rw- r-- r-- . 1 root root 1739656 9 月 10 14 : 19 redis- 4.0 .11 . tar. gz
[ root@localhost software] # tar - zxvf jdk- 8 u181- linux- x64. tar. gz - C / usr/ local/ `/*将JDK解压到/usr/local/目录下*/`
1.2 去到JDK解压后的文件目录下
[ root@localhost software] # cd / usr/ local/ `/*去到JDK解压后的文件目录下*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 0
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk1. 8.0 _181 `/*解压后的JDK文件夹*/`
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
1.3 将jdk1.8.0_181文件夹名称重命名为jdk
[ root@localhost local] # mv jdk1. 8.0 _181 jdk `/*将jdk1.8.0_181文件夹名称重命名为jdk*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 0
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk `/*重命名后的文件夹*/`
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
2、配置Linux的JDK环境变量
2.1 编辑/etc/目录下的profile环境变量配置文件
[ root@localhost local] # vim / etc/ profile `/*编辑/etc/目录下的profile*/`
2.2 profile文件,配置Linux的JDK环境(需要添加的内容在 unset -f pathmunge 下面
)
# / etc/ profile
# System wide environment and startup programs, for login setup
# Functions and aliases go in / etc/ bashrc
# It's NOT a good idea to change this file unless you know what you
# are doing. It's much better to create a custom. sh shell script in
# / etc/ profile. d/ to make custom changes to your environment, as this
# will prevent the need for merging in future updates.
pathmunge ( ) {
case ":${PATH}:" in
* : "$1" : * )
; ;
* )
if [ "$2" = "after" ] ; then
PATH = $PATH : $1
else
PATH = $1 : $PATH
fi
esac
}
if [ - x / usr/ bin/ id ] ; then
if [ - z "$EUID" ] ; then
# ksh workaround
EUID = `/usr/bin/id -u`
UID = `/usr/bin/id -ru`
fi
USER = "`/usr/bin/id -un`"
LOGNAME = $USER
MAIL = "/var/spool/mail/$USER"
fi
# Path manipulation
if [ "$EUID" = "0" ] ; then
pathmunge / usr/ sbin
pathmunge / usr/ local/ sbin
HOSTNAME = `/usr/bin/hostname 2>/dev/null`
HISTSIZE = 1000
if [ "$HISTCONTROL" = "ignorespace" ] ; then
export HISTCONTROL = ignoreboth
else
export HISTCONTROL = ignoredups
fi
export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL
# By default , we want umask to get set . This sets it for login shell
# Current threshold for system reserved uid/ gids is 200
# You could check uidgid reservation validity in
# / usr/ share/ doc/ setup- * / uidgid file
if [ $UID - gt 199 ] && [ "`/usr/bin/id -gn`" = "`/usr/bin/id -un`" ] ; then
umask 002
else
umask 022
fi
for i in / etc/ profile. d`/*` . sh ; do
if [ - r "$i" ] ; then
if [ "${-#*i}" != "$-" ] ; then
. "$i"
else
. "$i" > / dev/ null
fi
fi
done
unset i
unset - f pathmunge
`/*按i字母键进入编辑模式,上、下键进行移动*/`
#set java environment ( 这里添加JDK 的环境变量)
JAVA_HOME = / usr/ local/ jdk
CLASSPATH = . : $JAVA_HOME / lib
PATH = $JAVA_HOME / bin: $PATH
export JAVA_HOME CLASSPATH PATH
`/*按esc键退出编辑模式*/`
`/*按Shift键 + : (冒号)键 + w字母键 + q字母键 + ! (感叹号)键,保存并退出*/`
: wq! `/*强制保存并退出*/`
2.3 重新加载环境变量配置文件
[ root@localhost local] # source / etc/ profile `/*使profile配置文件生效*/`
3、查看JDK是否安装成功(查看到下面信息,表示JDK已经安装成功
)
[ root@localhost local] # java - version `/*查看JDK的版本*/`
java version "1.8.0_181"
Java ( TM ) SE Runtime Environment ( build 1.8 .0 _181- b13)
Java HotSpot ( TM ) 64 - Bit Server VM ( build 25.181 - b13, mixed mode)
三、安装Tomcat软件(/*注释的文字为提示*/
不要复制 )
1、将Tomcat解压到/usr/local/文件目录下
[ root@localhost / ] # cd / software `/*去software文件夹*/`
[ root@localhost software] # ll `/*查看文件*/`
总用量 193412
- rw- r-- r-- . 1 root root 9625824 9 月 10 14 : 18 apache- tomcat- 8.5 .34 . tar. gz
- rw- r-- r-- . 1 root root 185646832 9 月 10 14 : 19 jdk- 8 u181- linux- x64. tar. gz
- rw- r-- r-- . 1 root root 1032630 9 月 10 14 : 19 nginx- 1.16 .1 . tar. gz
- rw- r-- r-- . 1 root root 1739656 9 月 10 14 : 19 redis- 4.0 .11 . tar. gz
[ root@localhost software] # tar - zvxf apache- tomcat- 8.5 .34 . tar. gz - C / usr/ local/ `/*将Tomcat解压到/usr/local/文件目录下*/`
2、去Tomcat解压后的/usr/local/目录下
[ root@localhost software] # cd / usr/ local/ `/*去到JDK解压后的文件目录下*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 0
drwxr- xr- x. 9 root root 220 9 月 10 19 : 09 apache- tomcat- 8.5 .34 `/*解压后的tomcat文件夹*/`
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
3、将apache-tomcat-8.5.34文件夹名称重命名为tomcat
[ root@localhost local] # mv apache- tomcat- 8.5 .34 tomcat `/*将apache-tomcat-8.5.34文件夹名称重命名为tomcat*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 0
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
drwxr- xr- x. 9 root root 220 9 月 10 19 : 09 tomcat `/*重命名后的tomcat文件夹*/`
4、 进入tomcat的bin目录,启动tomcat服务器
[ root@localhost local] # cd / usr/ local/ tomcat/ bin/ `/*进入tomcat的bin目录*/`
[ root@localhost bin] # ll `/*查看文件*/`
总用量 840
- rw- r-- -- - . 1 root root 34990 9 月 5 2018 bootstrap. jar
- rw- r-- -- - . 1 root root 15900 9 月 5 2018 catalina. bat
- rwxr- x-- - . 1 root root 23463 9 月 5 2018 catalina. sh
- rw- r-- -- - . 1 root root 1664 9 月 5 2018 catalina- tasks. xml
- rw- r-- -- - . 1 root root 25145 9 月 5 2018 commons- daemon. jar
- rw- r-- -- - . 1 root root 207125 9 月 5 2018 commons- daemon- native. tar. gz
- rw- r-- -- - . 1 root root 2040 9 月 5 2018 configtest. bat
- rwxr- x-- - . 1 root root 1922 9 月 5 2018 configtest. sh
- rwxr- x-- - . 1 root root 8508 9 月 5 2018 daemon. sh
- rw- r-- -- - . 1 root root 2091 9 月 5 2018 digest. bat
- rwxr- x-- - . 1 root root 1965 9 月 5 2018 digest. sh
- rw- r-- -- - . 1 root root 3460 9 月 5 2018 setclasspath. bat
- rwxr- x-- - . 1 root root 3680 9 月 5 2018 setclasspath. sh
- rw- r-- -- - . 1 root root 2020 9 月 5 2018 shutdown. bat
- rwxr- x-- - . 1 root root 1902 9 月 5 2018 shutdown. sh `/*关闭tomcat服务器的命令(./shutdown.sh)*/`
- rw- r-- -- - . 1 root root 2022 9 月 5 2018 startup. bat
- rwxr- x-- - . 1 root root 1904 9 月 5 2018 startup. sh `/*开启tomcat服务器的命令(./startup.sh)*/`
- rw- r-- -- - . 1 root root 49336 9 月 5 2018 tomcat- juli. jar
- rw- r-- -- - . 1 root root 408967 9 月 5 2018 tomcat- native. tar. gz
- rw- r-- -- - . 1 root root 4574 9 月 5 2018 tool- wrapper. bat
- rwxr- x-- - . 1 root root 5483 9 月 5 2018 tool- wrapper. sh
- rw- r-- -- - . 1 root root 2026 9 月 5 2018 version. bat
- rwxr- x-- - . 1 root root 1908 9 月 5 2018 version. sh `/*查看tomcat的版本*/`
[ root@localhost bin] # . / startup. sh `/*开启tomcat服务器*/`
5、开放Linux系统防火墙的8080端口
[ root@localhost bin] # firewall- cmd -- zone= public -- add- port= 8080 / tcp -- permanent `/*允许8080端口通过防火墙*/`
success `/*开放Linux系统防火墙的8080端口成功*/`
[ root@localhost bin] # systemctl restart firewalld `/*重新启动防火墙的服务*/`
6、在Windows系统上的Google Chrome浏览器访问tomcat服务器(看到成功访问tomcat服务器,表示tomcat服务器已安装成功
)
7、关闭tomcat服务器
[ root@localhost bin] # . / shutdown. sh `/*关闭tomcat服务器*/`
四、安装MySQL数据库(/*注释的文字为提示*/
不要复制 )
1、查看CentOS是否自带的mysql,如果已经安装需要卸载。如果没有找到,则表示没有安装。
[ root@localhost / ] # rpm - qa | grep mysql `/*查看mysql是否安装的命令*/`
2.、在线获取CentOS 7的mysql的rpm安装文件,执行下面的命令:
`/*在线获取CentOS 7的mysql的rpm安装文件*/`
[ root@localhost / ] # wget https: / / repo. mysql. com
-- 2019 - 09 - 10 20 : 15 : 49 -- https: / / repo. mysql. com
正在解析主机 repo. mysql. com ( repo. mysql. com) ... 104.75 .165 .42
正在连接 repo. mysql. com ( repo. mysql. com) | 104.75 .165 .42 | : 443. . . 已连接。
已发出 HTTP 请求,正在等待回应... 200 OK
长度:25820 ( 25 K) [ application/ x- redhat- package - manager]
正在保存至: “mysql80- community- release- el7- 1. noarch. rpm”
100 % [ === === === === === === === === === === === === === === === === === === === === === === === === === => ] 25 , 820 -- . - K / s 用时 0.04 s
2019 - 09 - 10 20 : 15 : 50 ( 626 KB / s) - 已保存 “mysql80- community- release- el7- 1. noarch. rpm” [ 25820 / 25820 ] )
3、执行安装的命令
[ root@localhost / ] # rpm - ivh mysql80- community- release- el7- 1. noarch. rpm `/*执行安装的命令*/`
警告:mysql80- community- release- el7- 1. noarch. rpm: 头V3 DSA / SHA1 Signature, 密钥 ID 5072e1 f5: NOKEY
准备中... ################################# [ 100 % ]
正在升级/ 安装...
1 : mysql80- community- release- el7- 1 ################################# [ 100 % ]
4、查看刚刚得到的两个配置文件(在/etc/yum.repos.d目录下
)
[ root@localhost / ] # cd / etc/ yum. repos. d `/*去/etc/yum.repos.d目录下*/`
[ root@localhost yum. repos. d] # ll `/*查看文件*/`
总用量 36
- rw- r-- r-- . 1 root root 1664 8 月 30 2017 CentOS- Base. repo
- rw- r-- r-- . 1 root root 1309 8 月 30 2017 CentOS- CR . repo
- rw- r-- r-- . 1 root root 649 8 月 30 2017 CentOS- Debuginfo. repo
- rw- r-- r-- . 1 root root 314 8 月 30 2017 CentOS- fasttrack. repo
- rw- r-- r-- . 1 root root 630 8 月 30 2017 CentOS- Media. repo
- rw- r-- r-- . 1 root root 1331 8 月 30 2017 CentOS- Sources. repo
- rw- r-- r-- . 1 root root 3830 8 月 30 2017 CentOS- Vault. repo
- rw- r-- r-- . 1 root root 1864 2 月 22 2018 mysql- community. repo `/*刚刚下载的文件1*/`
- rw- r-- r-- . 1 root root 1885 2 月 22 2018 mysql- community- source. repo `/*刚刚下载的文件2*/`
5. 编辑mysql-community.repo文件,配置资源库下载版本选择
5.1 编辑文件的命令
[ root@localhost yum. repos. d] # vim mysql- community. repo `/*编辑mysql-community.repo文件*/`
5.2 将mysql56-community中的enabled=0改为enabled=1(0表示不下载/1表示下载
)
[ mysql56- community]
name= MySQL 5.6 Community Server
baseurl= http: / / repo. mysql. com/ yum/ mysql- 5.6 - community/ el/ 7 / $basearch/
enabled= 1 `/*将enabled=0改为enabled=1(0表示不下载/1表示下载)*/`
gpgcheck= 1
gpgkey= file: /
5.3 将mysql80-community中的enabled=1改为enabled=0(0表示不下载/1表示下载
)
[ mysql80- community]
name= MySQL 8.0 Community Server
baseurl= http: / / repo. mysql. com/ yum/ mysql- 8.0 - community/ el/ 7 / $basearch/
enabled= 0 `/*将enabled=1改为enabled=0(0表示不下载/1表示下载)*/`
gpgcheck= 1
gpgkey= file: /
5.4 执行上文温馨提示中的4、5步骤保存并退出
6、下载安装客户端、服务器端、工具包
6.1 执行安装的命令
[ root@localhost yum. repos. d] # cd / `/*去根目录执行安装的命令*/`
[ root@localhost / ] # yum - y install mysql- community- client mysql- community- server mysqlcommunity- devel
6.2 安装后的效果
已安装:
mysql- community- client. x86_64 0 : 5.6 .45 - 2. el7 mysql- community- libs. x86_64 0 : 5.6 .45 - 2. el7
mysql- community- server. x86_64 0 : 5.6 .45 - 2. el7
作为依赖被安装:
mysql- community- common. x86_64 0 : 5.6 .45 - 2. el7 perl- Compress- Raw- Bzip2. x86_64 0 : 2.061 - 3. el7
perl- Compress- Raw- Zlib. x86_64 1 : 2.061 - 4. el7 perl- DBI . x86_64 0 : 1.627 - 4. el7
perl- IO - Compress. noarch 0 : 2.061 - 2. el7 perl- Net- Daemon. noarch 0 : 0.48 - 5. el7
perl- PlRPC. noarch 0 : 0.2020 - 14. el7
替代:
mariadb- libs. x86_64 1 : 5.5 .56 - 2. el7
完毕!
6.3 启动MySQL的服务
[ root@localhost / ] # systemctl start mysqld `/*启动mysql的服务*/`
6.4 将mysql添加加到系统服务中并设置开机启动
[ root@localhost / ] # systemctl enable mysqld `/*设置MySQL服务开机启动*/`
6.5 登录mysql账户,root用户默认没有密码
[ root@localhost/ ] # mysql - uroot `/*登录MySQL账户*/`
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.6 .45 MySQL Community Server ( GPL )
Copyright ( c) 2000 , 2019 , Oracle and/ or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/ or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
6.6 在mysql中修改自己的密码
mysql> set password = password ( 'root' ) ; `/*修改密码*/`
Query OK , 0 rows affected ( 0.06 sec)
6.7 设置远程连接权限、开发端口号
mysql> grant all privileges on * . * to 'root' @'%' identified by 'root' ; `/*远程连接授权*/`
Query OK , 0 rows affected ( 0.00 sec)
6.8 刷新权限缓存,并退出
mysql> flush privileges; `/*刷信息权限缓存*/`
Query OK , 0 rows affected ( 0.00 sec)
mysql> exit `/*退出*/`
Bye `/*回应“拜拜”*/`
6.9 开放Linux的对外访问的MySQL端口3306
[ root@bogon / ] # firewall- cmd -- zone= public -- add- port= 3306 / tcp -- permanent `/*开放3306端口号*/`
success `/*成功*/`
6.10 重新启动防火墙服务
[ root@localhost / ] # systemctl restart firewalld
7 在Windows系统上的SQLyogEnt客户端访问MySQL数据库(看到成功访问tomcat服务器,表示tomcat服务器已安装成功
)
7.1 点击“新建” → 输入“新连接名称” → 点击“确定” → 选择“新创建的连接名” → 输入Linux终端的IP地址 → 输入“用户名” → 输入“密码” → 点击“连接” → 点击“是” → Linux终端成功连接数据库(表示Linux终端上的MySQL数据库安装成功
)
五、安装Redis软件(/*注释的文字为提示*/
不要复制 )
1、将redis解压到/usr/local/文件目录下
[ root@localhost / ] # cd / software `/*去software文件下*/`
[ root@localhost software] # ll `/*查看文件*/`
总用量 193440
- rw- r-- r-- . 1 root root 9625824 9 月 10 14 : 18 apache- tomcat- 8.5 .34 . tar. gz
- rw- r-- r-- . 1 root root 185646832 9 月 10 14 : 19 jdk- 8 u181- linux- x64. tar. gz
- rw- r-- r-- . 1 root root 25820 9 月 10 21 : 28 mysql80- community- release- el7- 1. noarch. rpm
- rw- r-- r-- . 1 root root 1032630 9 月 10 14 : 19 nginx- 1.16 .1 . tar. gz
- rw- r-- r-- . 1 root root 1739656 9 月 10 14 : 19 redis- 4.0 .11 . tar. gz
[ root@localhost software] # tar - zxvf redis- 4.0 .11 . tar. gz - C / usr/ local/ `/*将redis解压到/usr/local/文件目录下*/`
2、从官方下载Linux版本,redis是c语言源代码,需要下载编译器进行编译之后再安装
[ root@localhost software] # cd / `/*去根目录下*/`
[ root@localhost / ] # yum - y install gcc- c++ `/*需要C++预编译环境*/`
3、C++预编译环境安装的效果
更新完毕:
gcc- c++ . x86_64 0 : 4.8 .5 - 36. el7_6. 2
作为依赖被升级:
cpp. x86_64 0 : 4.8 .5 - 36. el7_6. 2 gcc. x86_64 0 : 4.8 .5 - 36. el7_6. 2
gcc- gfortran. x86_64 0 : 4.8 .5 - 36. el7_6. 2 libgcc. x86_64 0 : 4.8 .5 - 36. el7_6. 2
libgfortran. x86_64 0 : 4.8 .5 - 36. el7_6. 2 libgomp. x86_64 0 : 4.8 .5 - 36. el7_6. 2
libquadmath. x86_64 0 : 4.8 .5 - 36. el7_6. 2 libquadmath- devel. x86_64 0 : 4.8 .5 - 36. el7_6. 2
libstdc++ . x86_64 0 : 4.8 .5 - 36. el7_6. 2 libstdc++ - devel. x86_64 0 : 4.8 .5 - 36. el7_6. 2
完毕!
4、去redis解压后的目录下
[ root@localhost / ] # cd / usr/ local/ `/*去redis解压后的目录下*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 4
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxrwxr- x. 6 root root 4096 8 月 4 2018 redis- 4.0 .11
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
drwxr- xr- x. 9 root root 220 9 月 10 19 : 09 tomcat
5、将redis-4.0.11文件夹名称重命名为redis
[ root@localhost local] # mv redis- 4.0 .11 redis `/*将redis-4.0.11文件夹名称重命名为redis*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 4
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxrwxr- x. 6 root root 4096 8 月 4 2018 redis `/*重命名后的文件夹*/`
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
drwxr- xr- x. 9 root root 220 9 月 10 19 : 09 tomcat
6、进入/usr/local/redis目录下,执行make命令,用于编译c语言源代码
[ root@localhost local] # cd / usr/ local/ redis/ `/*进入/usr/local/redis目录下*/`
[ root@localhost redis] # make `/*执行编译命令*/`
make[ 1 ] : 离开目录“/ usr/ local/ redis/ src” `/*安装效果*/`
7、执行安装的命令
[ root@localhost redis] # make PREFIX = / usr/ local/ redis install `/*执行安装命令*/`
cd src && make install
make[ 1 ] : 进入目录“/ usr/ local/ redis/ src”
CC Makefile. dep
make[ 1 ] : 离开目录“/ usr/ local/ redis/ src”
make[ 1 ] : 进入目录“/ usr/ local/ redis/ src”
Hint: It's a good idea to run ' make test' ; )
INSTALL install
INSTALL install
INSTALL install
INSTALL install
INSTALL install
make[ 1 ] : 离开目录“/ usr/ local/ redis/ src”
8、安装好的文件结构
[ root@localhost bin] # pwd `/*查看当前路径*/`
/ usr/ local/ redis/ bin
[ root@bogon bin] # ll `/*查看文件*/`
总用量 21888
- rwxr- xr- x. 1 root root 2451688 9 月 11 02 : 04 redis- benchmark
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- aof
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- rdb
- rwxr- xr- x. 1 root root 2617768 9 月 11 02 : 04 redis- cli
lrwxrwxrwx. 1 root root 12 9 月 11 02 : 04 redis- sentinel - > redis- server
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- server
9、后端模式启动redis
9.1 将源代码目录中/usr/local/redis/redis.conf复制到当前安装bin目录下
[ root@localhost bin] # cp / usr/ local/ redis/ redis. conf . / `/*将源代码目录中/usr/local/redis/redis.conf复制到当前安装bin目录下*/`
9.2 修改redis.conf配置文件内容,让其支持后端启动(编辑及操作文件看上文的温馨提示)
[ root@localhost bin] # vim redis. conf `/*编辑redis.conf配置文件*/`
################################# GENERAL #####################################
# By default Redis does not run as a daemon. Use 'yes' if you need it.
# Note that Redis will write a pid file in / var / run/ redis. pid when daemonized.
daemonize yes `/*daemonize no 修改为 daemonize yes(保存并退出,操作文件看上文的温馨提示)*/`
9.3 以后端方式启动服务器,必须指明redis.conf进行启动
[ root@localhost bin] # . / redis- server redis. conf
9.4 启动客户端
[ root@localhost bin] # ll `/*查看文件*/`
总用量 21948
- rwxr- xr- x. 1 root root 2451688 9 月 11 02 : 04 redis- benchmark
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- aof
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- rdb
- rwxr- xr- x. 1 root root 2617768 9 月 11 02 : 04 redis- cli
- rw- r-- r-- . 1 root root 58767 9 月 11 03 : 01 redis. conf
lrwxrwxrwx. 1 root root 12 9 月 11 02 : 04 redis- sentinel - > redis- server
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- server
[ root@localhost bin] # . / redis- cli `/*启动客户端的命令*/`
9.5 redis操作存储数据
127.0 .0 .1 : 6379 > set name zhangsan `/*添加数据*/`
OK
127.0 .0 .1 : 6379 > set name lisi `/*修改数据(将“zhangsan”修改为"lisi")*/`
OK
127.0 .0 .1 : 6379 > get name `/*获取neme(key)的值*/`
"zhangsan"
127.0 .0 .1 : 6379 > del name `/*删除name(key)的值*/`
( integer) 1
127.0 .0 .1 : 6379 > exit `/*退出*/`
9.6 关闭客户端
[ root@localhost bin] # ll `/*查看文件*/`
总用量 21952
- rw- r-- r-- . 1 root root 109 9 月 11 03 : 26 dump. rdb
- rwxr- xr- x. 1 root root 2451688 9 月 11 02 : 04 redis- benchmark
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- aof
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- rdb
- rwxr- xr- x. 1 root root 2617768 9 月 11 02 : 04 redis- cli
- rw- r-- r-- . 1 root root 58767 9 月 11 03 : 01 redis. conf
lrwxrwxrwx. 1 root root 12 9 月 11 02 : 04 redis- sentinel - > redis- server
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- server
[ root@localhost bin] # . / redis- cli shutdown `/*关闭客户端*/`
10、在Windows的RedisDesktopManager(Redis客户端
)访问Linux终端的Redis
10.1 测试Redis客户端是否可以远程连接Linux终端的Redis服务器
10.2 在Linux终端开放端口6379
[ root@localhost bin] # / sbin/ iptables - I INPUT - p tcp -- dport 6379 - j ACCEPT `/*开放端口6379*/`
[ root@localhost bin] # firewall- cmd -- zone= public -- add- port= 6379 / tcp -- permanent `/*将开发的端口6379保存到防火墙*/`
success
10.3 在redis.conf中绑定本Linux终端的IP地址(编辑及操作文件看上文的温馨提示
)
redis在3.2.x版本以后进行了安全升级,默认只允许本地访问,不允许远程访问,这个安全设置在redis.conf中有配置,默认只允许本地127.0.0.1访问
[ root@localhost bin] # ll `/*查看文件*/`
总用量 21952
- rw- r-- r-- . 1 root root 109 9 月 11 03 : 44 dump. rdb
- rwxr- xr- x. 1 root root 2451688 9 月 11 02 : 04 redis- benchmark
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- aof
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- check- rdb
- rwxr- xr- x. 1 root root 2617768 9 月 11 02 : 04 redis- cli
- rw- r-- r-- . 1 root root 58767 9 月 11 03 : 01 redis. conf
lrwxrwxrwx. 1 root root 12 9 月 11 02 : 04 redis- sentinel - > redis- server
- rwxr- xr- x. 1 root root 5775976 9 月 11 02 : 04 redis- server
[ root@localhost bin] # vim redis. conf `/*编辑redis.conf文件*/`
# ~ ~ ~ WARNING ~ ~ ~ If the computer running Redis is directly exposed to the
# internet, binding to all the interfaces is dangerous and will expose the
# instance to everybody on the internet. So by default we uncomment the
# following bind directive, that will force Redis to listen only into
# the IPv4 lookback interface address ( this means Redis will be able to
# accept connections only from clients running into the same computer it
# is running) .
#
# IF YOU ARE SURE YOU WANT YOUR INSTANCE TO LISTEN TO ALL THE INTERFACES
# JUST COMMENT THE FOLLOWING LINE .
# ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~
bind 127.0 .0 .1 192.168 .198 .130 `#绑定本Linux主机的IP地址(前面是Windows的本机IP地址)`
10.4 重启Redis服务器
[ root@localhost bin] # . / redis- cli shutdown `/*关闭Linux终端上Redis客户端*/`
[ root@localhost bin] # . / redis- server redis. conf `/*重新启动redis的服务*/`
10.5 Windows中的Redis客户端远程连接Linux终端的Redis服务器
六、安装Nginx软件(/*注释的文字为提示*/
不要复制 )
1、安装 gcc-c++ 预编译环境
[ root@localhost / ] # yum - y install gcc- c++ `/*安装 gcc-c++ 预编译环境*/`
安装 C++的编译环境:因为 Nginx 是 C 语句开发的,我们下载下来的 Nginx 是 C 语言的源码,安装前需
要下载一个 C 语言的编译环境,所以需要安装 Gcc
2、安装 Nginx 依赖的环境
[ root@localhost / ] # yum - y install pcre pcre- devel `/*正则表达式的库:1.4M*/`
[ root@localhost / ] # yum - y install zlib zlib- devel `/*数据压缩的库:140K*/`
[ root@localhost / ] # yum - y install openssl openssl- devel `/*安全证书的库:6.5M*/`
3、将Nginx解压到/software文件目录下
[ root@localhost software] # ll `/*查看文件*/`
总用量 193440
- rw- r-- r-- . 1 root root 9625824 9 月 10 14 : 18 apache- tomcat- 8.5 .34 . tar. gz
- rw- r-- r-- . 1 root root 185646832 9 月 10 14 : 19 jdk- 8 u181- linux- x64. tar. gz
- rw- r-- r-- . 1 root root 25820 9 月 10 21 : 28 mysql80- community- release- el7- 1. noarch. rpm
- rw- r-- r-- . 1 root root 1032630 9 月 10 14 : 19 nginx- 1.16 .1 . tar. gz
- rw- r-- r-- . 1 root root 1739656 9 月 10 14 : 19 redis- 4.0 .11 . tar. gz
[ root@localhost software] # tar - zxvf nginx- 1.16 .1 . tar. gz `/*将Nginx解压到/software文件目录下*/`
4、解压后会在/software目录下出现nginx-1.16.1目录
[ root@localhost software] # ll `/*查看文件*/`
总用量 193440
- rw- r-- r-- . 1 root root 9625824 9 月 10 14 : 18 apache- tomcat- 8.5 .34 . tar. gz
- rw- r-- r-- . 1 root root 185646832 9 月 10 14 : 19 jdk- 8 u181- linux- x64. tar. gz
- rw- r-- r-- . 1 root root 25820 9 月 10 21 : 28 mysql80- community- release- el7- 1. noarch. rpm
drwxr- xr- x. 8 1001 1001 158 8 月 13 20 : 51 nginx- 1.16 .1
- rw- r-- r-- . 1 root root 1032630 9 月 10 14 : 19 nginx- 1.16 .1 . tar. gz
- rw- r-- r-- . 1 root root 1739656 9 月 10 14 : 19 redis- 4.0 .11 . tar. gz
5、在nginx-1.16.1文件目录下,执行 configure 文件./configure,作用:运行配置脚本,检查安装环境是否正确
[ root@localhost software] # cd nginx- 1.16 .1 `/*去nginx-1.16.1文件目录下*/`
[ root@localhost nginx- 1.16 .1 ] # ll `/*查看文件*/`
总用量 752
drwxr- xr- x. 6 1001 1001 4096 9 月 11 06 : 27 auto
- rw- r-- r-- . 1 1001 1001 296463 8 月 13 20 : 51 CHANGES
- rw- r-- r-- . 1 1001 1001 452171 8 月 13 20 : 51 CHANGES . ru
drwxr- xr- x. 2 1001 1001 168 9 月 11 06 : 27 conf
- rwxr- xr- x. 1 1001 1001 2502 8 月 13 20 : 51 configure
drwxr- xr- x. 4 1001 1001 72 9 月 11 06 : 27 contrib
drwxr- xr- x. 2 1001 1001 40 9 月 11 06 : 27 html
- rw- r-- r-- . 1 1001 1001 1397 8 月 13 20 : 51 LICENSE
drwxr- xr- x. 2 1001 1001 21 9 月 11 06 : 27 man
- rw- r-- r-- . 1 1001 1001 49 8 月 13 20 : 51 README
drwxr- xr- x. 9 1001 1001 91 9 月 11 06 : 27 src
[ root@localhost nginx- 1.16 .1 ] # . / configure `/*执行配置命令*/`
默认是将Nginx安装到/usr/local/目录下
Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using system zlib library
nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
6、在 nginx-1.16.1 的解压目录下编译与安装 nginx
[ root@localhost nginx- 1.16 .1 ] # make && make install `/*执行安装命令*/`
make[ 1 ] : 离开目录“/ software/ nginx- 1.16 .1 ”
7、去到安装后的/usr/local/nginx/文件目录下
[ root@localhost nginx- 1.16 .1 ] # cd / usr/ local/ nginx/ `/*去到安装后的/usr/local/nginx/文件目录下*/`
[ root@localhost nginx] # ll `/*查看文件*/`
总用量 4
drwxr- xr- x. 2 root root 4096 9 月 11 06 : 42 conf
drwxr- xr- x. 2 root root 40 9 月 11 06 : 42 html
drwxr- xr- x. 2 root root 6 9 月 11 06 : 42 logs
drwxr- xr- x. 2 root root 19 9 月 11 06 : 42 sbin
8、进入 sbin 目录启动 nginx 服务器
[ root@localhost nginx] # cd sbin `/*进入Sbin目录*/`
[ root@localhost sbin] # ll `/*查看文件*/`
总用量 3736
- rwxr- xr- x. 1 root root 3825544 9 月 11 06 : 42 nginx
[ root@localhost sbin] # . / nginx `/*启动nginx服务器*/`
这时还不能在Google Chrome浏览器访问Nginx
9、开放80端口号,重启防火墙服务
9.1 开放80端口号
[ root@localhost sbin] # firewall- cmd -- zone= public -- add- port= 80 / tcp -- permanent `/*开放80端口号*/`
success `/*成功*/`
9.2 重启防火墙服务
[ root@localhost sbin] # systemctl restart firewalld `/*重启防火墙服务*/`
10、在Google Chrome浏览器访问Nginx
七、安装Zookeeper注册中心(/*注释的文字为提示*/
不要复制 )
1、使用Xftp工具将软件上传到指定的文件夹(一、安装前的准备
)
2、将Zookeeper解压到/usr/local/文件目录下
[ root@localhost / ] # cd / software `/*去software文件下*/`
[ root@localhost software] # ll `/*去看文件*/`
总用量 292716
- rw- r-- r-- . 1 root root 9536557 8 月 29 20 : 26 apache- tomcat- 8.5 .27 . tar. gz
- rw- r-- r-- . 1 root root 185646832 8 月 29 20 : 28 jdk- 8 u181- linux- x64. tar. gz
- rw- r-- r-- . 1 root root 1022881 9 月 9 15 : 01 nginx- 1.15 .3 . tar. gz
- rw- r-- r-- . 1 root root 1032630 9 月 9 21 : 30 nginx- 1.16 .1 . tar. gz
- rw- r-- r-- . 1 root root 1550452 8 月 29 20 : 26 redis- 3.2 .11 . tar. gz
- rw- r-- r-- . 1 root root 78677527 9 月 9 14 : 58 Travel. war
- rw- r-- r-- . 1 root root 22261552 10 月 13 20 : 47 zookeeper- 3.4 .8 . tar. gz
[ root@localhost software] # tar - zvxf zookeeper- 3.4 .8 . tar. gz - C / usr/ local/ `/*将Zookeeper解压到/usr/local/文件目录下*/`
3、去Zookeeper解压后的目录下
[ root@localhost software] # cd / usr/ local/ `/*去Zookeeper解压后的目录下*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 12
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxr- xr- x. 2 root root 56 8 月 29 23 : 47 mysql
drwxr- xr- x. 11 root root 151 9 月 9 22 : 03 nginx
drwxr- xr- x. 9 1001 1001 186 9 月 9 21 : 59 nginx- 1.16 .1
drwxrwxr- x. 7 root root 4096 8 月 29 21 : 21 redis
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
drwxr- xr- x. 9 root root 160 8 月 29 20 : 40 tomcat
drwxr- xr- x. 10 1000 1000 4096 2 月 6 2016 zookeeper- 3.4 .8
4、将zookeeper-3.4.8文件夹名称重命名为zookeeper
[ root@localhost local] # mv zookeeper- 3.4 .8 zookeeper `/*将zookeeper-3.4.8文件夹名称重命名为zookeeper*/`
[ root@localhost local] # ll `/*查看文件*/`
总用量 8
drwxr- xr- x. 2 root root 6 11 月 5 2016 bin
drwxr- xr- x. 2 root root 6 11 月 5 2016 etc
drwxr- xr- x. 2 root root 6 11 月 5 2016 games
drwxr- xr- x. 2 root root 6 11 月 5 2016 include
drwxr- xr- x. 7 10 143 245 7 月 7 2018 jdk
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib
drwxr- xr- x. 2 root root 6 11 月 5 2016 lib64
drwxr- xr- x. 2 root root 6 11 月 5 2016 libexec
drwxr- xr- x. 2 root root 56 8 月 29 23 : 47 mysql
drwxr- xr- x. 11 root root 151 9 月 9 22 : 03 nginx
drwxr- xr- x. 9 1001 1001 186 9 月 9 21 : 59 nginx- 1.16 .1
drwxrwxr- x. 7 root root 4096 8 月 29 21 : 21 redis
drwxr- xr- x. 2 root root 6 11 月 5 2016 sbin
drwxr- xr- x. 5 root root 49 8 月 30 00 : 32 share
drwxr- xr- x. 2 root root 6 11 月 5 2016 src
drwxr- xr- x. 9 root root 160 8 月 29 20 : 40 tomcat
drwxr- xr- x. 11 1000 1000 4096 10 月 13 21 : 19 zookeeper `/*重命名*/`
3、进入/usr/local/zookeeper目录下,创建data文件夹
[ root@localhost local] # cd zookeeper `/*进入/usr/local/zookeeper目录下*/`
[ root@localhost zookeeper] # mkdir data `/*创建data文件夹*/`
[ root@localhost zookeeper] # ll `/*查看文件*/`
总用量 1556
drwxr- xr- x. 2 1000 1000 170 10 月 14 09 : 08 bin
- rw- rw- r-- . 1 1000 1000 83235 2 月 6 2016 build. xml
- rw- rw- r-- . 1 1000 1000 88625 2 月 6 2016 CHANGES . txt
drwxr- xr- x. 2 1000 1000 90 10 月 14 09 : 04 conf
drwxr- xr- x. 10 1000 1000 130 2 月 6 2016 contrib
drwxr- xr- x. 3 root root 23 10 月 14 09 : 09 data `/*创建的data文件夹*/`
drwxr- xr- x. 2 1000 1000 4096 2 月 6 2016 dist- maven
drwxr- xr- x. 6 1000 1000 4096 2 月 6 2016 docs
- rw- rw- r-- . 1 1000 1000 1953 2 月 6 2016 ivysettings. xml
- rw- rw- r-- . 1 1000 1000 3498 2 月 6 2016 ivy. xml
drwxr- xr- x. 4 1000 1000 266 2 月 6 2016 lib
- rw- rw- r-- . 1 1000 1000 11938 2 月 6 2016 LICENSE . txt
- rw- rw- r-- . 1 1000 1000 171 2 月 6 2016 NOTICE . txt
- rw- rw- r-- . 1 1000 1000 1770 2 月 6 2016 README_packaging. txt
- rw- rw- r-- . 1 1000 1000 1585 2 月 6 2016 README . txt
drwxr- xr- x. 5 1000 1000 47 2 月 6 2016 recipes
drwxr- xr- x. 8 1000 1000 191 2 月 6 2016 src
- rw- rw- r-- . 1 1000 1000 1360961 2 月 6 2016 zookeeper- 3.4 .8 . jar
- rw- rw- r-- . 1 1000 1000 819 2 月 6 2016 zookeeper- 3.4 .8 . jar. asc
- rw- rw- r-- . 1 1000 1000 33 2 月 6 2016 zookeeper- 3.4 .8 . jar. md5
- rw- rw- r-- . 1 1000 1000 41 2 月 6 2016 zookeeper- 3.4 .8 . jar. sha1
4、进入/usr/local/zookeeper/conf目录下
[ root@localhost zookeeper] # cd conf `/*进入/usr/local/zookeeper/conf目录下*/`
[ root@localhost conf] # ll `/*查看文件*/`
总用量 12
- rw- rw- r-- . 1 1000 1000 535 2 月 6 2016 configuration. xsl
- rw- rw- r-- . 1 1000 1000 2161 2 月 6 2016 log4j. properties
- rw- rw- r-- . 1 1000 1000 933 10 月 14 09 : 04 zoo_sample. cfg
5、将zoo_sample.cfg文件夹名称重命名为zoo.cfg
[ root@localhost conf] # mv zoo_sample. cfg zoo. cfg `/*将zoo_sample.cfg文件夹名称重命名为zoo.cfg*/`
[ root@localhost conf] # ll `/*查看文件*/`
总用量 12
- rw- rw- r-- . 1 1000 1000 535 2 月 6 2016 configuration. xsl
- rw- rw- r-- . 1 1000 1000 2161 2 月 6 2016 log4j. properties
- rw- rw- r-- . 1 1000 1000 933 10 月 14 09 : 04 zoo. cfg `/*重命名后的文件*/`
6、编辑zoo.cfg文件,将dataDir=/tmp/zookeeper改为dataDit=/usr/local/zookeeper/data(编辑文件的操作——上文的温馨提示
)
[ root@localhost conf] # vim zoo. cfg `/*编辑zoo.cfg文件*/`
# The number of milliseconds of each tick
tickTime= 2000
# The number of ticks that the initial
# synchronization phase can take
initLimit= 10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit= 5
# the directory where the snapshot is stored.
# do not use / tmp for storage, / tmp here is just
# example sakes.
dataDir= / tmp/ zookeeper/ `/*改为dataDir=/usr/local/zookeeper/data*/`
# the port at which the clients will connect
clientPort= 2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns= 60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http: / / zookeeper. apache. org/ doc/ current/ zookeeperAdmin. html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge. snapRetainCount= 3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge. purgeInterval= 1
执行上文温馨提示中的4、5步骤保存并退出
8、进入bin目录下
[ root@localhost conf] # cd . . `*返回到上一级目录*`
[ root@localhost zookeeper] # ll `*查看文件*`
总用量 1556
drwxr- xr- x. 2 1000 1000 170 10 月 14 09 : 08 bin
- rw- rw- r-- . 1 1000 1000 83235 2 月 6 2016 build. xml
- rw- rw- r-- . 1 1000 1000 88625 2 月 6 2016 CHANGES . txt
drwxr- xr- x. 2 1000 1000 90 10 月 14 10 : 40 conf
drwxr- xr- x. 10 1000 1000 130 2 月 6 2016 contrib
drwxr- xr- x. 3 root root 23 10 月 14 09 : 09 data
drwxr- xr- x. 2 1000 1000 4096 2 月 6 2016 dist- maven
drwxr- xr- x. 6 1000 1000 4096 2 月 6 2016 docs
- rw- rw- r-- . 1 1000 1000 1953 2 月 6 2016 ivysettings. xml
- rw- rw- r-- . 1 1000 1000 3498 2 月 6 2016 ivy. xml
drwxr- xr- x. 4 1000 1000 266 2 月 6 2016 lib
- rw- rw- r-- . 1 1000 1000 11938 2 月 6 2016 LICENSE . txt
- rw- rw- r-- . 1 1000 1000 171 2 月 6 2016 NOTICE . txt
- rw- rw- r-- . 1 1000 1000 1770 2 月 6 2016 README_packaging. txt
- rw- rw- r-- . 1 1000 1000 1585 2 月 6 2016 README . txt
drwxr- xr- x. 5 1000 1000 47 2 月 6 2016 recipes
drwxr- xr- x. 8 1000 1000 191 2 月 6 2016 src
- rw- rw- r-- . 1 1000 1000 1360961 2 月 6 2016 zookeeper- 3.4 .8 . jar
- rw- rw- r-- . 1 1000 1000 819 2 月 6 2016 zookeeper- 3.4 .8 . jar. asc
- rw- rw- r-- . 1 1000 1000 33 2 月 6 2016 zookeeper- 3.4 .8 . jar. md5
- rw- rw- r-- . 1 1000 1000 41 2 月 6 2016 zookeeper- 3.4 .8 . jar. sha
[ root@localhost zookeeper] # cd bin `/*进入bin目录下*/`
[ root@localhost bin] # ll `/*查看文件*/`
总用量 40
- rwxr- xr- x. 1 1000 1000 232 2 月 6 2016 README . txt
- rwxr- xr- x. 1 1000 1000 1937 2 月 6 2016 zkCleanup. sh
- rwxr- xr- x. 1 1000 1000 1056 2 月 6 2016 zkCli. cmd
- rwxr- xr- x. 1 1000 1000 1534 2 月 6 2016 zkCli. sh
- rwxr- xr- x. 1 1000 1000 1628 2 月 6 2016 zkEnv. cmd
- rwxr- xr- x. 1 1000 1000 2696 2 月 6 2016 zkEnv. sh
- rwxr- xr- x. 1 1000 1000 1089 2 月 6 2016 zkServer. cmd
- rwxr- xr- x. 1 1000 1000 6773 2 月 6 2016 zkServer. sh
- rw- r-- r-- . 1 root root 3872 10 月 14 09 : 08 zookeeper. out
9、启动、终止、查看服务的操作
9.1 启动zookeeper的服务
[ root@localhost bin] # . / zkServer. sh start `/*启动zookeeper的服务*/`
ZooKeeper JMX enabled by default
Using config: / usr/ local/ zookeeper/ bin/ . . / conf/ zoo. cfg
Starting zookeeper ... STARTED
9.2 终止zookeeper的服务
[ root@localhost bin] # . / zkServer. sh stop `/*终止zookeeper的服务*/`
ZooKeeper JMX enabled by default
Using config: / usr/ local/ zookeeper/ bin/ . . / conf/ zoo. cfg
Stopping zookeeper ... STOPPED
9.3 查看zookeeper的服务状态
[ root@localhost bin] # . / zkServer. sh status `/*查看zookeeper的服务状态*/`
ZooKeeper JMX enabled by default
Using config: / usr/ local/ zookeeper/ bin/ . . / conf/ zoo. cfg
Error contacting service. It is probably not running.
10、在Linux终端开放Zookeeper的端口2081
[ root@localhost bin] # cd / `/*去根目录下*/`
[ root@localhost / ] # firewall- cmd -- zone= public -- add- port= 2181 / tcp -- permanent `/*开放Zookeeper的端口2081*/`
success
11、重新启动防火墙服务
[ root@localhost / ] # systemctl restart firewalld