Write the Code. Change the World.

4月 05

在CentOS8下编译安装MySQL8可能会出现Could not find rpcgen错误,而CentOS8默认的yum源下不提供rpcgen的安装包。所以需要到rpcgen的GitHub仓库上找,地址如下:

https://github.com/thkukuk/rpcsvc-proto/releases

参考:
http://www.linuxfromscratch.org/blfs/view/svn/basicnet/rpcsvc-proto.html

下载安装

wget https://github.com/thkukuk/rpcsvc-proto/archive/v1.4.1.tar.gz

tar -xzvf v1.4.1.tar.gz

./configure --sysconfdir=/etc

4月 05

官网: https://dev.mysql.com/

先下载:
当前最新版本 8.0.19

cd /usr/local/src/

mkdir mysql

cd mysql

wget https://cdn.mysql.com//Downloads/MySQL-8.0/mysql-boost-8.0.19.tar.gz

tar -xzvf mysql-boost-8.0.19.tar.gz

创建用户组以及相关目录

groupadd mysql  #创建mysql用户组
useradd -s /sbin/nologin -g mysql -M mysql   #创建mysql用户归属mysql组
mkdir /data/server/mariadb/mysql   #创建安装目录
mkdir -p /data/server/mariadb/data   #创建数据库存放目录
chown -R mysql:mysql  /data/server/mariadb/data   #给予权限

开始编译安装

cd mysql-8-0-19

cmake .  \
-DCMAKE_INSTALL_PREFIX=/alidata/service/mysql/mysql \
-DMYSQL_DATADIR=/alidata/service/mysql/data \
-DSYSCONFDIR=/etc \
-DMYSQL_TCP_PORT=3306 \
-DWITH_BOOST=/usr/local/src/mysql/mysql-8.0.19/boost \
-DDEFAULT_CHARSET=utf8 \
-DDEFAULT_COLLATION=utf8_general_ci \
-DENABLED_LOCAL_INFILE=ON \
-DWITH_INNODB_MEMCACHED=ON \
-DWITH_INNOBASE_STORAGE_ENGINE=1 \
-DWITH_FEDERATED_STORAGE_ENGINE=1 \
-DWITH_BLACKHOLE_STORAGE_ENGINE=1 \
-DWITH_ARCHIVE_STORAGE_ENGINE=1 \
-DWITHOUT_EXAMPLE_STORAGE_ENGINE=1 \
-DWITH_PERFSCHEMA_STORAGE_ENGINE=1

发现报错: Please do not build in-source. Out-of source builds are highly

这个时候这样处理

mkdir build

cd build

再 cmake  .. 后边各种参数

继续报错:

报 Could NOT find Curses 这个。缺少 ncurses-devel , 装个就可以了。

yum install ncurses-devel

然后,再重新 camke,再报错,报 Package ‘libtirpc’, required by ‘virtual:world’, not found

继续安装

yum install libtirpc-devel

继续报错 Could not find rpcgen。 在CentOS8下编译安装MySQL8可能会出现Could not find rpcgen错误,而CentOS8默认的yum源下不提供rpcgen的安装包。所以需要到rpcgen的GitHub仓库上找,

https://blog.vini123.com/381

继续报错 Could NOT find BISON

yum install bison

继续报错 Could NOT find Doxygen,然后编译安装 doxygen

git clone https://github.com/doxygen/doxygen.git

cd doxygen

cmake .. -G "Unix Makefiles"

make -j2
sudo make install

然后继续报错Could NOT find FLEX

yum install flex
安装好 doxygen 后,继续编译 mysql。

make -j2

make install

初始化数据库

cd /alidata/service/mysql/mysql

./mysqld --initialize-insecure --user=mysql --basedir=/alidata/service/mysql/mysql --datadir=/alidata/service/mysql/data

设置mysqld

cd /usr/local/src/mysql/superfiles

cp mysql.server.sh /etc/init.d/mysqld

vim /etc/init.d/mysqld

# 修改 dir 配置保存
basedir=/alidata/service/mysql/mysql
datadir=/alidata/service/mysql/data

chmod +x /etc/init.d/mysqld

chkconfig --add mysqld   #添加到系统服务
chkconfig mysqld on   #设置开机自启动   

更改环境变量

vim /etc/profile

PATH=$PATH:/alidata/service/mysql/mysql/bin   

export PATH

source /etc/profile

设置 my.conf

vim /etc/my.conf

# 内容如下
[client]
port=3306
default-character-set=utf8
#user=root
#password=123
[mysqld]
server-id=1
#skip-grant-tables
port=3306
user=mysql
max_connections=200
socket=/alidata/service/mysql/mysql.sock
basedir=/alidata/service/mysql/mysql
datadir=/alidata/service/mysql/data
pid-file=/alidata/service/mysql/mysql.pid
init-connect='SET NAMES utf8'
character-set-server=utf8
default-storage-engine=INNODB
log_error=/alidata/service/mysql/log/mysql-error.log
slow_query_log_file=/alidata/service/mysql/log/mysql-slow.log
[mysqldump]
quick
max_allowed_packet=16M
EOF

授权,设置用户组

chown -R mysql.mysql /alidata/service/mysql/mysql
chown -R mysql.mysql /alidata/service/mysql/data

chmod -R 755 /alidata/service/mysql/mysql
chmod -R 755 /alidata/service/mysql/data

启动 mysql

/etc/init.d/mysqld start

执行安全初始化脚本

# 执行,然后回车
mysql_secure_installation 

