【推荐】2019 Java 开发者跳槽指南.pdf(吐血整理) >>>
MariaDB介绍
MariaDB数据库管理系统是MySQL的一个分支,主要由开源社区在维护,采用GPL授权许可 MariaDB的目的是完全兼容MySQL,包括API和命令行,使之能轻松成为MySQL的代替品。在存储引擎方面,使用XtraDB(英语:XtraDB)来代替MySQL的InnoDB。 MariaDB由MySQL的创始人Michael Widenius(英语:Michael Widenius)主导开发,他早前曾以10亿美元的价格,将自己创建的公司MySQL AB卖给了SUN,此后,随着SUN被甲骨文收购,MySQL的所有权也落入Oracle的手中。MariaDB名称来自Michael Widenius的女儿Maria的名字。
MariaDB安装
- 先进入/usr/local/src 目录
- 下载 wget https://downloads.mariadb.org/interstitial/mariadb-10.2.6/bintar-linux-glibc_214-x86_64/mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz,我在使用这个命令下载不成功,提示错误,于是去官网下载到本地pc然后上传到/usr/local/src目录下的。
- 解压 tar zxvf mariadb-10.2.6-linux-glibc_214-x86_64.tar.gz
- 将解压好的文件移动至/usr/local/mariadb中
mv mariadb-10.2.6-linux-glibc_214-x86_64 /usr/local/mariadb
- 进入 /usr/local/mariadb/目录
./scripts/mysql_install_db --user=mysql --basedir=/usr/local/mariadb/ --datadir=/data/mariadb
执行该命令初始化,初始化完成后执行echo $? 来验证初始化是否成功。- 拷贝配置文件,修改配置文件
cp support-files/my-small.cnf /usr/local/mariadb/my.cnf
有好几个配置文件,small huge large 等,根据实际内存大小选择配置文件。 需要指定datadir否则它在启动的时候回自动去找/data/mysql
[mysqld]
datadir=/data/mariadb
- cp 启动脚本
cp support-files/mysql.server /etc/init.d/mariadb
然后编辑/etc/init.d/mariadb ,因为我们的配置文件并不是/etc/my.cnf所以在启动脚本中需要修改几个地方
basedir=/usr/local/mariadb
datadir=/data/mariadb
conf=$dasedir/my.cnf
- 在启动命令处需要指定配置文件
$bindir/mysqld_safe --defaults-file=$conf --datadir="$datadir" --pid-file="$mysqld_pid_file_path" "$@" & --defaults-file=$conf是我们添加的内容
- 启动mariadb /etc/init.d/mariadb start
[root@llll ~]# /etc/init.d/mariadb start
Starting mariadb (via systemctl): [ 确定 ]
[root@llll ~]# ps aux |grep mariadb
root 2467 0.0 0.0 115436 1768 ? S 12:03 0:00 /bin/sh /usr/local/mariadb/bin/mysqld_safe --defaults-file=/usr/local/mariadb/my.cnf --datadir=/data/mariadb --pid-file=/data/mariadb/llll.pid
mysql 2586 0.1 1.7 1649864 66572 ? Sl 12:03 0:03 /usr/local/mariadb/bin/mysqld --defaults-file=/usr/local/mariadb/my.cnf --basedir=/usr/local/mariadb --datadir=/data/mariadb --plugin-dir=/usr/local/mariadb/lib/plugin --user=mysql --log-error=/data/mariadb/llll.err --pid-file=/data/mariadb/llll.pid --socket=/tmp/mysql.sock --port=3306
root 2671 0.0 0.0 112724 972 pts/0 S+ 12:39 0:00 grep --color=auto mariadb
- 如果要开机启动,则需要把/etc/init.d/mariadb添加到chkconfig工具中
[root@llll ~]# chkconfig --add mariadb
[root@llll ~]# chkconfig
注意:该输出结果只显示 SysV 服务,并不包含原生 systemd 服务。SysV 配置数据可能被原生 systemd 配置覆盖。
如果您想列出 systemd 服务,请执行 'systemctl list-unit-files'。
欲查看对特定 target 启用的服务请执行
'systemctl list-dependencies [target]'。
iprdump 0:关 1:关 2:开 3:开 4:开 5:开 6:关
iprinit 0:关 1:关 2:开 3:开 4:开 5:开 6:关
iprupdate 0:关 1:关 2:开 3:开 4:开 5:开 6:关
mariadb 0:关 1:关 2:开 3:开 4:开 5:开 6:关
netconsole 0:关 1:关 2:关 3:关 4:关 5:关 6:关
network 0:关 1:关 2:开 3:关 4:关 5:开 6:关
到这里mariadb就安装并启动了。
使用源码包安装Apache
Apache HTTP Server(简称Apache)是Apache软件基金会的一个开放源码的网页服务器,可以在大多数计算机操作系统中运行,由于其多平台和安全性被广泛使用,是最流行的Web服务器端软件之一。它快速、可靠并且可通过简单的API扩展,将Perl/Python等解释器编译到服务器中。 apr和apr-util是一个通用的函数库,它让httpd可以不关心底层的操作系统平台,可以很方便的移植(从Linux移植到Windows)
- 进入/usr/local/src 目录下
- 下载httpd包
wget http://mirrors.hust.edu.cn/apache/httpd/httpd-2.4.34.tar.gz
- 下载apr
wget http://mirrors.hust.edu.cn/apache/apr/apr-1.5.2.tar.gz
- 下载apr-util
wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.6.1.tar.gz
- 解压上面下载的三个包
tar zxvf httpd-2.4.34.tar.gz
- 进入cd /usr/local/src/apr-1.6.3
- 编译apr ./configure --prefix=/usr/local/apr ,编译完了之后可以使用echo $? 验证编译是否有问题,输出值为0则表示没有问题。
- 安装
make && make install
命令直接安装,安装完之后同样可以使用echo $? 验证 - cd /usr/local/src/apr-util-1.6.1
- 编译arp-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/
编译apr-util时需要指定apr的安装路径 --with-apr= 编译完成后验证echo $?。 - 安装 make && make install 安装完成后验证echo $?
- 提示错误,这是因为缺少expat-devel包,运行yum install -y expat-devel
xml/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录
#include <expat.h>
^
编译中断。
make[1]: *** [xml/apr_xml.lo] 错误 1
make[1]: 离开目录“/usr/local/src/apr-util-1.6.1”
make: *** [all-recursive] 错误 1
然后在make && make install 就可以了。
- 进入
cd httpd-2.4.34
./configure\ --prefix=/usr/local/apache2.4 \ --with-apr=/usr/local/apr\ --with-apr-util=/usr/local/apr-util/ \ --enable-so --enable-mods-shared=most
其中with-apr 和with-apr-util是Apache依赖这两个包,需要指定 --enable-so是让Apache能支持动态扩展模块 --enable-mods-shared=most 是让它能支持绝大多数的动态模块- 在make && make install 的时候遇到了一个新的问题
make[2]: *** [htpasswd] 错误 1
解决这个问题可以使用如下办法:
# cd /usr/local/src/
# cp -r apr-1.6.3 /usr/local/src/httpd-2.4.33/srclib/apr
# cp -r apr-util-1.6.1 /usr/local/src/httpd-2.4.33/srclib/apr-util
- 然后在重新./configure
./configure --prefix=/usr/local/apache2.4 --with-included-apr --with-included-apr-util --enable-so --enable-mods-shared=most
- 最后一步 make && make install 完成后echo $? 验证是否有问题
- 查看Apache支持的扩展模块 每个模块都代表一种功能
[root@llll httpd-2.4.34]# ls /usr/local/apache2.4/modules/
httpd.exp mod_authn_dbm.so mod_buffer.so mod_expires.so mod_log_config.so mod_proxy_fdpass.so mod_request.so mod_speling.so
mod_access_compat.so mod_authn_file.so mod_cache_disk.so mod_ext_filter.so mod_log_debug.so mod_proxy_ftp.so mod_rewrite.so mod_status.so
mod_actions.so mod_authn_socache.so mod_cache.so mod_file_cache.so mod_logio.so mod_proxy_hcheck.so mod_sed.so mod_substitute.so
mod_alias.so mod_authz_core.so mod_cache_socache.so mod_filter.so mod_macro.so mod_proxy_http.so mod_session_cookie.so mod_unique_id.so
mod_allowmethods.so mod_authz_dbd.so mod_cgid.so mod_headers.so mod_mime.so mod_proxy_scgi.so mod_session_dbd.so mod_unixd.so
mod_auth_basic.so mod_authz_dbm.so mod_dav_fs.so mod_include.so mod_negotiation.so mod_proxy.so mod_session.so mod_userdir.so
mod_auth_digest.so mod_authz_groupfile.so mod_dav.so mod_info.so mod_proxy_ajp.so mod_proxy_uwsgi.so mod_setenvif.so mod_version.so
mod_auth_form.so mod_authz_host.so mod_dbd.so mod_lbmethod_bybusyness.so mod_proxy_balancer.so mod_proxy_wstunnel.so mod_slotmem_shm.so mod_vhost_alias.so
mod_authn_anon.so mod_authz_owner.so mod_dir.so mod_lbmethod_byrequests.so mod_proxy_connect.so mod_ratelimit.so mod_socache_dbm.so mod_watchdog.so
mod_authn_core.so mod_authz_user.so mod_dumpio.so mod_lbmethod_bytraffic.so mod_proxy_express.so mod_remoteip.so mod_socache_memcache.so
mod_authn_dbd.so mod_autoindex.so mod_env.so mod_lbmethod_heartbeat.so mod_proxy_fcgi.so mod_reqtimeout.so mod_socache_shmcb.so
- 查看加载的模块
[root@llll httpd-2.4.34]# /usr/local/apache2.4/bin/httpd -M
AH00557: httpd: apr_sockaddr_info_get() failed for llll
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
Loaded Modules:
core_module (static) static这种是绑定在/usr/local/apache2.4/bin/httpd当中的
so_module (static)
http_module (static)
mpm_event_module (static)
authn_file_module (shared) shared是扩展模块,就是上面.so结尾的文件
authn_core_module (shared)
authz_host_module (shared)
authz_groupfile_module (shared)
authz_user_module (shared)
authz_core_module (shared)
access_compat_module (shared)
- 启动服务/usr/local/apache2.4/bin/apachectl start
[root@llll ~]# /usr/local/apache2.4/bin/apachectl start
AH00557: httpd: apr_sockaddr_info_get() failed for llll
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
- 虽然提示了failed,但是我们通过ps aux |grep httpd 发现该服务是正常启动了的
[root@llll ~]# ps aux |grep httpd
root 48904 0.1 0.0 75716 2292 ? Ss 14:27 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 48905 0.0 0.1 364680 4284 ? Sl 14:27 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 48906 0.0 0.1 364680 4288 ? Sl 14:27 0:00 /usr/local/apache2.4/bin/httpd -k start
daemon 48907 0.0 0.1 364680 4284 ? Sl 14:27 0:00 /usr/local/apache2.4/bin/httpd -k start
root 48991 0.0 0.0 112720 968 pts/0 S+ 14:29 0:00 grep --color=auto httpd
- 查看端口netstat -lntp ,可以看到端口是开启的
[root@llll ~]# netstat -lntp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.1:25 0.0.0.0:* LISTEN 1576/master
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 995/sshd
tcp6 0 0 ::1:25 :::* LISTEN 1576/master
tcp6 0 0 :::3306 :::* LISTEN 2586/mysqld
tcp6 0 0 :::80 :::* LISTEN 48904/httpd
tcp6 0 0 :::22 :::* LISTEN 995/sshd
来源:oschina
链接:https://my.oschina.net/u/3731306/blog/1920211