Securing the MySQL server deployment.

Connecting to MySQL using a blank password.
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Please set the password for root here.  # 设置root用户密码

New password:

Re-enter new password:

Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

 #是否删除匿名用户,生产环境建议删除
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.

#是否禁止root远程登录,根据自己的需求选择Y/n并回车,建议禁止
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.

#是否删除test数据库

Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

#是否重新加载权限表,直接回车
Reload privilege tables now? (Press y|Y for Yes, any other key for No) :

 ... skipping.
All done!

到此,设置了 root 用户密码,以及禁用远程登录 root 用户,也删除了匿名用户。那么需要创建一个新用户来使用mysql了。

请看这里: https://blog.vini123.com/382

远程连接 mysql

创建新用户,然后远程连接。

create user shenqi@'%' identified by '33441314';  

# 创建 shenqi 用户,并设置密码。但这样远程连接会报错。
caching_sha2_password' cannot be loaded: dlopen(/usr/local/lib/plugin/caching_sha2_password.so, 

# 使用 mysql_native_password 方式设置密码就好了。
ALTER USER 'shenqi'@'%' IDENTIFIED WITH mysql_native_password BY '33441314';

请看这里: https://www.iteye.com/blog/binary-space-2412769

参考

https://www.cnblogs.com/zyxnhr/p/11892702.html

4月 05

安装

github 地址:

https://github.com/kkos/oniguruma/

过程:

点击 tags,找到最新版本,寻找下载

cd /usr/local/src/php/

wget https://github.com/kkos/oniguruma/archive/v6.9.5_rc1.zip

unzip v6.9.5_rc1.zip

./autogen.sh && ./configure --prefix=/usr

# 错误
./autogen.sh: line 6: autoreconf: command not found

# 解决错误,
yum install autoconf automake libtool

make && make install

参考:

https://www.cnblogs.com/architectforest/p/12433640.html
24kplus.com/linux/1614.html

4月 05

参考版本

https://blog.vini123.com/303

https://www.24kplus.com/linux/400.html

却的依赖,然后安装:

yum install sqlite-devel

# centos8 安装 oniguruma ,yum 不行。
yum install oniguruma

yum 不行,就编译安装个哈。看这里
https://blog.vini123.com/379

configure 后会出警告如下:

php 7.4 –enable-gd 代替 –with-gd

configure: WARNING: unrecognized options: --with-freetype-dir,  --with-libxml-dir, --with-pcre-regex, --with-png-dir, --with-jpeg-dir, --enable-libxml, --enable-zip, --enable-gd

不管它,安装吧。
最后:

Wrote PEAR system config file at: /alidata/service/php/etc/pear.conf
You may want to add: /alidata/service/php/lib/php to your php.ini include_path
/usr/local/src/php/php-7.4.4/build/shtool install -c ext/phar/phar.phar /alidata/service/php/bin
ln -s -f phar.phar /alidata/service/php/bin/phar
Installing PDO headers:           /alidata/service/php/include/php/ext/pdo/

如果之前没安装 gd库,则需要安装

https://www.php.net/manual/zh/image.installation.php



4月 05

编译安装 gcc gcc-c++

官网: https://gcc.gnu.org/

安装文档:
https://gcc.gnu.org/install/

安装包镜像:
https://gcc.gnu.org/mirrors.html

https://bigsearcher.com/mirrors/gcc/releases/

发现 yum 源上的是 8.3版本,而 9.3版本已经在2020年3月12日发布了。

cd /usr/local/src/

mkdir gcc

cd gcc

wget https://bigsearcher.com/mirrors/gcc/releases/gcc-9.3.0/gcc-9.3.0.tar.gz

tar -xzvf gcc-9.3.0.tar.gz

# 哎呀 ,不熟悉。还是 yum 安装吧。强迫症郁闷。
4月 05

先更新yum并安装依赖

尽可能的安装最新版本。如果 yum 安装的不是最新版本,可以先卸载掉,再下载源码编译安装。yum 安装新包之前,可以先查看下该包是否是最新版本。编译安装后,可以 ls -l 建立软链接,下次有新包,可以再覆盖安装。

# 更新 yum 包
yum update

# 查看某个安装,比如 gcc。 它会显示是否存在该安装,该安装的版本,是否已经安装等信息。

yum list gcc

需要安装:

  1. gcc gcc-c++。它可以编译 C,C++,Ada,Object C和Java等语言。

  2. pcre pcre-devel。PCRE(Perl Compatible Regular Expressions) 是一个Perl库,包括 perl 兼容的正则表达式库。nginx 的 http 模块使用 pcre 来解析正则表达式,所以需要在 linux 上安装 pcre 库,pcre-devel 是使用 pcre 开发的一个二次开发库。

  3. nginx 使用 zlib 对 http 包的内容进行 gzip。可是,不是用 Brotli 么。两个都装,装了也没事。gzip 编译安装来个。如果不编译,使用 yum 安装,版本达不到要求。

  4. bzip2 是一个基于Burrows-Wheeler 变换的无损压缩软件,压缩效果比传统的LZ77/LZ78压缩算法来得好。

开始安装

yum install gcc gcc-c++

yum install pcre pcre-devel

yum install zlib zlib-devel

yum install bzip2

安装 openssl

https://blog.vini123.com/301

安装 cmake

https://blog.vini123.com/289

已经安装到了 usr/local/bin 下了,不需要软链了

安装 ngx_brotli

参考从前:https://blog.vini123.com/298